build.Do: verbose
This commit is contained in:
@@ -5,5 +5,6 @@ import "github.com/goplus/llgo/cl/internal/stdio"
|
||||
var hello = [...]int8{'H', 'e', 'l', 'l', 'o', '\n', 0}
|
||||
|
||||
func main() {
|
||||
_ = stdio.Max(2, 100)
|
||||
stdio.Printf(&hello[0])
|
||||
}
|
||||
|
||||
@@ -28,10 +28,13 @@ _llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
define void @main() {
|
||||
_llgo_0:
|
||||
call void @main.init()
|
||||
%0 = call i64 @"github.com/goplus/llgo/cl/internal/stdio.Max"(i64 2, i64 100)
|
||||
call void (ptr, ...) @printf(ptr @main.hello)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/cl/internal/stdio.init"()
|
||||
|
||||
declare i64 @"github.com/goplus/llgo/cl/internal/stdio.Max"(i64, i64)
|
||||
|
||||
declare void @printf(ptr, ...)
|
||||
|
||||
@@ -8,3 +8,10 @@ const (
|
||||
|
||||
//go:linkname Printf printf
|
||||
func Printf(format *int8, __llgo_va_list ...any)
|
||||
|
||||
func Max(a, b int) int {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ const (
|
||||
)
|
||||
|
||||
func Do(args []string, mode Mode) {
|
||||
flags, patterns := parseArgs(args)
|
||||
flags, patterns, verbose := parseArgs(args)
|
||||
cfg := &packages.Config{
|
||||
Mode: loadSyntax | packages.NeedExportFile,
|
||||
BuildFlags: flags,
|
||||
@@ -67,8 +67,10 @@ func Do(args []string, mode Mode) {
|
||||
}
|
||||
|
||||
llssa.Initialize(llssa.InitAll)
|
||||
// llssa.SetDebug(llssa.DbgFlagAll)
|
||||
// cl.SetDebug(cl.DbgFlagAll)
|
||||
if verbose {
|
||||
llssa.SetDebug(llssa.DbgFlagAll)
|
||||
cl.SetDebug(cl.DbgFlagAll)
|
||||
}
|
||||
|
||||
prog := llssa.NewProgram(nil)
|
||||
llFiles := make([]string, 0, len(pkgs))
|
||||
@@ -122,13 +124,18 @@ func allPkgs(initial []*packages.Package, mode ssa.BuilderMode) (prog *ssa.Progr
|
||||
return
|
||||
}
|
||||
|
||||
func parseArgs(args []string) (flags, patterns []string) {
|
||||
func parseArgs(args []string) (flags, patterns []string, verbose bool) {
|
||||
for i, arg := range args {
|
||||
if !strings.HasPrefix(arg, "-") {
|
||||
return args[:i], args[i:]
|
||||
flags, patterns = args[:i], args[i:]
|
||||
return
|
||||
}
|
||||
if arg == "-v" {
|
||||
verbose = true
|
||||
}
|
||||
}
|
||||
return args, nil
|
||||
flags = args
|
||||
return
|
||||
}
|
||||
|
||||
func check(err error) {
|
||||
|
||||
Reference in New Issue
Block a user