csource building prefers bin/nim (#21115)

This commit is contained in:
ringabout
2022-12-16 14:59:18 +08:00
committed by GitHub
parent 644318ad9c
commit 8a3b76b287

View File

@@ -515,6 +515,17 @@ template gatherFiles(fun, libpath, outDir) =
# commenting out for now, see discussion in https://github.com/nim-lang/Nim/pull/13413
# copySrc(libpath / "lib/wrappers/linenoise/linenoise.h")
proc exe(f: string): string =
result = addFileExt(f, ExeExt)
when defined(windows):
result = result.replace('/','\\')
proc findNim(): string =
let nim = "nim".exe
result = quoteShell("bin" / nim)
if not fileExists(result):
result = "nim"
proc srcdist(c: var ConfigData) =
let cCodeDir = getOutputDir(c) / "c_code"
if not dirExists(cCodeDir): createDir(cCodeDir)
@@ -533,10 +544,10 @@ proc srcdist(c: var ConfigData) =
var dir = getOutputDir(c) / buildDir(osA, cpuA)
if dirExists(dir): removeDir(dir)
createDir(dir)
var cmd = ("nim compile -f --symbolfiles:off --compileonly " &
var cmd = ("$# compile -f --symbolfiles:off --compileonly " &
"--gen_mapping --cc:gcc --skipUserCfg" &
" --os:$# --cpu:$# $# $#") %
[osname, cpuname, c.nimArgs, c.mainfile]
[findNim(), osname, cpuname, c.nimArgs, c.mainfile]
echo(cmd)
if execShellCmd(cmd) != 0:
quit("Error: call to nim compiler failed")