Skip to content

Commit

Permalink
Add --use-system-nim setting
Browse files Browse the repository at this point in the history
  • Loading branch information
yyoncho committed Jan 30, 2023
1 parent 861747a commit 0ad1a70
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/nimble.nim
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ proc allDependencies(pkgInfo: PackageInfo, options: Options): HashSet[PackageInf
result.incl pkgInfo.processFreeDependencies(requires, options)

proc useLockedNimIfNeeded(pkgInfo: PackageInfo, options: var Options) =
if pkgInfo.lockedDeps.len > 0:
if pkgInfo.lockedDeps.len > 0 and not options.useSystemNim:
var deps = pkgInfo.processLockedDependencies(options, true)
if deps.len != 0:
# process the first entry (hash.pop is triggering warnings)
Expand Down
6 changes: 5 additions & 1 deletion src/nimblepkg/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type
pkgInfoCache*: TableRef[string, PackageInfo]
showHelp*: bool
lockFileName*: string
useSystemNim*: bool
showVersion*: bool
offline*: bool
noColor*: bool
Expand Down Expand Up @@ -112,7 +113,7 @@ Usage: nimble [nimbleopts] COMMAND [cmdopts]
Commands:
install [pkgname, ...] Installs a list of packages.
[-d, --depsOnly] Only install dependencies. Leave out pkgname
to install deps for a local nimble package.
to install deps for a local nimble package.
[-p, --passNim] Forward specified flag to compiler.
[--noRebuild] Don't rebuild binaries if they're up-to-date.
develop [pkgname, ...] Clones a list of packages for development.
Expand Down Expand Up @@ -228,6 +229,8 @@ Nimble Options:
--noColor Don't colorise output.
--noSSLCheck Don't check SSL certificates.
--lock-file Override the lock file name.
--use-system-nim Use system nim and ignore nim from the lock
file if any
For more information read the Github readme:
https://github.com/nim-lang/nimble#readme
Expand Down Expand Up @@ -532,6 +535,7 @@ proc parseFlag*(flag, val: string, result: var Options, kind = cmdLongOption) =
of "tarballs", "t": result.enableTarballs = true
of "package", "p": result.package = val
of "lock-file": result.lockFileName = val
of "use-system-nim": result.useSystemNim = true
else: isGlobalFlag = false

var wasFlagHandled = true
Expand Down
2 changes: 1 addition & 1 deletion tests/nimdep/nimdep.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bin = @["demo"]

# Dependencies

requires "nim == 1.7.1"
requires "nim"

task version, "Test nim version":
exec "nim --version"
4 changes: 4 additions & 0 deletions tests/tlockfile.nim
Original file line number Diff line number Diff line change
Expand Up @@ -618,3 +618,7 @@ requires "nim >= 1.5.1"
# check the nim version
let (outputVersion, _) = execNimble("version")
check outputVersion.contains(getRevision("nim"))

let (outputGlobalNim, exitCodeGlobalNim) = execNimbleYes("-y", "--use-system-nim", "build")
check exitCodeGlobalNim == QuitSuccess
check not outputGlobalNim.contains("bin/nim for compilation")

0 comments on commit 0ad1a70

Please sign in to comment.