mirror of
https://github.com/danog/gllvm.git
synced 2024-11-30 09:48:59 +01:00
Moved dealing with the enviroment into one place (apart from logging)
This commit is contained in:
parent
1d79248ebb
commit
d153584bba
@ -20,7 +20,7 @@ type bitcodeToObjectLink struct {
|
||||
func compile(args []string, compilerName string) {
|
||||
var compilerExecName = getCompilerExecName(compilerName)
|
||||
var configureOnly bool
|
||||
if os.Getenv(envCONFIGUREONLY) != "" {
|
||||
if ConfigureOnly != "" {
|
||||
configureOnly = true
|
||||
}
|
||||
var pr = parse(args)
|
||||
@ -123,7 +123,7 @@ func attachBitcodePathToObject(bcFile, objFile string) {
|
||||
_, err = execCmd(attachCmd, attachCmdArgs, "")
|
||||
|
||||
// Copy bitcode file to store, if necessary
|
||||
if bcStorePath := os.Getenv(envBCSTOREPATH); bcStorePath != "" {
|
||||
if bcStorePath := os.Getenv(BitcodeStorePath); bcStorePath != "" {
|
||||
destFilePath := path.Join(bcStorePath, getHashedPath(absBcPath))
|
||||
in, _ := os.Open(absBcPath)
|
||||
defer in.Close()
|
||||
|
12
constants.go
12
constants.go
@ -5,11 +5,6 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// Environment variables
|
||||
envCONFIGUREONLY = "GLLVM_CONFIGURE_ONLY"
|
||||
envBCSTOREPATH = "GLLVM_BC_STORE"
|
||||
|
||||
// Gllvm functioning (once we have it working we can change the W to G; but for the time being leave it so that extract-bc works)
|
||||
elfSECTIONNAME = ".llvm_bc"
|
||||
darwinSEGMENTNAME = "__WLLVM"
|
||||
darwinSECTIONNAME = "__llvm_bc"
|
||||
@ -21,12 +16,19 @@ var LLVMCXXName = ""
|
||||
var LLVMARName = ""
|
||||
var LLVMLINKName = ""
|
||||
|
||||
var ConfigureOnly = ""
|
||||
var BitcodeStorePath = ""
|
||||
|
||||
func init(){
|
||||
|
||||
LLVMToolChainBinDir = os.Getenv("GLLVM_TOOLS_PATH")
|
||||
LLVMCCName = os.Getenv("GLLVM_CC_NAME")
|
||||
LLVMCXXName = os.Getenv("GLLVM_CXX_NAME")
|
||||
LLVMARName = os.Getenv("GLLVM_AR_NAME")
|
||||
LLVMLINKName = os.Getenv("GLLVM_LINK_NAME")
|
||||
|
||||
ConfigureOnly = os.Getenv("GLLVM_CONFIGURE_ONLY")
|
||||
BitcodeStorePath = os.Getenv("GLLVM_BC_STORE")
|
||||
}
|
||||
|
||||
|
||||
|
@ -286,7 +286,7 @@ func extractSectionUnix(inputFile string) (contents []string) {
|
||||
func resolveBitcodePath(bcPath string) string {
|
||||
if _, err := os.Stat(bcPath); os.IsNotExist(err) {
|
||||
// If the bitcode file does not exist, try to find it in the store
|
||||
if bcStorePath := os.Getenv(envBCSTOREPATH); bcStorePath != "" {
|
||||
if bcStorePath := os.Getenv(BitcodeStorePath); bcStorePath != "" {
|
||||
// Compute absolute path hash
|
||||
absBcPath, _ := filepath.Abs(bcPath)
|
||||
storeBcPath := path.Join(bcStorePath, getHashedPath(absBcPath))
|
||||
|
@ -13,11 +13,6 @@ const (
|
||||
debugV
|
||||
)
|
||||
|
||||
const (
|
||||
loggingLevelEnvVar = "GLLVM_OUTPUT_LEVEL"
|
||||
loggingFileEnvVar = "GLLVM_OUTPUT_FILE"
|
||||
)
|
||||
|
||||
var loggingLevels = map[string]int{
|
||||
"ERROR": errorV,
|
||||
"WARNING": warningV,
|
||||
@ -30,12 +25,12 @@ var level = 0
|
||||
var filePointer = os.Stderr
|
||||
|
||||
func init() {
|
||||
if envLevelStr := os.Getenv(loggingLevelEnvVar); envLevelStr != "" {
|
||||
if envLevelStr := os.Getenv("GLLVM_OUTPUT_LEVEL"); envLevelStr != "" {
|
||||
if envLevelVal, ok := loggingLevels[envLevelStr]; ok {
|
||||
level = envLevelVal
|
||||
}
|
||||
}
|
||||
if envFileStr := os.Getenv(loggingFileEnvVar); envFileStr != "" {
|
||||
if envFileStr := os.Getenv("GLLVM_OUTPUT_FILE"); envFileStr != "" {
|
||||
if loggingFP, err := os.OpenFile(envFileStr, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600); err == nil {
|
||||
filePointer = loggingFP
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user