mirror of
https://github.com/danog/gllvm.git
synced 2024-11-30 05:59:02 +01:00
Keep the formating gods at bay (or PG&E will not restore my power)
This commit is contained in:
parent
28f0ce31f2
commit
f464fcac22
@ -198,7 +198,7 @@ func attachBitcodePathToObject(bcFile, objFile string) (success bool) {
|
|||||||
err = out.Sync()
|
err = out.Sync()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LogWarning("Syncing bitcode archive %v failed because %v\n", destFilePath, err)
|
LogWarning("Syncing bitcode archive %v failed because %v\n", destFilePath, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -92,9 +92,9 @@ ea.ArchiverName: %v
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ParseSwitches(args []string) (ea ExtractionArgs) {
|
func ParseSwitches(args []string) (ea ExtractionArgs) {
|
||||||
|
|
||||||
var flagSet *flag.FlagSet = flag.NewFlagSet(args[0], flag.ContinueOnError)
|
var flagSet *flag.FlagSet = flag.NewFlagSet(args[0], flag.ContinueOnError)
|
||||||
|
|
||||||
flagSet.BoolVar(&ea.Verbose, "v", false, "verbose mode")
|
flagSet.BoolVar(&ea.Verbose, "v", false, "verbose mode")
|
||||||
flagSet.BoolVar(&ea.WriteManifest, "m", false, "write the manifest")
|
flagSet.BoolVar(&ea.WriteManifest, "m", false, "write the manifest")
|
||||||
flagSet.BoolVar(&ea.SortBitcodeFiles, "s", false, "sort the bitcode files")
|
flagSet.BoolVar(&ea.SortBitcodeFiles, "s", false, "sort the bitcode files")
|
||||||
@ -119,19 +119,19 @@ func ParseSwitches(args []string) (ea ExtractionArgs) {
|
|||||||
if len(inputFiles) != 1 {
|
if len(inputFiles) != 1 {
|
||||||
LogError("Can currently only deal with exactly one input file, sorry. You gave me %v input files.\n", len(inputFiles))
|
LogError("Can currently only deal with exactly one input file, sorry. You gave me %v input files.\n", len(inputFiles))
|
||||||
ea.Failure = true
|
ea.Failure = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ea.InputFile = inputFiles[0]
|
ea.InputFile = inputFiles[0]
|
||||||
if _, err := os.Stat(ea.InputFile); os.IsNotExist(err) {
|
if _, err := os.Stat(ea.InputFile); os.IsNotExist(err) {
|
||||||
LogError("The input file %s does not exist.", ea.InputFile)
|
LogError("The input file %s does not exist.", ea.InputFile)
|
||||||
ea.Failure = true
|
ea.Failure = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
realPath, err := filepath.EvalSymlinks(ea.InputFile)
|
realPath, err := filepath.EvalSymlinks(ea.InputFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LogError("There was an error getting the real path of %s.", ea.InputFile)
|
LogError("There was an error getting the real path of %s.", ea.InputFile)
|
||||||
ea.Failure = true
|
ea.Failure = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ea.InputFile = realPath
|
ea.InputFile = realPath
|
||||||
ea.InputType = getFileType(realPath)
|
ea.InputType = getFileType(realPath)
|
||||||
@ -143,9 +143,9 @@ func ParseSwitches(args []string) (ea ExtractionArgs) {
|
|||||||
|
|
||||||
//Extract extracts the LLVM bitcode according to the arguments it is passed.
|
//Extract extracts the LLVM bitcode according to the arguments it is passed.
|
||||||
func Extract(args []string) (exitCode int) {
|
func Extract(args []string) (exitCode int) {
|
||||||
|
|
||||||
exitCode = 1
|
exitCode = 1
|
||||||
|
|
||||||
ea := ParseSwitches(args)
|
ea := ParseSwitches(args)
|
||||||
|
|
||||||
if ea.Failure {
|
if ea.Failure {
|
||||||
@ -229,7 +229,6 @@ func setOutputFile(ea *ExtractionArgs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func resolveTool(defaultPath string, envPath string, usrPath string) (path string) {
|
func resolveTool(defaultPath string, envPath string, usrPath string) (path string) {
|
||||||
if usrPath != defaultPath {
|
if usrPath != defaultPath {
|
||||||
path = usrPath
|
path = usrPath
|
||||||
@ -255,7 +254,6 @@ func resolveTool(defaultPath string, envPath string, usrPath string) (path strin
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func handleExecutable(ea ExtractionArgs) (success bool) {
|
func handleExecutable(ea ExtractionArgs) (success bool) {
|
||||||
// get the list of bitcode paths
|
// get the list of bitcode paths
|
||||||
artifactPaths := ea.Extractor(ea.InputFile)
|
artifactPaths := ea.Extractor(ea.InputFile)
|
||||||
@ -339,7 +337,7 @@ func handleThinArchive(ea ExtractionArgs) (success bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !success {
|
if !success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write manifest
|
// Write manifest
|
||||||
@ -361,7 +359,7 @@ func listArchiveFiles(ea ExtractionArgs, inputFile string) (contents []string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
LogWarning("ar command: %v %v", ea.ArchiverName, arArgs)
|
LogWarning("ar command: %v %v", ea.ArchiverName, arArgs)
|
||||||
LogError("Failed to extract contents from archive %s because: %v.\n", inputFile, err)
|
LogError("Failed to extract contents from archive %s because: %v.\n", inputFile, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
contents = strings.Split(output, "\n")
|
contents = strings.Split(output, "\n")
|
||||||
return
|
return
|
||||||
@ -497,7 +495,7 @@ func handleArchive(ea ExtractionArgs) (success bool) {
|
|||||||
|
|
||||||
if !success {
|
if !success {
|
||||||
//hopefully the failure has alreadu been reported...
|
//hopefully the failure has alreadu been reported...
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write manifest
|
// Write manifest
|
||||||
|
@ -2,8 +2,8 @@ package test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"github.com/SRI-CSL/gllvm/shared"
|
"github.com/SRI-CSL/gllvm/shared"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,23 +13,23 @@ const (
|
|||||||
|
|
||||||
func checkExecutables(t *testing.T, ea shared.ExtractionArgs,
|
func checkExecutables(t *testing.T, ea shared.ExtractionArgs,
|
||||||
llvmLinker string, llvmArchiver string, archiver string,
|
llvmLinker string, llvmArchiver string, archiver string,
|
||||||
clang string, clangpp string){
|
clang string, clangpp string) {
|
||||||
if ea.LlvmLinkerName != llvmLinker {
|
if ea.LlvmLinkerName != llvmLinker {
|
||||||
t.Errorf("ParseSwitches: LlvmLinkerName incorrect: %v\n", ea.LlvmLinkerName)
|
t.Errorf("ParseSwitches: LlvmLinkerName incorrect: %v\n", ea.LlvmLinkerName)
|
||||||
}
|
}
|
||||||
if ea.LlvmArchiverName != llvmArchiver {
|
if ea.LlvmArchiverName != llvmArchiver {
|
||||||
t.Errorf("ParseSwitches: LlvmArchiverName incorrect: %v\n", ea.LlvmArchiverName)
|
t.Errorf("ParseSwitches: LlvmArchiverName incorrect: %v\n", ea.LlvmArchiverName)
|
||||||
}
|
}
|
||||||
if ea.ArchiverName != archiver {
|
if ea.ArchiverName != archiver {
|
||||||
t.Errorf("ParseSwitches: ArchiverName incorrect: %v\n", ea.ArchiverName)
|
t.Errorf("ParseSwitches: ArchiverName incorrect: %v\n", ea.ArchiverName)
|
||||||
}
|
}
|
||||||
|
|
||||||
eclang := shared.GetCompilerExecName("clang")
|
eclang := shared.GetCompilerExecName("clang")
|
||||||
if eclang != clang {
|
if eclang != clang {
|
||||||
t.Errorf("C compiler not correct: %v\n", eclang)
|
t.Errorf("C compiler not correct: %v\n", eclang)
|
||||||
}
|
}
|
||||||
eclangpp := shared.GetCompilerExecName("clang++")
|
eclangpp := shared.GetCompilerExecName("clang++")
|
||||||
if eclangpp != clangpp {
|
if eclangpp != clangpp {
|
||||||
t.Errorf("C++ compiler not correct: %v\n", eclangpp)
|
t.Errorf("C++ compiler not correct: %v\n", eclangpp)
|
||||||
}
|
}
|
||||||
if verbose {
|
if verbose {
|
||||||
@ -45,14 +45,14 @@ func Test_env_and_args(t *testing.T) {
|
|||||||
if !ea.Verbose {
|
if !ea.Verbose {
|
||||||
t.Errorf("ParseSwitches: -v flag not working\n")
|
t.Errorf("ParseSwitches: -v flag not working\n")
|
||||||
}
|
}
|
||||||
if ea.WriteManifest || ea.SortBitcodeFiles || ea.BuildBitcodeModule || ea.KeepTemp {
|
if ea.WriteManifest || ea.SortBitcodeFiles || ea.BuildBitcodeModule || ea.KeepTemp {
|
||||||
t.Errorf("ParseSwitches: defaults not correct\n")
|
t.Errorf("ParseSwitches: defaults not correct\n")
|
||||||
}
|
}
|
||||||
if ea.InputFile != "../data/hello" {
|
if ea.InputFile != "../data/hello" {
|
||||||
t.Errorf("ParseSwitches: InputFile incorrect: %v\n", ea.InputFile)
|
t.Errorf("ParseSwitches: InputFile incorrect: %v\n", ea.InputFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
checkExecutables(t, ea, "llvm-link", "llvm-ar", "ar", "clang", "clang++")
|
checkExecutables(t, ea, "llvm-link", "llvm-ar", "ar", "clang", "clang++")
|
||||||
|
|
||||||
os.Setenv("LLVM_COMPILER_PATH", "/the_future_is_here")
|
os.Setenv("LLVM_COMPILER_PATH", "/the_future_is_here")
|
||||||
os.Setenv("LLVM_CC_NAME", "clang-666")
|
os.Setenv("LLVM_CC_NAME", "clang-666")
|
||||||
@ -61,27 +61,25 @@ func Test_env_and_args(t *testing.T) {
|
|||||||
os.Setenv("LLVM_AR_NAME", "llvm-ar-666")
|
os.Setenv("LLVM_AR_NAME", "llvm-ar-666")
|
||||||
|
|
||||||
shared.FetchEnvironment()
|
shared.FetchEnvironment()
|
||||||
|
|
||||||
ea = shared.ParseSwitches(args)
|
ea = shared.ParseSwitches(args)
|
||||||
|
|
||||||
checkExecutables(t, ea,
|
checkExecutables(t, ea,
|
||||||
"/the_future_is_here/llvm-link-666",
|
"/the_future_is_here/llvm-link-666",
|
||||||
"/the_future_is_here/llvm-ar-666",
|
"/the_future_is_here/llvm-ar-666",
|
||||||
"ar",
|
"ar",
|
||||||
"/the_future_is_here/clang-666",
|
"/the_future_is_here/clang-666",
|
||||||
"/the_future_is_here/clang++-666")
|
"/the_future_is_here/clang++-666")
|
||||||
|
|
||||||
args = []string{"get-bc", "-a", "llvm-ar-665", "-l", "llvm-link-665", "../data/hello"}
|
args = []string{"get-bc", "-a", "llvm-ar-665", "-l", "llvm-link-665", "../data/hello"}
|
||||||
|
|
||||||
ea = shared.ParseSwitches(args)
|
ea = shared.ParseSwitches(args)
|
||||||
|
|
||||||
checkExecutables(t, ea,
|
checkExecutables(t, ea,
|
||||||
"llvm-link-665",
|
"llvm-link-665",
|
||||||
"llvm-ar-665",
|
"llvm-ar-665",
|
||||||
"ar",
|
"ar",
|
||||||
"/the_future_is_here/clang-666",
|
"/the_future_is_here/clang-666",
|
||||||
"/the_future_is_here/clang++-666")
|
"/the_future_is_here/clang++-666")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user