Skip to content

Commit f10824f

Browse files
committed
fix #11457 lock down csources version
1 parent 7d17cd3 commit f10824f

File tree

6 files changed

+80
-23
lines changed

6 files changed

+80
-23
lines changed

.builds/freebsd.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ tasks:
2121
sudo pkg install -y -q databases/sqlite3 devel/boehm-gc-threaded devel/pcre \
2222
devel/sdl20 devel/sfml www/node devel/gmake devel/git
2323
cd Nim
24-
git clone --depth 1 -q https://github.com/nim-lang/csources.git
25-
gmake -C csources -j $(sysctl -n hw.ncpu)
26-
bin/nim c --skipUserCfg --skipParentCfg koch
24+
NIMBUILD_ACTION=action_build_koch sh build_all.sh
2725
echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv
2826
- test: |
2927
cd Nim

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848

4949
- checkout: self
5050

51-
- bash: git clone --depth 1 https://github.com/nim-lang/csources.git
51+
- bash: NIMBUILD_ACTION=action_fetch_csources sh build_all.sh
5252
displayName: 'Checkout csources'
5353

5454
- task: NodeTool@0

build_all.bat

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
@echo off
2-
rem build development version of the compiler; can be rerun safely
2+
rem build development version of the compiler; can be rerun safely but won't pickup
3+
rem modifications in config/build_config.txt after 1st run, see build_all.sh for a way
4+
5+
rem read in some common shared variables (shared with other tools)
6+
rem see https://stackoverflow.com/questions/3068929/how-to-read-file-contents-into-a-variable-in-a-batch-file
7+
for /f "delims== tokens=1,2" %%G in (config/build_config.txt) do set %%G=%%H
8+
39
if not exist csources (
4-
git clone --depth 1 https://github.com/nim-lang/csources.git
10+
git clone -q --depth 1 --branch %nim_csources2_tag% %nim_csources2url% csources
511
)
612
if not exist bin\nim.exe (
713
cd csources
@@ -11,7 +17,7 @@ if not exist bin\nim.exe (
1117
CALL build.bat
1218
cd ..
1319
)
14-
bin\nim.exe c --skipUserCfg --skipParentCfg koch
15-
koch.exe boot -d:release --skipUserCfg --skipParentCfg
16-
koch.exe tools --skipUserCfg --skipParentCfg
20+
bin\nim.exe c --skipUserCfg --skipParentCfg --hints:off koch
21+
koch.exe boot -d:release --skipUserCfg --skipParentCfg --hints:off
22+
koch.exe tools --skipUserCfg --skipParentCfg --hints:off
1723

build_all.sh

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
#! /bin/sh
22

3-
# build development version of the compiler; can be rerun safely.
3+
# build development version of the compiler; can be rerun safely and will pickup
4+
# any modification in config/build_config.txt
45
# arguments can be passed, eg `--os freebsd`
6+
#
7+
# Usage:
8+
# sh build_all.sh # builds all
9+
# NIMBUILD_ACTION=action_build_koch sh build_all.sh # just builds everything up to koch
10+
511

612
set -u # error on undefined variables
713
set -e # exit on first error
@@ -11,9 +17,20 @@ echo_run(){
1117
"$@"
1218
}
1319

14-
[ -d csources ] || echo_run git clone -q --depth 1 https://github.com/nim-lang/csources.git
20+
echo_run . config/build_config.txt
21+
22+
nim_csources=bin/nim_csources2
1523

16-
nim_csources=bin/nim_csources
24+
fetch_nim_csources(){
25+
(
26+
[ -d csources ] || echo_run $nim_csources2_clone_cmd
27+
echo_run cd csources
28+
echo_run git remote set-url origin $nim_csources2url
29+
echo_run git fetch -q --depth 1 origin tag $nim_csources2_tag
30+
echo_run git checkout $nim_csources2_tag
31+
echo_run git reset --hard $nim_csources2_tag
32+
)
33+
}
1734

1835
build_nim_csources_via_script(){
1936
echo_run cd csources
@@ -23,6 +40,8 @@ build_nim_csources_via_script(){
2340
build_nim_csources(){
2441
# avoid changing dir in case of failure
2542
(
43+
[ -f bin/nim ] && echo_run rm bin/nim # otherwise wrongly says: `bin/nim' is up to date.
44+
# it's cheap to redo the linking step anyway
2645
if [ $# -ne 0 ]; then
2746
# some args were passed (eg: `--cpu i386`), need to call build.sh
2847
build_nim_csources_via_script "$@"
@@ -37,16 +56,50 @@ build_nim_csources(){
3756
which $makeX && echo_run $makeX -C csources -j $((nCPU + 2)) -l $nCPU || build_nim_csources_via_script
3857
fi
3958
)
59+
echo_run bin/nim -v
4060
# keep $nim_csources in case needed to investigate bootstrap issues
4161
# without having to rebuild from csources
4262
echo_run cp bin/nim $nim_csources
4363
}
4464

45-
[ -f $nim_csources ] || echo_run build_nim_csources $@
65+
## stable API below here
66+
action_fetch_csources(){
67+
echo_run fetch_nim_csources
68+
}
4669

47-
# Note: if fails, may need to `cd csources && git pull`
48-
echo_run bin/nim c --skipUserCfg --skipParentCfg koch
70+
action_build_csources(){
71+
action_fetch_csources
72+
echo_run build_nim_csources
73+
}
74+
75+
action_build_koch(){
76+
action_build_csources
77+
# always bootstrap from $nim_csources for reproducibility, in case this is rerun
78+
echo_run $nim_csources c --skipUserCfg --skipParentCfg --hints:off koch
79+
}
80+
81+
action_build_all(){
82+
action_build_koch
83+
# re-running without modifications takes 2 seconds up to this line
84+
echo_run ./koch boot -d:release --skipUserCfg --skipParentCfg --hints:off
85+
echo_run ./koch tools --skipUserCfg --skipParentCfg --hints:off # Compile Nimble and other tools.
86+
}
4987

50-
echo_run ./koch boot -d:release --skipUserCfg --skipParentCfg
51-
echo_run ./koch tools --skipUserCfg --skipParentCfg # Compile Nimble and other tools.
88+
echo "NIMBUILD_ACTION: ${NIMBUILD_ACTION}"
5289

90+
if [ -z "${NIMBUILD_ACTION}" ]; then
91+
action_build_all # backward compatibility: same as action_build_all
92+
elif [ "${NIMBUILD_ACTION}" = "action_definitions" ]; then
93+
echo "bash functions defined" # useful if we source this, then we can call individual functions
94+
elif [ "${NIMBUILD_ACTION}" = "action_fetch_csources" ]; then
95+
action_fetch_csources
96+
elif [ "${NIMBUILD_ACTION}" = "action_build_csources" ]; then
97+
echo_run fetch_nim_csources
98+
elif [ "${NIMBUILD_ACTION}" = "action_build_koch" ]; then
99+
action_build_koch
100+
elif [ "${NIMBUILD_ACTION}" = "action_build_all" ]; then
101+
action_build_all
102+
else
103+
echo "unrecognized NIMBUILD_ACTION: $NIMBUILD_ACTION"
104+
exit 1
105+
fi

ci/build.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
sh ci/deps.sh
22

33
# Build from C sources.
4-
git clone --depth 1 https://github.com/nim-lang/csources.git
5-
cd csources
6-
sh build.sh
7-
cd ..
4+
NIMBUILD_ACTION=action_build_koch sh build_all.sh
5+
86
# Add Nim to the PATH
97
export PATH=$(pwd)/bin${PATH:+:$PATH}
108
# Bootstrap.
11-
nim -v
12-
nim c koch
139
./koch boot
1410
cp bin/nim bin/nimd
1511
./koch boot -d:release

config/build_config.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
nim_comment="key-value pairs for windows/posix builds, locking down csources version (refs #11457)"
2+
nim_csources2url=https://github.com/timotheecour/csources
3+
nim_csources2_tag=v0.20.0
4+
nim_csources2_clone_cmd="git clone -q --depth 1 --branch $nim_csources2_tag $nim_csources2url csources"

0 commit comments

Comments
 (0)