From dfb57d66c949bb01665ea7f1b7d5acb4a9aa75d7 Mon Sep 17 00:00:00 2001 From: Loic Gelle Date: Thu, 22 Jun 2017 14:30:01 -0700 Subject: [PATCH] fix artifacts names producer --- compiler.go | 3 ++- parser.go | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/compiler.go b/compiler.go index 2d94627..247235c 100644 --- a/compiler.go +++ b/compiler.go @@ -10,6 +10,7 @@ import ( "path/filepath" "runtime" "io" + "fmt" ) func compile(args []string) { @@ -80,7 +81,6 @@ func attachBitcodePathToObject(bcFile, objFile string) { ".os", ".So", ".po": - // Store bitcode path to temp file var absBcPath, _= filepath.Abs(bcFile) tmpContent := []byte(absBcPath+"\n") @@ -163,6 +163,7 @@ func execCompile(compilerExecName string, pr ParserResult) { // Executes a command then returns true if there was an error func execCmd(cmdExecName string, args []string) bool { + fmt.Println(args) cmd := exec.Command(cmdExecName, args...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr diff --git a/parser.go b/parser.go index 72931c9..07b49e1 100644 --- a/parser.go +++ b/parser.go @@ -4,6 +4,7 @@ import( "fmt" "regexp" "runtime" + "path" "path/filepath" "strings" "crypto/sha256" @@ -214,7 +215,7 @@ func parse(argList []string) ParserResult { } } - + fmt.Println(pr) return pr } @@ -222,16 +223,18 @@ func parse(argList []string) ParserResult { func getArtifactNames(pr ParserResult, srcFileIndex int, hidden bool) (objBase string, bcBase string) { if len(pr.InputFiles) == 1 && pr.IsCompileOnly && len(pr.OutputFilename) > 0 { objBase = pr.OutputFilename - bcBase = fmt.Sprintf(".%s.bc", objBase) + dir, baseName := path.Split(objBase) + bcBaseName := fmt.Sprintf(".%s.bc", baseName) + bcBase = path.Join(dir, bcBaseName) } else { srcFile := pr.InputFiles[srcFileIndex] - var baseNameWithExt = filepath.Base(srcFile) + var dir, baseNameWithExt = path.Split(srcFile) var baseName = strings.TrimSuffix(baseNameWithExt, filepath.Ext(baseNameWithExt)) bcBase = fmt.Sprintf(".%s.o.bc", baseName) if hidden { - objBase = fmt.Sprintf(".%s.o", baseName) + objBase = path.Join(dir, fmt.Sprintf(".%s.o", baseName)) } else { - objBase = fmt.Sprintf("%s.o", baseName) + objBase = path.Join(dir, fmt.Sprintf("%s.o", baseName)) } } return