Documenting the exported routines.

This commit is contained in:
Ian A. Mason 2017-07-05 17:42:55 -07:00
parent 0cf14152fe
commit 562983793a
3 changed files with 15 additions and 8 deletions

View File

@ -16,14 +16,15 @@ type bitcodeToObjectLink struct {
objPath string
}
func Compile(args []string, compilerName string) (exitCode int) {
//Compile wraps a call to the compiler with the given args.
func Compile(args []string, compiler string) (exitCode int) {
exitCode = 0
//in the configureOnly case we have to know the exit code of the compile
//because that is how configure figures out what it can and cannot do.
var ok bool = true
var ok = true
var compilerExecName = getCompilerExecName(compilerName)
var compilerExecName = getCompilerExecName(compiler)
var configureOnly bool
if ConfigureOnly != "" {
configureOnly = true
@ -199,20 +200,20 @@ func execCompile(compilerExecName string, pr parserResult, wg *sync.WaitGroup, o
}
}
func getCompilerExecName(compilerName string) string {
switch compilerName {
func getCompilerExecName(compiler string) string {
switch compiler {
case "clang":
if LLVMCCName != "" {
return filepath.Join(LLVMToolChainBinDir, LLVMCCName)
}
return filepath.Join(LLVMToolChainBinDir, compilerName)
return filepath.Join(LLVMToolChainBinDir, compiler)
case "clang++":
if LLVMCXXName != "" {
return filepath.Join(LLVMToolChainBinDir, LLVMCXXName)
}
return filepath.Join(LLVMToolChainBinDir, compilerName)
return filepath.Join(LLVMToolChainBinDir, compiler)
default:
LogFatal("The compiler %s is not supported by this tool.", compilerName)
LogFatal("The compiler %s is not supported by this tool.", compiler)
return ""
}
}

View File

@ -26,6 +26,7 @@ type extractionArgs struct {
BuildBitcodeArchive bool
}
//Extract extracts the LLVM bitcode according to the argumets it is passed.
func Extract(args []string) {
ea := parseSwitches()

View File

@ -49,11 +49,16 @@ func makeLogger(lvl int) func(format string, a ...interface{}) {
}
}
//LogDebug logs to the configured stream if the logging level is DEBUG.
var LogDebug = makeLogger(debugV)
//LogInfo logs to the configured stream if the logging level is INFO or lower.
var LogInfo = makeLogger(infoV)
//LogWarning logs to the configured stream if the logging level is WARNING or lower.
var LogWarning = makeLogger(warningV)
//LogError logs to the configured stream if the logging level is ERROR or lower.
var LogError = makeLogger(errorV)
//LogFatal logs to the configured stream and then exits.
func LogFatal(format string, a ...interface{}) {
LogError(format, a...)
os.Exit(1)