aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGanesh Viswanathan <dev@genotrance.com>2019-10-16 22:56:50 -0500
committerGanesh Viswanathan <dev@genotrance.com>2019-10-16 22:56:50 -0500
commitf7bc37f2b3345f5e04a4a7ba733751bf5ce41c6e (patch)
tree46d12e9f130cf1f15156683fbf294554abeea250
parent8dc327d02b851a6447e971823cb440f973c5a146 (diff)
downloadnimterop-issue141.tar.gz
nimterop-issue141.zip
Fix #141issue141
-rw-r--r--nimterop/build.nim16
-rw-r--r--nimterop/getters.nim2
2 files changed, 15 insertions, 3 deletions
diff --git a/nimterop/build.nim b/nimterop/build.nim
index 72f80b9..f96593e 100644
--- a/nimterop/build.nim
+++ b/nimterop/build.nim
@@ -570,13 +570,25 @@ proc make*(path, check: string, flags = "", regex = false) =
doAssert findFile(check, path, regex = regex).len != 0, "# make failed"
+proc getCompiler*(): string =
+ var
+ compiler =
+ when defined(gcc):
+ "gcc"
+ elif defined(clang):
+ "clang"
+ else:
+ doAssert false, "Nimterop only supports gcc and clang at this time"
+
+ result = getEnv("CC", compiler)
+
proc getGccPaths*(mode = "c"): seq[string] =
var
nul = when defined(Windows): "nul" else: "/dev/null"
mmode = if mode == "cpp": "c++" else: mode
inc = false
- (outp, _) = gorgeEx(&"""{getEnv("CC", "gcc")} -Wp,-v -x{mmode} {nul}""")
+ (outp, _) = gorgeEx(&"""{getCompiler()} -Wp,-v -x{mmode} {nul}""")
for line in outp.splitLines():
if "#include <...> search starts here" in line:
@@ -599,7 +611,7 @@ proc getGccLibPaths*(mode = "c"): seq[string] =
mmode = if mode == "cpp": "c++" else: mode
linker = when defined(OSX): "-Xlinker" else: ""
- (outp, _) = gorgeEx(&"""{getEnv("CC", "gcc")} {linker} -v -x{mmode} {nul}""")
+ (outp, _) = gorgeEx(&"""{getCompiler()} {linker} -v -x{mmode} {nul}""")
for line in outp.splitLines():
if "LIBRARY_PATH=" in line:
diff --git a/nimterop/getters.nim b/nimterop/getters.nim
index 660f69f..a88895d 100644
--- a/nimterop/getters.nim
+++ b/nimterop/getters.nim
@@ -204,7 +204,7 @@ proc removeStatic(content: string): string =
proc getPreprocessor*(gState: State, fullpath: string, mode = "cpp"): string =
var
mmode = if mode == "cpp": "c++" else: mode
- cmd = &"""{getEnv("CC", "gcc")} -E -CC -dD -x{mmode} -w """
+ cmd = &"""{getCompiler()} -E -CC -dD -x{mmode} -w """
rdata: seq[string] = @[]
start = false