Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bundle nif #24262

Open
wants to merge 7 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compiler/nim.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

hint[XDeclaredButNotUsed]:off

# allow dependencies to import the compiler via `import compiler / ...`:
path:".."
# nif uses `--path:$nim` by default, make it use the current compiler instead:
define:nifCompilerInPath

define:booting
define:nimcore
define:nimPreviewSlimSystem
Expand Down
4 changes: 4 additions & 0 deletions compiler/nim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import
commands, options, msgs, extccomp, main, idents, lineinfos, cmdlinehelper,
pathutils, modulegraphs

when defined(testNifImports):
# temporary until nif is actually used in the compiler
import ../dist/nif/src/[nifler/nifler, xelim/xelim, nifgram/nifgram, gear2/gear2]

from std/browsers import openDefaultBrowser
from nodejs import findNodeJs

Expand Down
15 changes: 14 additions & 1 deletion koch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const
AtlasStableCommit = "5faec3e9a33afe99a7d22377dd1b45a5391f5504"
ChecksumsStableCommit = "bd9bf4eaea124bf8d01e08f92ac1b14c6879d8d3"
SatStableCommit = "faf1617f44d7632ee9601ebc13887644925dcc01"
NifStableCommit = "5a1570de3d9c0f246ba903c6780e5c0ecb6ddbfc"

# examples of possible values for fusion: #head, #ea82b54, 1.2.3
FusionStableHash = "#372ee4313827ef9f2ea388840f7d6b46c2b1b014"
Expand Down Expand Up @@ -78,6 +79,7 @@ Possible Commands:
nimble builds the Nimble tool
atlas builds the Atlas tool
checksums installs the checksums dependency
nif installs the nif dependency
fusion installs fusion via Nimble

Boot options:
Expand Down Expand Up @@ -210,7 +212,12 @@ proc bundleChecksums(latest: bool) =
let commit = if latest: "HEAD" else: ChecksumsStableCommit
cloneDependency(distDir, "https://github.com/nim-lang/checksums.git", commit, allowBundled = true)

proc bundleNif(latest: bool) =
let commit = if latest: "HEAD" else: NifStableCommit
cloneDependency(distDir, "https://github.com/nim-lang/nif.git", commit, allowBundled = true)

proc zip(latest: bool; args: string) =
bundleNif(latest)
bundleChecksums(latest)
bundleNimbleExe(latest, args)
bundleAtlasExe(latest, args)
Expand Down Expand Up @@ -265,6 +272,7 @@ proc testTools(args: string = "") =
nimCompileFold("Compile testament", "testament/testament.nim", options = "-d:release " & args)

proc nsis(latest: bool; args: string) =
bundleNif(latest)
bundleChecksums(latest)
bundleNimbleExe(latest, args)
bundleAtlasExe(latest, args)
Expand Down Expand Up @@ -345,6 +353,7 @@ proc boot(args: string, skipIntegrityCheck: bool) =
let smartNimcache = (if "release" in args or "danger" in args: "nimcache/r_" else: "nimcache/d_") &
hostOS & "_" & hostCPU

bundleNif(false)
bundleChecksums(false)

let usingLibFFI = "nimHasLibFFI" in args
Expand Down Expand Up @@ -508,6 +517,7 @@ proc temp(args: string) =
result[1].add " " & quoteShell(args[i])
inc i

bundleNif(false)
bundleChecksums(false)

let d = getAppDir()
Expand Down Expand Up @@ -586,7 +596,8 @@ proc runCI(cmd: string) =
# boot without -d:nimHasLibFFI to make sure this still works
# `--lib:lib` is needed for bootstrap on openbsd, for reasons described in
# https://github.com/nim-lang/Nim/pull/14291 (`getAppFilename` bugsfor older nim on openbsd).
kochExecFold("Boot Nim ORC", "boot -d:release -d:nimStrictMode --lib:lib")
kochExecFold("Boot Nim ORC", "boot -d:release -d:nimStrictMode --lib:lib -d:testNifImports")
# remove -d:testNifImports when nif is actually used

when false: # debugging: when you need to run only 1 test in CI, use something like this:
execFold("debugging test", "nim r tests/stdlib/tosproc.nim")
Expand Down Expand Up @@ -764,6 +775,8 @@ when isMainModule:
bundleAtlasExe(latest, op.cmdLineRest)
of "checksums":
bundleChecksums(latest)
of "nif":
bundleNif(latest)
of "pushcsource":
quit "use this instead: https://github.com/nim-lang/csources_v1/blob/master/push_c_code.nim"
of "valgrind": valgrind(op.cmdLineRest)
Expand Down
4 changes: 4 additions & 0 deletions lib/system.nim
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ when defined(nimHasEnsureMove):
doAssert y == "Hello"
foo()
discard "implemented in injectdestructors"
else:
template ensureMove*[T](x: T): T =
# no-op for bootstrapping
x

type
range*[T]{.magic: "Range".} ## Generic type to construct range types.
Expand Down