From 0cf14152fe3158ab582bcf187e09beb6ff538e87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gelle?= Date: Wed, 5 Jul 2017 12:52:06 -0700 Subject: [PATCH] fix print only case --- shared/compiler.go | 6 +++--- shared/parser.go | 8 +++++++- shared/utils.go | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/shared/compiler.go b/shared/compiler.go index 12301b1..22ccfcc 100644 --- a/shared/compiler.go +++ b/shared/compiler.go @@ -31,18 +31,18 @@ func Compile(args []string, compilerName string) (exitCode int) { var pr = parse(args) var wg sync.WaitGroup - // If configure only is set, just execute the compiler - if configureOnly { + // If configure only or print only are set, just execute the compiler + if configureOnly || pr.IsPrintOnly { wg.Add(1) go execCompile(compilerExecName, pr, &wg, &ok) wg.Wait() - // Else try to build bitcode as well if !ok { exitCode = 1 } + // Else try to build bitcode as well } else { var bcObjLinks []bitcodeToObjectLink var newObjectFiles []string diff --git a/shared/parser.go b/shared/parser.go index 0246b6d..6237649 100644 --- a/shared/parser.go +++ b/shared/parser.go @@ -25,6 +25,7 @@ type parserResult struct { IsAssembly bool IsCompileOnly bool IsEmitLLVM bool + IsPrintOnly bool } type flagInfo struct { @@ -37,6 +38,7 @@ func parse(argList []string) parserResult { pr.InputList = argList var argsExactMatches = map[string]flagInfo{ + "-": {0, pr.printOnlyCallback}, "-o": {1, pr.outputFileCallback}, "-c": {0, pr.compileOnlyCallback}, "-E": {0, pr.preprocessOnlyCallback}, @@ -194,7 +196,7 @@ func parse(argList []string) parserResult { `^-print-file-name=.*$`: {0, pr.compileUnaryCallback}, } - for len(argList) > 0 && !(pr.IsAssembly || pr.IsAssembleOnly || pr.IsPreprocessOnly) { + for len(argList) > 0 { var elem = argList[0] // Try to match the flag exactly @@ -279,6 +281,10 @@ func (pr *parserResult) dependencyOnlyCallback(flag string, _ []string) { pr.CompileArgs = append(pr.CompileArgs, flag) } +func (pr *parserResult) printOnlyCallback(flag string, _ []string) { + pr.IsPrintOnly = true +} + func (pr *parserResult) assembleOnlyCallback(_ string, _ []string) { pr.IsAssembleOnly = true } diff --git a/shared/utils.go b/shared/utils.go index a989015..dbf5c60 100644 --- a/shared/utils.go +++ b/shared/utils.go @@ -10,6 +10,7 @@ func execCmd(cmdExecName string, args []string, workingDir string) (success bool cmd := exec.Command(cmdExecName, args...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr + cmd.Stdin = os.Stdin cmd.Dir = workingDir err = cmd.Run() success = (err == nil)