aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Yakimowich-Payne <jyapayne@gmail.com>2018-07-09 09:16:44 +0900
committerJoey Yakimowich-Payne <jyapayne@gmail.com>2018-07-09 09:16:44 +0900
commit17e54d3b8786422c8643cbe2f405f30ef324ed38 (patch)
treed2fb16d0745ddc6a6d3be7c643fd65d3fc8807f9
parent76020e8f219bda1af3f7e1bc7974ffb1d6b2a6df (diff)
downloadnimgen-17e54d3b8786422c8643cbe2f405f30ef324ed38.tar.gz
nimgen-17e54d3b8786422c8643cbe2f405f30ef324ed38.zip
Make c/cpp compiler priority .cfg > CC/CXX > gcc/g++
-rw-r--r--nimgen.nim17
1 files changed, 15 insertions, 2 deletions
diff --git a/nimgen.nim b/nimgen.nim
index e1e16b7..4f2c251 100644
--- a/nimgen.nim
+++ b/nimgen.nim
@@ -1,5 +1,11 @@
import nre, os, ospaths, osproc, parsecfg, pegs, ropes, sequtils, streams, strutils, tables
+const
+ C_COMPILER_ENV = "CC"
+ CPP_COMPILER_ENV = "CPP"
+ DEFAULT_C_COMPILER = "gcc"
+ DEFAULT_CPP_COMPILER = "g++"
+
var
gDoneRecursive: seq[string] = @[]
gDoneInline: seq[string] = @[]
@@ -8,8 +14,8 @@ var
gConfig: Config
gFilter = ""
gQuotes = true
- gCppCompiler = "g++"
- gCCompiler = "gcc"
+ gCppCompiler = getEnv(CPP_COMPILER_ENV, DEFAULT_C_COMPILER)
+ gCCompiler = getEnv(C_COMPILER_ENV, DEFAULT_CPP_COMPILER)
gOutput = ""
gIncludes: seq[string] = @[]
gExcludes: seq[string] = @[]
@@ -719,8 +725,15 @@ proc runCfg(cfg: string) =
if gConfig["n.global"].hasKey("cpp_compiler"):
gCppCompiler = gConfig["n.global"]["cpp_compiler"]
+ else:
+ # Reset on a per project basis
+ gCppCompiler = getEnv(CPP_COMPILER_ENV, DEFAULT_CPP_COMPILER)
+
if gConfig["n.global"].hasKey("c_compiler"):
gCCompiler = gConfig["n.global"]["c_compiler"]
+ else:
+ # Reset on a per project basis
+ gCCompiler = getEnv(C_COMPILER_ENV, DEFAULT_C_COMPILER)
if gConfig["n.global"].hasKey("filter"):
gFilter = gConfig["n.global"]["filter"]