mirror of
https://github.com/goplus/llgo.git
synced 2025-09-26 19:51:21 +08:00
chore: llgen -abi flags (default 0)
This commit is contained in:
@@ -21,14 +21,19 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/goplus/llgo/internal/build"
|
||||
"github.com/goplus/llgo/internal/llgen"
|
||||
)
|
||||
|
||||
var (
|
||||
abi = flag.Int("abi", 0, "ABI mode (default 0). 0 = none, 1 = cfunc, 2 = allfunc.")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if len(flag.Args()) != 1 {
|
||||
fmt.Fprintln(os.Stderr, "Usage: llgen [flags] <pkg>")
|
||||
return
|
||||
}
|
||||
llgen.SmartDoFile(flag.Args()[0])
|
||||
llgen.SmartDoFileEx(flag.Args()[0], build.AbiMode(*abi))
|
||||
}
|
||||
|
@@ -27,12 +27,12 @@ import (
|
||||
)
|
||||
|
||||
func GenFrom(fileOrPkg string) string {
|
||||
pkg, err := genFrom(fileOrPkg)
|
||||
pkg, err := genFrom(fileOrPkg, 0)
|
||||
check(err)
|
||||
return pkg.LPkg.String()
|
||||
}
|
||||
|
||||
func genFrom(pkgPath string) (build.Package, error) {
|
||||
func genFrom(pkgPath string, abiMode build.AbiMode) (build.Package, error) {
|
||||
oldDbg := os.Getenv("LLGO_DEBUG")
|
||||
oldDbgSyms := os.Getenv("LLGO_DEBUG_SYMBOLS")
|
||||
dbg := isDbgSymEnabled(filepath.Join(pkgPath, "flags.txt"))
|
||||
@@ -47,6 +47,7 @@ func genFrom(pkgPath string) (build.Package, error) {
|
||||
|
||||
conf := &build.Config{
|
||||
Mode: build.ModeGen,
|
||||
AbiMode: abiMode,
|
||||
AppExt: build.DefaultAppExt(runtime.GOOS),
|
||||
}
|
||||
pkgs, err := build.Do([]string{pkgPath}, conf)
|
||||
@@ -77,7 +78,11 @@ func isDbgSymEnabled(flagsFile string) bool {
|
||||
}
|
||||
|
||||
func SmartDoFile(pkgPath string) {
|
||||
pkg, err := genFrom(pkgPath)
|
||||
SmartDoFileEx(pkgPath, 0)
|
||||
}
|
||||
|
||||
func SmartDoFileEx(pkgPath string, abiMode build.AbiMode) {
|
||||
pkg, err := genFrom(pkgPath, abiMode)
|
||||
check(err)
|
||||
|
||||
const autgenFile = "llgo_autogen.ll"
|
||||
|
Reference in New Issue
Block a user