From cbadeda314284c22889020ef0bc5b32ddc3a65e8 Mon Sep 17 00:00:00 2001 From: jmgomez Date: Thu, 18 Jul 2024 15:29:27 +0100 Subject: [PATCH 1/3] Adds a fallback to `build_all` when `csources` fails --- src/nimblepkg/nimenv.nim | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/nimblepkg/nimenv.nim b/src/nimblepkg/nimenv.nim index 0cd61a132..8a0df824d 100644 --- a/src/nimblepkg/nimenv.nim +++ b/src/nimblepkg/nimenv.nim @@ -51,23 +51,34 @@ proc compileNim*(options: Options, nimDest: string, v: VersionRange) = else: "csources_v1" cd workspace: - echo "Entering CSOURCES", csourcesVersion, " exists ", dirExists(csourcesVersion) if not dirExists(csourcesVersion): exec "git clone https://github.com/nim-lang/" & csourcesVersion + var csourcesSucceed = false cd workspace / csourcesVersion: when defined(windows): - exec "build.bat" + let cmd = "build.bat" + csourcesSucceed = os.execShellCmd(cmd) != 0 else: let makeExe = findExe("make") if makeExe.len == 0: - exec "sh build.sh" + let cmd = "sh build.sh" + csourcesSucceed = os.execShellCmd(cmd) != 0 else: - exec "make" - let nimExe0 = ".." / csourcesVersion / "bin" / "nim".addFileExt(ExeExt) + let cmd = "make" + csourcesSucceed = os.execShellCmd(cmd) != 0 + cd nimDest: + #Sometimes building from csources fails and we cant do much about it. So we fallback to the slow build_all method + if not csourcesSucceed: + display("Warning", "Building nim from csources failed. Using `build_all`", Warning, HighPriority) + let cmd = + when defined(windows): "build_all.bat" + else: "sh build_all.sh" + exec cmd let nimExe = "bin" / "nim".addFileExt(ExeExt) - copyFileWithPermissions nimExe0, nimExe + when defined(nimExe0): + copyFileWithPermissions nimExe0, nimExe exec nimExe & " c --noNimblePath --skipUserCfg --skipParentCfg --hints:off koch" let kochExe = when defined(windows): "koch.exe" else: "./koch" exec kochExe & " boot -d:release --skipUserCfg --skipParentCfg --hints:off" From fc19b1ab1b3b7ae0cf9dea0fa51335dda1d3e148 Mon Sep 17 00:00:00 2001 From: jmgomez Date: Fri, 19 Jul 2024 11:52:01 +0100 Subject: [PATCH 2/3] reverse test --- src/nimblepkg/nimenv.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nimblepkg/nimenv.nim b/src/nimblepkg/nimenv.nim index 8a0df824d..aaaa0ae31 100644 --- a/src/nimblepkg/nimenv.nim +++ b/src/nimblepkg/nimenv.nim @@ -58,15 +58,15 @@ proc compileNim*(options: Options, nimDest: string, v: VersionRange) = cd workspace / csourcesVersion: when defined(windows): let cmd = "build.bat" - csourcesSucceed = os.execShellCmd(cmd) != 0 + csourcesSucceed = os.execShellCmd(cmd) == 0 else: let makeExe = findExe("make") if makeExe.len == 0: let cmd = "sh build.sh" - csourcesSucceed = os.execShellCmd(cmd) != 0 + csourcesSucceed = os.execShellCmd(cmd) == 0 else: let cmd = "make" - csourcesSucceed = os.execShellCmd(cmd) != 0 + csourcesSucceed = os.execShellCmd(cmd) == 0 cd nimDest: #Sometimes building from csources fails and we cant do much about it. So we fallback to the slow build_all method From e47c4af74b5e1abe045a1a05c4a4c9aabb58ee6b Mon Sep 17 00:00:00 2001 From: jmgomez Date: Fri, 19 Jul 2024 12:58:08 +0100 Subject: [PATCH 3/3] fixes nimenv regression --- src/nimblepkg/nimenv.nim | 3 ++- tests/tniminstall.nim | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nimblepkg/nimenv.nim b/src/nimblepkg/nimenv.nim index aaaa0ae31..92a9f63bb 100644 --- a/src/nimblepkg/nimenv.nim +++ b/src/nimblepkg/nimenv.nim @@ -77,7 +77,8 @@ proc compileNim*(options: Options, nimDest: string, v: VersionRange) = else: "sh build_all.sh" exec cmd let nimExe = "bin" / "nim".addFileExt(ExeExt) - when defined(nimExe0): + let nimExe0 = ".." / csourcesVersion / "bin" / "nim".addFileExt(ExeExt) + if csourcesSucceed: copyFileWithPermissions nimExe0, nimExe exec nimExe & " c --noNimblePath --skipUserCfg --skipParentCfg --hints:off koch" let kochExe = when defined(windows): "koch.exe" else: "./koch" diff --git a/tests/tniminstall.nim b/tests/tniminstall.nim index eb89bf5cc..737ad7c12 100644 --- a/tests/tniminstall.nim +++ b/tests/tniminstall.nim @@ -28,5 +28,6 @@ suite "Nim install": echo "Checking version ", nimVer let (_, exitCode) = execNimble("install", "-l") let pkgPath = getCurrentDir() / "nimbledeps" / "pkgs2" + echo "Checking ", pkgPath check exitCode == QuitSuccess check walkDir(pkgPath).toSeq.anyIt(it[1].isNimPkgVer(nimVer))