mirror of
https://github.com/danog/gllvm.git
synced 2024-11-26 23:14:41 +01:00
fix print only case
This commit is contained in:
parent
09ffb6d8e4
commit
0cf14152fe
@ -31,18 +31,18 @@ func Compile(args []string, compilerName string) (exitCode int) {
|
|||||||
var pr = parse(args)
|
var pr = parse(args)
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
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)
|
wg.Add(1)
|
||||||
go execCompile(compilerExecName, pr, &wg, &ok)
|
go execCompile(compilerExecName, pr, &wg, &ok)
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
// Else try to build bitcode as well
|
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
exitCode = 1
|
exitCode = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Else try to build bitcode as well
|
||||||
} else {
|
} else {
|
||||||
var bcObjLinks []bitcodeToObjectLink
|
var bcObjLinks []bitcodeToObjectLink
|
||||||
var newObjectFiles []string
|
var newObjectFiles []string
|
||||||
|
@ -25,6 +25,7 @@ type parserResult struct {
|
|||||||
IsAssembly bool
|
IsAssembly bool
|
||||||
IsCompileOnly bool
|
IsCompileOnly bool
|
||||||
IsEmitLLVM bool
|
IsEmitLLVM bool
|
||||||
|
IsPrintOnly bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type flagInfo struct {
|
type flagInfo struct {
|
||||||
@ -37,6 +38,7 @@ func parse(argList []string) parserResult {
|
|||||||
pr.InputList = argList
|
pr.InputList = argList
|
||||||
|
|
||||||
var argsExactMatches = map[string]flagInfo{
|
var argsExactMatches = map[string]flagInfo{
|
||||||
|
"-": {0, pr.printOnlyCallback},
|
||||||
"-o": {1, pr.outputFileCallback},
|
"-o": {1, pr.outputFileCallback},
|
||||||
"-c": {0, pr.compileOnlyCallback},
|
"-c": {0, pr.compileOnlyCallback},
|
||||||
"-E": {0, pr.preprocessOnlyCallback},
|
"-E": {0, pr.preprocessOnlyCallback},
|
||||||
@ -194,7 +196,7 @@ func parse(argList []string) parserResult {
|
|||||||
`^-print-file-name=.*$`: {0, pr.compileUnaryCallback},
|
`^-print-file-name=.*$`: {0, pr.compileUnaryCallback},
|
||||||
}
|
}
|
||||||
|
|
||||||
for len(argList) > 0 && !(pr.IsAssembly || pr.IsAssembleOnly || pr.IsPreprocessOnly) {
|
for len(argList) > 0 {
|
||||||
var elem = argList[0]
|
var elem = argList[0]
|
||||||
|
|
||||||
// Try to match the flag exactly
|
// Try to match the flag exactly
|
||||||
@ -279,6 +281,10 @@ func (pr *parserResult) dependencyOnlyCallback(flag string, _ []string) {
|
|||||||
pr.CompileArgs = append(pr.CompileArgs, flag)
|
pr.CompileArgs = append(pr.CompileArgs, flag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pr *parserResult) printOnlyCallback(flag string, _ []string) {
|
||||||
|
pr.IsPrintOnly = true
|
||||||
|
}
|
||||||
|
|
||||||
func (pr *parserResult) assembleOnlyCallback(_ string, _ []string) {
|
func (pr *parserResult) assembleOnlyCallback(_ string, _ []string) {
|
||||||
pr.IsAssembleOnly = true
|
pr.IsAssembleOnly = true
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ func execCmd(cmdExecName string, args []string, workingDir string) (success bool
|
|||||||
cmd := exec.Command(cmdExecName, args...)
|
cmd := exec.Command(cmdExecName, args...)
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
cmd.Stdin = os.Stdin
|
||||||
cmd.Dir = workingDir
|
cmd.Dir = workingDir
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
success = (err == nil)
|
success = (err == nil)
|
||||||
|
Loading…
Reference in New Issue
Block a user