Skip to content

Commit 3866a8a

Browse files
authored
remove Nim-csources-v1 and nimble checkouts (#75)
When `build_nim.sh` detects that `skipIntegrityCheck` is supported, it runs the upstream toolchain for building Nim, ignoring the locally checked out `Nim-csources-v1` and `nimble` sub-repositories. So, having those repos checked out is not useful in that scenario. When `skipIntegrityCheck` is unsupported, `build_nim.sh` uses the local sub-repositories if they are available. But, it also clones them if they are unavailable using commits as specified by environment variables. Because the clone will happen as part of the script, having the repos linked as sub-repositories is also not useful. Even worse, if the script has different commit hashes than the subrepository, the behaviour is different depending on whether `build_nim.sh` is run before or after the submodules are checked out. Therefore, we can remove the `Nim-csources-v1` and `nimble` sub-repos, using the upstream build system if available, or the hardcoded commits inside `build_nim.sh` to have a manual build, as before. Also moves the various variables that control the used versions into the manual section to emphasize that these only take effect in manual mode, but not when using upstream build system (`skipIntegrityCheck`). If one wants to use a custom `Nimble` version, fork `Nim` and adjust the config in that fork. That also works with the upstream build system.
1 parent c01eb70 commit 3866a8a

File tree

5 files changed

+20
-26
lines changed

5 files changed

+20
-26
lines changed

.gitmodules

-10
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,3 @@
33
url = https://github.com/status-im/Nim.git
44
ignore = dirty
55
branch = nimbus
6-
[submodule "vendor/nimble"]
7-
path = vendor/nimble
8-
url = https://github.com/nim-lang/nimble.git
9-
ignore = dirty
10-
branch = master
11-
[submodule "vendor/Nim-csources-v1"]
12-
path = vendor/Nim-csources-v1
13-
url = https://github.com/nim-lang/csources_v1.git
14-
ignore = untracked
15-
branch = master

makefiles/targets.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ build-nim: | sanity-checks
8585
MAKE="$(MAKE)" \
8686
ARCH_OVERRIDE=$(ARCH_OVERRIDE) \
8787
QUICK_AND_DIRTY_COMPILER=$(QUICK_AND_DIRTY_COMPILER) \
88-
"$(CURDIR)/$(BUILD_SYSTEM_DIR)/scripts/build_nim.sh" "$(NIM_DIR)" ../Nim-csources-v1 ../nimble "$(CI_CACHE)"
88+
"$(CURDIR)/$(BUILD_SYSTEM_DIR)/scripts/build_nim.sh" "$(NIM_DIR)" ../Nim-csources ../nimble "$(CI_CACHE)"
8989

9090
# Check if the update might cause loss of work. Abort, if so, while allowing an override mechanism.
9191
update-test:

scripts/build_nim.sh

+19-13
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,14 @@
1010

1111
set -e
1212

13-
# Git commits
14-
: ${CSOURCES_V1_COMMIT:=561b417c65791cd8356b5f73620914ceff845d10}
15-
: ${CSOURCES_V2_COMMIT:=86742fb02c6606ab01a532a0085784effb2e753e}
16-
: ${CSOURCES_V1_REPO:=https://github.com/nim-lang/csources_v1.git}
17-
: ${CSOURCES_V2_REPO:=https://github.com/nim-lang/csources_v2.git}
18-
19-
# After this Nim commit, use csources v2
20-
: ${CSOURCES_V2_START_COMMIT:=f7c203fb6c89b5cef83c4f326aeb23ef8c4a2c40}
21-
: ${NIMBLE_COMMIT:=d13f3b8ce288b4dc8c34c219a4e050aaeaf43fc9} # 0.13.1
2213
# NIM_COMMIT could be a (partial) commit hash, a tag, a branch name, etc. Empty by default.
2314
NIM_COMMIT_HASH="" # full hash for NIM_COMMIT, retrieved in "nim_needs_rebuilding()"
2415

2516
# script arguments
2617
[[ $# -ne 4 ]] && { echo "Usage: $0 nim_dir csources_dir nimble_dir ci_cache_dir"; exit 1; }
2718
NIM_DIR="$1"
28-
CSOURCES_DIR="$2" # can be relative to NIM_DIR
29-
NIMBLE_DIR="$3" # can be relative to NIM_DIR
19+
CSOURCES_DIR="$2" # can be relative to NIM_DIR; only used when `skipIntegrityCheck` unsupported
20+
NIMBLE_DIR="$3" # can be relative to NIM_DIR; only used when `skipIntegrityCheck` unsupported
3021
CI_CACHE="$4"
3122

3223
## env vars
@@ -128,7 +119,11 @@ build_nim() {
128119
pushd "$NIM_DIR"
129120

130121
if grep -q skipIntegrityCheck koch.nim; then
131-
# Run Nim buildchain
122+
# Run Nim buildchain, with matching dependency versions
123+
# - CSOURCES_REPO from Nim/config/build_config.txt (nim_csourcesUrl)
124+
# - CSOURCES_COMMIT from Nim/config/build_config.txt (nim_csourcesHash)
125+
# - NIMBLE_REPO from Nim/koch.nim (bundleNimbleExe)
126+
# - NIMBLE_COMMIT from Nim/koch.nim (NimbleStableCommit)
132127
. ci/funs.sh
133128
NIMCORES=1 nimBuildCsourcesIfNeeded $UCPU
134129
bin/nim c --noNimblePath --skipUserCfg --skipParentCfg --warnings:off --hints:off koch
@@ -141,6 +136,17 @@ build_nim() {
141136
./koch nimble -d:release --skipUserCfg --skipParentCfg --warnings:off --hints:off
142137
fi
143138
else
139+
# Git commits
140+
: ${CSOURCES_V1_COMMIT:=561b417c65791cd8356b5f73620914ceff845d10}
141+
: ${CSOURCES_V2_COMMIT:=86742fb02c6606ab01a532a0085784effb2e753e}
142+
: ${CSOURCES_V1_REPO:=https://github.com/nim-lang/csources_v1.git}
143+
: ${CSOURCES_V2_REPO:=https://github.com/nim-lang/csources_v2.git}
144+
145+
# After this Nim commit, use csources v2
146+
: ${CSOURCES_V2_START_COMMIT:=f7c203fb6c89b5cef83c4f326aeb23ef8c4a2c40}
147+
: ${NIMBLE_REPO:=https://github.com/nim-lang/nimble.git}
148+
: ${NIMBLE_COMMIT:=d13f3b8ce288b4dc8c34c219a4e050aaeaf43fc9} # 0.13.1
149+
144150
# Custom buildchain for older versions
145151
# TODO Remove this once the default NIM_COMMIT supports `--skipIntegrityCheck`
146152
# We will still be able to compile older versions by removing the flag,
@@ -170,7 +176,7 @@ build_nim() {
170176
if [[ ! -d "$NIMBLE_DIR" ]]; then
171177
mkdir -p "$NIMBLE_DIR"
172178
pushd "$NIMBLE_DIR"
173-
git clone https://github.com/nim-lang/nimble.git .
179+
git clone $NIMBLE_REPO .
174180
git checkout $NIMBLE_COMMIT
175181
# we have to delete .git or koch.nim will checkout a branch tip, overriding our target commit
176182
rm -rf .git

vendor/Nim-csources-v1

-1
This file was deleted.

vendor/nimble

-1
This file was deleted.

0 commit comments

Comments
 (0)