mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-07 12:24:19 +00:00
compilesettings: add libpath (#16997)
* compilesettings: add libpath * add test * changelog * fixup Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
This commit is contained in:
@@ -142,6 +142,7 @@ provided by the operating system.
|
||||
|
||||
- Added experimental `linenoise.readLineStatus` to get line and status (e.g. ctrl-D or ctrl-C).
|
||||
|
||||
- Added `compilesettings.SingleValueSetting.libPath`
|
||||
- `std/wrapnils` doesn't use `experimental:dotOperators` anymore, avoiding
|
||||
issues like https://github.com/nim-lang/Nim/issues/13063 (which affected error messages)
|
||||
for modules importing `std/wrapnils`.
|
||||
|
||||
@@ -12,7 +12,7 @@ import
|
||||
ast, astalgo, modules, passes, condsyms,
|
||||
options, sem, llstream, lineinfos, vm,
|
||||
vmdef, modulegraphs, idents, os, pathutils,
|
||||
passaux, scriptconfig
|
||||
passaux, scriptconfig, std/compilesettings
|
||||
|
||||
type
|
||||
Interpreter* = ref object ## Use Nim as an interpreter with this object
|
||||
@@ -92,10 +92,9 @@ proc findNimStdLib*(): string =
|
||||
return ""
|
||||
|
||||
proc findNimStdLibCompileTime*(): string =
|
||||
## Same as ``findNimStdLib`` but uses source files used at compile time,
|
||||
## Same as `findNimStdLib` but uses source files used at compile time,
|
||||
## and asserts on error.
|
||||
const exe = getCurrentCompilerExe()
|
||||
result = exe.splitFile.dir.parentDir / "lib"
|
||||
result = querySetting(libPath)
|
||||
doAssert fileExists(result / "system.nim"), "result:" & result
|
||||
|
||||
proc createInterpreter*(scriptName: string;
|
||||
|
||||
@@ -131,6 +131,7 @@ when defined(nimHasInvariant):
|
||||
of compileOptions: result = conf.compileOptions
|
||||
of ccompilerPath: result = conf.cCompilerPath
|
||||
of backend: result = $conf.backend
|
||||
of libPath: result = conf.libpath.string
|
||||
|
||||
proc querySettingSeqImpl(conf: ConfigRef, switch: BiggestInt): seq[string] =
|
||||
template copySeq(field: untyped): untyped =
|
||||
|
||||
@@ -31,6 +31,7 @@ type
|
||||
ccompilerPath ## the path to the C/C++ compiler
|
||||
backend ## the backend (eg: c|cpp|objc|js); both `nim doc --backend:js`
|
||||
## and `nim js` would imply backend=js
|
||||
libPath ## the absolute path to the stdlib library, i.e. nim's `--lib`, since 1.5.1
|
||||
|
||||
MultipleValueSetting* {.pure.} = enum ## \
|
||||
## settings resulting in a seq of string values
|
||||
|
||||
@@ -18,10 +18,12 @@ const
|
||||
|
||||
template tpath(): untyped = getAppDir() / "tests"
|
||||
|
||||
import std/compilesettings
|
||||
|
||||
proc parseTest(filename: string; epcMode=false): Test =
|
||||
const cursorMarker = "#[!]#"
|
||||
let nimsug = curDir & addFileExt("nimsuggest", ExeExt)
|
||||
let libpath = findExe("nim").splitFile().dir /../ "lib"
|
||||
const libpath = querySetting(libPath)
|
||||
result.filename = filename
|
||||
result.dest = getTempDir() / extractFilename(filename)
|
||||
result.cmd = nimsug & " --tester " & result.dest
|
||||
@@ -329,7 +331,7 @@ proc main() =
|
||||
failures += runTest(xx)
|
||||
failures += runEpcTest(xx)
|
||||
else:
|
||||
for x in walkFiles(getAppDir() / "tests/t*.nim"):
|
||||
for x in walkFiles(tpath() / "t*.nim"):
|
||||
echo "Test ", x
|
||||
let xx = expandFilename x
|
||||
when not defined(windows):
|
||||
|
||||
@@ -3,18 +3,15 @@ cmd: "nim c --nimcache:build/myNimCache --nimblePath:myNimblePath $file"
|
||||
joinable: false
|
||||
"""
|
||||
|
||||
import strutils
|
||||
import std/[strutils,compilesettings]
|
||||
from std/os import fileExists, `/`
|
||||
|
||||
import std / compilesettings
|
||||
template main =
|
||||
doAssert querySetting(nimcacheDir) == nimcacheDir.querySetting
|
||||
doAssert "myNimCache" in nimcacheDir.querySetting
|
||||
doAssert "myNimblePath" in nimblePaths.querySettingSeq[0]
|
||||
doAssert querySetting(backend) == "c"
|
||||
doAssert fileExists(libPath.querySetting / "system.nim")
|
||||
|
||||
const
|
||||
nc = querySetting(nimcacheDir)
|
||||
np = querySettingSeq(nimblePaths)
|
||||
|
||||
static:
|
||||
echo nc
|
||||
echo np
|
||||
|
||||
doAssert "myNimCache" in nc
|
||||
doAssert "myNimblePath" in np[0]
|
||||
doAssert querySetting(backend) == "c"
|
||||
static: main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user