Skip to content

Commit

Permalink
lang/nim: Upgrade to 2.0.0
Browse files Browse the repository at this point in the history
ChangeLog: https://nim-lang.org/blog/2023/08/01/nim-v20-released.html

PR:		273423
Reported by:	ports@nicandneal.net (maintainer)
  • Loading branch information
Neal Nelson authored and fernape committed Aug 31, 2023
1 parent 22ffecd commit 3a22c2f
Show file tree
Hide file tree
Showing 10 changed files with 1,128 additions and 1,019 deletions.
46 changes: 21 additions & 25 deletions lang/nim/Makefile
@@ -1,5 +1,5 @@
PORTNAME= nim
DISTVERSION= 1.6.14
DISTVERSION= 2.0.0
CATEGORIES= lang
MASTER_SITES= https://nim-lang.org/download/

Expand Down Expand Up @@ -38,19 +38,14 @@ EXTRA_PATCHES= ${PATCHDIR}/elfv1-patch-build.sh
EXTRA_PATCHES= ${PATCHDIR}/clang-patch-build.sh
.endif

NIMDIR= ${STAGEDIR}${PREFIX}/nim

post-patch:
.if defined(PPC_ABI) && ${PPC_ABI} == ELFv1
@${REINPLACE_CMD} -e '/cc =/s/clang/gcc/' ${WRKSRC}/config/nim.cfg
@${REINPLACE_CMD} -e s/%%GCC_DEFAULT%%/${GCC_DEFAULT}/ \
${WRKSRC}/build.sh ${WRKSRC}/config/nim.cfg
.endif
# Make a fake nimdoc.css so that we can change the expected target
# to where it should be, instead of where the nim project hard
# code it to be.
${MKDIR} ${WRKSRC}/share/doc/nim
${LN} -s ${WRKSRC}/doc/nimdoc.css ${WRKSRC}/share/doc/nim/nimdoc.css
${MKDIR} ${WRKSRC}/share/nim
${LN} -s ${WRKSRC}/tools/dochack ${WRKSRC}/share/nim/dochack

do-build:
cd ${WRKSRC} && ${SETENV} CC="${CC}" LINKER="${CC}" \
Expand All @@ -73,35 +68,36 @@ do-build-TOOLS-on:
-d:release --nimcache=${WRKSRC}/nimcache

do-install:
${MKDIR} ${NIMDIR}
${MKDIR} ${NIMDIR}/bin
# Install nim compiler
${INSTALL_PROGRAM} ${WRKSRC}/bin/nim ${STAGEDIR}${PREFIX}/bin
${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/nim
${INSTALL_PROGRAM} ${WRKSRC}/bin/nim ${NIMDIR}/bin
${STRIP_CMD} ${NIMDIR}/bin/nim
# Install lib nim rtl
${INSTALL_LIB} ${WRKSRC}/lib/libnimrtl.so ${STAGEDIR}${PREFIX}/lib
${MKDIR} ${NIMDIR}/lib
${INSTALL_LIB} ${WRKSRC}/lib/libnimrtl.so ${NIMDIR}/lib
# Install nim lib files
${MKDIR} ${STAGEDIR}${PREFIX}/lib/${PORTNAME}
(cd ${WRKSRC}/lib && ${COPYTREE_SHARE} . ${STAGEDIR}${PREFIX}/lib/${PORTNAME} "! -name libnimrtl.so")
${REINPLACE_CMD} 's|\.\.\/doc|/usr/local/share/doc/nim|g' ${WRKSRC}/compiler/commands.nim
${MKDIR} ${STAGEDIR}${PREFIX}/lib/${PORTNAME}/compiler
(cd ${WRKSRC}/compiler && ${COPYTREE_SHARE} . ${STAGEDIR}${PREFIX}/lib/${PORTNAME}/compiler "! -name nim ! -name nim1")
(cd ${WRKSRC}/lib && ${COPYTREE_SHARE} . ${NIMDIR}/lib "! -name libnimrtl.so")
${MKDIR} ${NIMDIR}/lib/compiler
(cd ${WRKSRC}/compiler && ${COPYTREE_SHARE} . ${NIMDIR}/lib/compiler "! -name nim ! -name nim1")
# Configuration files
${MKDIR} ${STAGEDIR}${ETCDIR}
${MKDIR} ${NIMDIR}/config
.for file in nim.cfg nimdoc.cfg nimdoc.tex.cfg
${INSTALL_DATA} ${WRKSRC}/config/${file} ${STAGEDIR}${ETCDIR}
${INSTALL_DATA} ${WRKSRC}/config/${file} ${NIMDIR}/config
.endfor

do-install-DOCS-on:
${FIND} ${WRKSRC}/doc -name "*.idx" -delete
${MKDIR} ${STAGEDIR}${DOCSDIR}
(cd ${WRKSRC}/doc && ${COPYTREE_SHARE} . ${STAGEDIR}${DOCSDIR})
${MKDIR} ${STAGEDIR}${PREFIX}/share/nim/dochack
${INSTALL_SCRIPT} ${WRKSRC}/tools/dochack/dochack.nim ${STAGEDIR}${PREFIX}/share/nim/dochack
${INSTALL_SCRIPT} ${WRKSRC}/tools/dochack/dochack.js ${STAGEDIR}${PREFIX}/share/nim/dochack
${INSTALL_SCRIPT} ${WRKSRC}/tools/dochack/fuzzysearch.nim ${STAGEDIR}${PREFIX}/share/nim/dochack
${MKDIR} ${NIMDIR}/doc
(cd ${WRKSRC}/doc && ${COPYTREE_SHARE} . ${NIMDIR}/doc)
${MKDIR} ${NIMDIR}/tools/dochack
${INSTALL_SCRIPT} ${WRKSRC}/tools/dochack/dochack.nim ${NIMDIR}/tools/dochack
${INSTALL_SCRIPT} ${WRKSRC}/tools/dochack/dochack.js ${NIMDIR}/tools/dochack
${INSTALL_SCRIPT} ${WRKSRC}/tools/dochack/fuzzysearch.nim ${NIMDIR}/tools/dochack

do-install-TOOLS-on:
.for t in ${TLIST}
${INSTALL_PROGRAM} ${WRKSRC}/bin/${t} ${STAGEDIR}${PREFIX}/bin
${INSTALL_PROGRAM} ${WRKSRC}/bin/${t} ${NIMDIR}/bin
.endfor

do-test:
Expand Down
6 changes: 3 additions & 3 deletions lang/nim/distinfo
@@ -1,3 +1,3 @@
TIMESTAMP = 1687959495
SHA256 (nim-1.6.14.tar.xz) = d070d2f28ae2400df7fe4a49eceb9f45cd539906b107481856a0af7a8fa82dc9
SIZE (nim-1.6.14.tar.xz) = 5266632
TIMESTAMP = 1690986777
SHA256 (nim-2.0.0.tar.xz) = bd6101d840036fb78e93a69df6cf3f9fd0c21cd754b695ff84a3b4add8ed0af7
SIZE (nim-2.0.0.tar.xz) = 7491724
15 changes: 0 additions & 15 deletions lang/nim/files/patch-build.sh

This file was deleted.

13 changes: 0 additions & 13 deletions lang/nim/files/patch-compiler_nimpaths.nim

This file was deleted.

16 changes: 2 additions & 14 deletions lang/nim/files/patch-config-nim.cfg
@@ -1,6 +1,6 @@
--- config/nim.cfg.orig 2021-10-20 15:37:06 UTC
--- config/nim.cfg.orig 2023-08-02 14:51:21 UTC
+++ config/nim.cfg
@@ -107,10 +107,7 @@ nimblepath="$home/.nimble/pkgs/"
@@ -130,10 +130,7 @@ nimblepath="$home/.nimble/pkgs/"
@end

@if unix:
Expand All @@ -12,15 +12,3 @@
gcc.options.linker = "-Wl,--as-needed -lnetwork"
gcc.cpp.options.linker = "-Wl,--as-needed -lnetwork"
clang.options.linker = "-Wl,--as-needed -lnetwork"
@@ -160,11 +157,6 @@ nimblepath="$home/.nimble/pkgs/"
@end

gcc.maxerrorsimpl = "-fmax-errors=3"
-
-@if bsd:
- # at least NetBSD has problems with thread local storage:
- tlsEmulation:on
-@end

@if macosx or freebsd or openbsd:
cc = clang
93 changes: 68 additions & 25 deletions lang/nim/files/patch-koch.nim
@@ -1,6 +1,6 @@
--- koch.nim.orig 2021-10-19 00:39:28 UTC
--- koch.nim.orig 2023-08-01 01:01:01 UTC
+++ koch.nim
@@ -139,18 +139,18 @@ proc csource(args: string) =
@@ -145,28 +145,28 @@ proc csource(args: string) =
"--main:compiler/nim.nim compiler/installer.ini $1") %
[args, VersionAsString, compileNimInst])

Expand All @@ -17,29 +17,50 @@
- let commit = if latest: "HEAD" else: NimbleStableCommit
- cloneDependency(distDir, "https://github.com/nim-lang/nimble.git",
- commit = commit, allowBundled = true)
- cloneDependency(distDir / "nimble" / distDir, "https://github.com/nim-lang/checksums.git",
- commit = ChecksumsStableCommit, allowBundled = true) # or copy it from dist?
- # installer.ini expects it under $nim/bin
- nimCompile("dist/nimble/src/nimble.nim",
- options = "-d:release --noNimblePath " & args)
- options = "-d:release --mm:refc --noNimblePath " & args)
+#proc bundleNimbleExe(latest: bool, args: string) =
+# let commit = if latest: "HEAD" else: NimbleStableCommit
+# cloneDependency(distDir, "https://github.com/nim-lang/nimble.git",
+# commit = commit, allowBundled = true)
+# cloneDependency(distDir / "nimble" / distDir, "https://github.com/nim-lang/checksums.git",
+# commit = ChecksumsStableCommit, allowBundled = true) # or copy it from dist?
+# # installer.ini expects it under $nim/bin
+# nimCompile("dist/nimble/src/nimble.nim",
+# options = "-d:release --mm:refc --noNimblePath " & args)

-proc bundleAtlasExe(latest: bool, args: string) =
- let commit = if latest: "HEAD" else: AtlasStableCommit
- cloneDependency(distDir, "https://github.com/nim-lang/atlas.git",
- commit = commit, allowBundled = true)
- # installer.ini expects it under $nim/bin
- nimCompile("dist/atlas/src/atlas.nim",
- options = "-d:release --noNimblePath " & args)
+#proc bundleAtlasExe(latest: bool, args: string) =
+# let commit = if latest: "HEAD" else: AtlasStableCommit
+# cloneDependency(distDir, "https://github.com/nim-lang/atlas.git",
+# commit = commit, allowBundled = true)
+# # installer.ini expects it under $nim/bin
+# nimCompile("dist/atlas/src/atlas.nim",
+# options = "-d:release --noNimblePath " & args)

proc bundleNimsuggest(args: string) =
nimCompileFold("Compile nimsuggest", "nimsuggest/nimsuggest.nim",
@@ -182,7 +182,7 @@ proc bundleWinTools(args: string) =
options = r"--cc:vcc --app:gui -d:ssl --noNimblePath --path:..\ui " & args)
@@ -203,8 +203,8 @@ proc bundleChecksums(latest: bool) =

proc zip(latest: bool; args: string) =
bundleChecksums(latest)
- bundleNimbleExe(latest, args)
- bundleAtlasExe(latest, args)
+ #bundleNimbleExe(latest, args)
+ #bundleAtlasExe(latest, args)
bundleNimsuggest(args)
bundleNimpretty(args)
bundleWinTools(args)
@@ -191,15 +191,15 @@ proc zip(latest: bool; args: string) =
@@ -213,15 +213,15 @@ proc zip(latest: bool; args: string) =
exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim zip compiler/installer.ini" %
["tools/niminst/niminst".exe, VersionAsString])

Expand All @@ -62,16 +83,18 @@
nimexec("cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
[VersionAsString, compileNimInst])
exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim xz compiler/installer.ini" %
@@ -231,7 +231,7 @@ proc buildTools(args: string = "") =

@@ -257,8 +257,8 @@ proc testTools(args: string = "") =

proc nsis(latest: bool; args: string) =
bundleChecksums(latest)
- bundleNimbleExe(latest, args)
- bundleAtlasExe(latest, args)
+ #bundleNimbleExe(latest, args)
+ #bundleAtlasExe(latest, args)
bundleNimsuggest(args)
bundleWinTools(args)
# make sure we have generated the niminst executables:
@@ -503,27 +503,27 @@ proc icTest(args: string) =
@@ -521,42 +521,42 @@ proc icTest(args: string) =
exec(cmd)
inc i

Expand Down Expand Up @@ -120,29 +143,29 @@


proc hostInfo(): string =
@@ -535,9 +535,9 @@ proc installDeps(dep: string, commit = "") =
"hostOS: $1, hostCPU: $2, int: $3, float: $4, cpuEndian: $5, cwd: $6" %
[hostOS, hostCPU, $int.sizeof, $float.sizeof, $cpuEndian, getCurrentDir()]

-proc installDeps(dep: string, commit = "") =
+#proc installDeps(dep: string, commit = "") =
# the hashes/urls are version controlled here, so can be changed seamlessly
# and tied to a nim release (mimicking git submodules)
var commit = commit
case dep
- var commit = commit
- case dep
- of "tinyc":
- if commit.len == 0: commit = "916cc2f94818a8a382dd8d4b8420978816c1dfb3"
- cloneDependency(distDir, "https://github.com/timotheecour/nim-tinyc-archive", commit)
- else: doAssert false, "unsupported: " & dep
+# var commit = commit
+# case dep
+ #of "tinyc":
+ # if commit.len == 0: commit = "916cc2f94818a8a382dd8d4b8420978816c1dfb3"
+ # cloneDependency(distDir, "https://github.com/timotheecour/nim-tinyc-archive", commit)
else: doAssert false, "unsupported: " & dep
+# else: doAssert false, "unsupported: " & dep
# xxx: also add linenoise, niminst etc, refs https://github.com/nim-lang/RFCs/issues/206

@@ -599,7 +599,7 @@ proc runCI(cmd: string) =
execFold("build nimsuggest_testing", "nim c -o:bin/nimsuggest_testing -d:release nimsuggest/nimsuggest")
execFold("Run nimsuggest tests", "nim r nimsuggest/tester")

- execFold("Run atlas tests", "nim c -r -d:atlasTests tools/atlas/atlas.nim clone https://github.com/disruptek/balls")
+ #execFold("Run atlas tests", "nim c -r -d:atlasTests tools/atlas/atlas.nim clone https://github.com/disruptek/balls")

when not defined(bsd):
if not doUseCpp:
@@ -662,12 +662,12 @@ proc showHelp(success: bool) =
proc runCI(cmd: string) =
@@ -679,18 +679,18 @@ proc showHelp(success: bool) =
quit(HelpText % [VersionAsString & spaces(44-len(VersionAsString)),
CompileDate, CompileTime], if success: QuitSuccess else: QuitFailure)

Expand All @@ -161,22 +184,42 @@

when isMainModule:
var op = initOptParser()
@@ -712,24 +712,24 @@ when isMainModule:
var
latest = false
- localDocsOnly = false
+ localDocsOnly = true
localDocsOut = ""
skipIntegrityCheck = false
while true:
@@ -726,34 +726,34 @@ when isMainModule:
of "distrohelper": geninstall()
of "install": install(op.cmdLineRest)
of "testinstall": testUnixInstall(op.cmdLineRest)
- of "installdeps": installDeps(op.cmdLineRest)
+ #of "installdeps": installDeps(op.cmdLineRest)
of "runci": runCI(op.cmdLineRest)
of "test", "tests": tests(op.cmdLineRest)
of "temp": temp(op.cmdLineRest)
of "xtemp": xtemp(op.cmdLineRest)
of "wintools": bundleWinTools(op.cmdLineRest)
- of "nimble": bundleNimbleExe(latest, op.cmdLineRest)
- of "atlas": bundleAtlasExe(latest, op.cmdLineRest)
+ #of "nimble": bundleNimbleExe(latest, op.cmdLineRest)
+ #of "atlas": bundleAtlasExe(latest, op.cmdLineRest)
of "nimsuggest": bundleNimsuggest(op.cmdLineRest)
# toolsNoNimble is kept for backward compatibility with build scripts
of "toolsnonimble", "toolsnoexternal":
buildTools(op.cmdLineRest)
of "tools":
buildTools(op.cmdLineRest)
- bundleNimbleExe(latest, op.cmdLineRest)
- bundleAtlasExe(latest, op.cmdLineRest)
+ #bundleNimbleExe(latest, op.cmdLineRest)
+ #bundleAtlasExe(latest, op.cmdLineRest)
of "checksums":
bundleChecksums(latest)
- of "pushcsource":
- quit "use this instead: https://github.com/nim-lang/csources_v1/blob/master/push_c_code.nim"
+ #bundleNimbleExe(latest, op.cmdLineRest)
+ #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
49 changes: 49 additions & 0 deletions lang/nim/files/patch-tools_deps.nim
@@ -0,0 +1,49 @@
--- tools/deps.nim.orig 2023-08-02 16:00:39 UTC
+++ tools/deps.nim
@@ -20,25 +20,26 @@ proc execRetry(cmd: string) =

proc cloneDependency*(destDirBase: string, url: string, commit = commitHead,
appendRepoName = true, allowBundled = false) =
- let destDirBase = destDirBase.absolutePath
- let p = url.parseUri.path
- let name = p.splitFile.name
- var destDir = destDirBase
- if appendRepoName: destDir = destDir / name
- let quotedDestDir = destDir.quoteShell
- if not dirExists(destDir):
+ #let destDirBase = destDirBase.absolutePath
+ #let p = url.parseUri.path
+ #let name = p.splitFile.name
+ #var destDir = destDirBase
+ #if appendRepoName: destDir = destDir / name
+ #let quotedDestDir = destDir.quoteShell
+ #if not dirExists(destDir):
# note: old code used `destDir / .git` but that wouldn't prevent git clone
# from failing
- execRetry fmt"git clone -q {url} {quotedDestDir}"
- if isGitRepo(destDir):
- let oldDir = getCurrentDir()
- setCurrentDir(destDir)
- try:
- execRetry "git fetch -q"
- exec fmt"git checkout -q {commit}"
- finally:
- setCurrentDir(oldDir)
- elif allowBundled:
- discard "this dependency was bundled with Nim, don't do anything"
- else:
- quit "FAILURE: " & destdir & " already exists but is not a git repo"
+ # execRetry fmt"git clone -q {url} {quotedDestDir}"
+ #if isGitRepo(destDir):
+ # let oldDir = getCurrentDir()
+ # setCurrentDir(destDir)
+ # try:
+ # execRetry "git fetch -q"
+ # exec fmt"git checkout -q {commit}"
+ # finally:
+ # setCurrentDir(oldDir)
+ #elif allowBundled:
+ # discard "this dependency was bundled with Nim, don't do anything"
+ #else:
+ # quit "FAILURE: " & destdir & " already exists but is not a git repo"
+ quit "FAILURE: git operations now allowed!: " & destDirBase

0 comments on commit 3a22c2f

Please sign in to comment.