2020-08-13 13:37:57 +00:00
|
|
|
#!/usr/bin/env bash
|
2024-10-17 02:59:25 +00:00
|
|
|
# Copyright (c) 2018-2024 Status Research & Development GmbH. Licensed under
|
2019-08-20 21:14:45 +00:00
|
|
|
# either of:
|
|
|
|
# - Apache License, version 2.0
|
|
|
|
# - MIT license
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
2024-10-17 02:59:25 +00:00
|
|
|
set -eo pipefail
|
2019-08-20 21:14:45 +00:00
|
|
|
|
2021-11-10 08:46:43 +00:00
|
|
|
# NIM_COMMIT could be a (partial) commit hash, a tag, a branch name, etc. Empty by default.
|
2021-03-02 17:03:30 +00:00
|
|
|
NIM_COMMIT_HASH="" # full hash for NIM_COMMIT, retrieved in "nim_needs_rebuilding()"
|
2019-08-20 21:14:45 +00:00
|
|
|
|
|
|
|
# script arguments
|
2020-06-14 17:12:27 +00:00
|
|
|
[[ $# -ne 4 ]] && { echo "Usage: $0 nim_dir csources_dir nimble_dir ci_cache_dir"; exit 1; }
|
2019-08-20 21:14:45 +00:00
|
|
|
NIM_DIR="$1"
|
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.
2024-01-15 15:21:06 +00:00
|
|
|
CSOURCES_DIR="$2" # can be relative to NIM_DIR; only used when `skipIntegrityCheck` unsupported
|
|
|
|
NIMBLE_DIR="$3" # can be relative to NIM_DIR; only used when `skipIntegrityCheck` unsupported
|
2019-08-20 21:14:45 +00:00
|
|
|
CI_CACHE="$4"
|
|
|
|
|
|
|
|
## env vars
|
|
|
|
# verbosity level
|
|
|
|
[[ -z "$V" ]] && V=0
|
|
|
|
[[ -z "$CC" ]] && CC="gcc"
|
|
|
|
# to build csources in parallel, set MAKE="make -jN"
|
|
|
|
[[ -z "$MAKE" ]] && MAKE="make"
|
2020-09-22 17:32:19 +00:00
|
|
|
# for 32-bit binaries on a 64-bit host
|
2019-08-20 21:14:45 +00:00
|
|
|
UCPU=""
|
|
|
|
[[ "$ARCH_OVERRIDE" == "x86" ]] && UCPU="ucpu=i686"
|
|
|
|
[[ -z "$NIM_BUILD_MSG" ]] && NIM_BUILD_MSG="Building the Nim compiler"
|
2020-12-26 15:04:58 +00:00
|
|
|
[[ -z "$QUICK_AND_DIRTY_COMPILER" ]] && QUICK_AND_DIRTY_COMPILER=0
|
2021-09-07 15:27:33 +00:00
|
|
|
[[ -z "$QUICK_AND_DIRTY_NIMBLE" ]] && QUICK_AND_DIRTY_NIMBLE=0
|
2019-08-20 21:14:45 +00:00
|
|
|
|
|
|
|
# Windows detection
|
|
|
|
if uname | grep -qiE "mingw|msys"; then
|
|
|
|
ON_WINDOWS=1
|
|
|
|
EXE_SUFFIX=".exe"
|
2020-04-30 20:27:55 +00:00
|
|
|
# otherwise it fails in AppVeyor due to https://github.com/git-for-windows/git/issues/2495
|
2020-05-01 13:10:44 +00:00
|
|
|
GIT_TIMESTAMP_ARG="--date=unix" # available since Git 2.9.4
|
2019-08-20 21:14:45 +00:00
|
|
|
else
|
|
|
|
ON_WINDOWS=0
|
|
|
|
EXE_SUFFIX=""
|
2020-05-01 13:10:44 +00:00
|
|
|
GIT_TIMESTAMP_ARG="--date=format-local:%s" # available since Git 2.7.0
|
2019-08-20 21:14:45 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
NIM_BINARY="${NIM_DIR}/bin/nim${EXE_SUFFIX}"
|
2022-03-18 09:21:21 +00:00
|
|
|
MAX_NIM_BINARIES="10" # Old ones get deleted.
|
2019-08-20 21:14:45 +00:00
|
|
|
|
|
|
|
nim_needs_rebuilding() {
|
|
|
|
REBUILD=0
|
|
|
|
NO_REBUILD=1
|
|
|
|
|
|
|
|
if [[ ! -e "$NIM_DIR" ]]; then
|
2021-03-02 17:03:30 +00:00
|
|
|
# Shallow clone, optimised for the default NIM_COMMIT value.
|
2020-06-18 22:46:22 +00:00
|
|
|
git clone -q --depth=1 https://github.com/status-im/Nim.git "$NIM_DIR"
|
2019-08-20 21:14:45 +00:00
|
|
|
fi
|
|
|
|
|
2021-03-02 17:03:30 +00:00
|
|
|
pushd "${NIM_DIR}" >/dev/null
|
2021-11-10 08:46:43 +00:00
|
|
|
if [[ -n "${NIM_COMMIT}" ]]; then
|
|
|
|
# support old Git versions, like the one from Ubuntu-18.04
|
|
|
|
git restore . 2>/dev/null || git reset --hard
|
2021-12-08 12:20:56 +00:00
|
|
|
if ! git checkout -q ${NIM_COMMIT} 2>/dev/null; then
|
2021-11-10 08:46:43 +00:00
|
|
|
# Pay the price for a non-default NIM_COMMIT here, by fetching everything.
|
|
|
|
# (This includes upstream branches and tags that might be missing from our fork.)
|
|
|
|
git remote add upstream https://github.com/nim-lang/Nim
|
2023-06-07 10:36:06 +00:00
|
|
|
git fetch --all --tags --quiet
|
2021-11-10 08:46:43 +00:00
|
|
|
git checkout -q ${NIM_COMMIT}
|
|
|
|
fi
|
|
|
|
# In case the local branch diverged and a fast-forward merge is not possible.
|
|
|
|
git fetch || true
|
2021-12-08 12:20:56 +00:00
|
|
|
git reset -q --hard origin/${NIM_COMMIT} 2>/dev/null || true
|
2021-11-10 08:46:43 +00:00
|
|
|
# In case NIM_COMMIT is a local branch that's behind the remote one it's tracking.
|
|
|
|
git pull -q 2>/dev/null || true
|
2021-03-02 17:03:30 +00:00
|
|
|
git checkout -q ${NIM_COMMIT}
|
2021-11-10 08:46:43 +00:00
|
|
|
# We can't use "rev-parse" here, because it would return the tag object's
|
|
|
|
# hash instead of the commit hash, when NIM_COMMIT is a tag.
|
|
|
|
NIM_COMMIT_HASH="$(git rev-list -n 1 ${NIM_COMMIT})"
|
|
|
|
else
|
|
|
|
# NIM_COMMIT is empty, so assume the commit we need is already checked out
|
|
|
|
NIM_COMMIT_HASH="$(git rev-list -n 1 HEAD)"
|
2021-03-02 17:03:30 +00:00
|
|
|
fi
|
|
|
|
popd >/dev/null
|
2021-02-08 18:12:28 +00:00
|
|
|
|
2019-08-20 21:14:45 +00:00
|
|
|
if [[ -n "$CI_CACHE" && -d "$CI_CACHE" ]]; then
|
|
|
|
cp -a "$CI_CACHE"/* "$NIM_DIR"/bin/ || true # let this one fail with an empty cache dir
|
|
|
|
fi
|
|
|
|
|
2022-03-18 09:21:21 +00:00
|
|
|
# Delete old Nim binaries, to put a limit on how much storage we use.
|
2022-03-18 20:09:01 +00:00
|
|
|
for F in "$(ls -t "${NIM_DIR}"/bin/nim_commit_* 2>/dev/null | tail -n +$((MAX_NIM_BINARIES + 1)))"; do
|
2022-03-18 09:21:21 +00:00
|
|
|
if [[ -e "${F}" ]]; then
|
|
|
|
rm "${F}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2022-01-26 10:54:34 +00:00
|
|
|
# Compare the last built commit to the one requested.
|
|
|
|
# Handle the scenario where our symlink is manually deleted by the user.
|
|
|
|
if [[ -e "${NIM_DIR}/bin/last_built_commit" && \
|
|
|
|
-e "${NIM_DIR}/bin/nim${EXE_SUFFIX}" && \
|
|
|
|
"$(cat "${NIM_DIR}/bin/last_built_commit")" == "${NIM_COMMIT_HASH}" ]]; then
|
2021-03-02 17:03:30 +00:00
|
|
|
return $NO_REBUILD
|
|
|
|
elif [[ -e "${NIM_DIR}/bin/nim_commit_${NIM_COMMIT_HASH}" ]]; then
|
|
|
|
# we built the requested commit in the past, so we simply reuse it
|
2021-04-29 11:22:35 +00:00
|
|
|
rm -f "${NIM_DIR}/bin/nim${EXE_SUFFIX}"
|
|
|
|
ln -s "nim_commit_${NIM_COMMIT_HASH}" "${NIM_DIR}/bin/nim${EXE_SUFFIX}"
|
2021-05-22 02:44:06 +00:00
|
|
|
echo ${NIM_COMMIT_HASH} > "${NIM_DIR}/bin/last_built_commit"
|
2019-08-20 21:14:45 +00:00
|
|
|
return $NO_REBUILD
|
|
|
|
else
|
|
|
|
return $REBUILD
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
build_nim() {
|
|
|
|
echo -e "$NIM_BUILD_MSG"
|
|
|
|
[[ "$V" == "0" ]] && exec &>/dev/null
|
|
|
|
|
|
|
|
# working directory
|
|
|
|
pushd "$NIM_DIR"
|
|
|
|
|
2024-10-08 12:20:14 +00:00
|
|
|
# Otherwise, when updating from pre-v2.0.10 to v2.0.10 or later,
|
|
|
|
# https://github.com/nim-lang/Nim/issues/24173 occurs. Simulates
|
|
|
|
# https://github.com/nim-lang/Nim/pull/24189 as a workaround.
|
2024-10-17 02:59:25 +00:00
|
|
|
#
|
|
|
|
# When building Nimbus from a Nix derivation which adds this as part of
|
|
|
|
# a preBuild phase, do not use this hack, because it's both unnecessary
|
|
|
|
# and prevents Nim from building.
|
|
|
|
NIX_BUILD_TOP="${NIX_BUILD_TOP:-}"
|
|
|
|
if [[ "${NIX_BUILD_TOP}" != "/build" ]]; then
|
|
|
|
rm -rf dist/checksums
|
|
|
|
fi
|
2024-10-08 12:20:14 +00:00
|
|
|
|
2023-05-22 13:55:06 +00:00
|
|
|
if grep -q skipIntegrityCheck koch.nim; then
|
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.
2024-01-15 15:21:06 +00:00
|
|
|
# Run Nim buildchain, with matching dependency versions
|
|
|
|
# - CSOURCES_REPO from Nim/config/build_config.txt (nim_csourcesUrl)
|
|
|
|
# - CSOURCES_COMMIT from Nim/config/build_config.txt (nim_csourcesHash)
|
|
|
|
# - NIMBLE_REPO from Nim/koch.nim (bundleNimbleExe)
|
|
|
|
# - NIMBLE_COMMIT from Nim/koch.nim (NimbleStableCommit)
|
2023-05-22 13:55:06 +00:00
|
|
|
. ci/funs.sh
|
|
|
|
NIMCORES=1 nimBuildCsourcesIfNeeded $UCPU
|
|
|
|
bin/nim c --noNimblePath --skipUserCfg --skipParentCfg --warnings:off --hints:off koch
|
|
|
|
./koch --skipIntegrityCheck boot -d:release --skipUserCfg --skipParentCfg --warnings:off --hints:off
|
|
|
|
if [[ "${QUICK_AND_DIRTY_COMPILER}" == "0" ]]; then
|
|
|
|
# We want tools
|
|
|
|
./koch tools -d:release --skipUserCfg --skipParentCfg --warnings:off --hints:off
|
|
|
|
elif [[ "${QUICK_AND_DIRTY_NIMBLE}" != "0" ]]; then
|
|
|
|
# We just want nimble
|
|
|
|
./koch nimble -d:release --skipUserCfg --skipParentCfg --warnings:off --hints:off
|
2023-01-05 09:40:49 +00:00
|
|
|
fi
|
2023-05-22 13:55:06 +00:00
|
|
|
else
|
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.
2024-01-15 15:21:06 +00:00
|
|
|
# Git commits
|
|
|
|
: ${CSOURCES_V1_COMMIT:=561b417c65791cd8356b5f73620914ceff845d10}
|
|
|
|
: ${CSOURCES_V2_COMMIT:=86742fb02c6606ab01a532a0085784effb2e753e}
|
|
|
|
: ${CSOURCES_V1_REPO:=https://github.com/nim-lang/csources_v1.git}
|
|
|
|
: ${CSOURCES_V2_REPO:=https://github.com/nim-lang/csources_v2.git}
|
|
|
|
|
|
|
|
# After this Nim commit, use csources v2
|
|
|
|
: ${CSOURCES_V2_START_COMMIT:=f7c203fb6c89b5cef83c4f326aeb23ef8c4a2c40}
|
|
|
|
: ${NIMBLE_REPO:=https://github.com/nim-lang/nimble.git}
|
|
|
|
: ${NIMBLE_COMMIT:=d13f3b8ce288b4dc8c34c219a4e050aaeaf43fc9} # 0.13.1
|
|
|
|
|
2023-05-22 13:55:06 +00:00
|
|
|
# Custom buildchain for older versions
|
|
|
|
# TODO Remove this once the default NIM_COMMIT supports `--skipIntegrityCheck`
|
|
|
|
# We will still be able to compile older versions by removing the flag,
|
|
|
|
# which will just waste a bit of CPU
|
2023-01-05 09:40:49 +00:00
|
|
|
|
2023-05-22 13:55:06 +00:00
|
|
|
# Git repos for csources and Nimble
|
|
|
|
if [[ ! -d "$CSOURCES_DIR" ]]; then
|
|
|
|
if git merge-base --is-ancestor $CSOURCES_V2_START_COMMIT $NIM_COMMIT_HASH; then
|
|
|
|
CSOURCES_REPO=$CSOURCES_V2_REPO
|
|
|
|
CSOURCES_COMMIT=$CSOURCES_V2_COMMIT
|
|
|
|
else
|
|
|
|
CSOURCES_REPO=$CSOURCES_V1_REPO
|
|
|
|
CSOURCES_COMMIT=$CSOURCES_V1_COMMIT
|
|
|
|
fi
|
2019-08-20 21:14:45 +00:00
|
|
|
|
2023-05-22 13:55:06 +00:00
|
|
|
mkdir -p "$CSOURCES_DIR"
|
|
|
|
pushd "$CSOURCES_DIR"
|
|
|
|
git clone $CSOURCES_REPO .
|
|
|
|
git checkout $CSOURCES_COMMIT
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
if [[ "$CSOURCES_DIR" != "csources" ]]; then
|
|
|
|
rm -rf csources
|
|
|
|
ln -s "$CSOURCES_DIR" csources
|
|
|
|
fi
|
2019-08-20 21:14:45 +00:00
|
|
|
|
2023-05-22 13:55:06 +00:00
|
|
|
if [[ ! -d "$NIMBLE_DIR" ]]; then
|
|
|
|
mkdir -p "$NIMBLE_DIR"
|
|
|
|
pushd "$NIMBLE_DIR"
|
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.
2024-01-15 15:21:06 +00:00
|
|
|
git clone $NIMBLE_REPO .
|
2023-05-22 13:55:06 +00:00
|
|
|
git checkout $NIMBLE_COMMIT
|
|
|
|
# we have to delete .git or koch.nim will checkout a branch tip, overriding our target commit
|
|
|
|
rm -rf .git
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
if [[ "$NIMBLE_DIR" != "dist/nimble" ]]; then
|
|
|
|
mkdir -p dist
|
|
|
|
rm -rf dist/nimble
|
|
|
|
ln -s ../"$NIMBLE_DIR" dist/nimble
|
|
|
|
fi
|
2021-09-07 15:27:33 +00:00
|
|
|
|
2023-05-22 13:55:06 +00:00
|
|
|
# bootstrap the Nim compiler and build the tools
|
|
|
|
rm -f bin/{nim,nim_csources}
|
|
|
|
pushd csources
|
|
|
|
if [[ "$ON_WINDOWS" == "0" ]]; then
|
|
|
|
$MAKE $UCPU clean
|
|
|
|
$MAKE $UCPU LD=$CC
|
|
|
|
else
|
|
|
|
$MAKE myos=windows $UCPU clean
|
|
|
|
$MAKE myos=windows $UCPU CC=gcc LD=gcc
|
2021-09-07 15:27:33 +00:00
|
|
|
fi
|
2023-05-22 13:55:06 +00:00
|
|
|
popd
|
|
|
|
if [[ -e csources/bin ]]; then
|
|
|
|
rm -f bin/nim bin/nim_csources
|
|
|
|
cp -a csources/bin/nim bin/nim
|
|
|
|
cp -a csources/bin/nim bin/nim_csources
|
|
|
|
rm -rf csources/bin
|
|
|
|
else
|
|
|
|
cp -a bin/nim bin/nim_csources
|
|
|
|
fi
|
|
|
|
if [[ "$QUICK_AND_DIRTY_COMPILER" == "0" ]]; then
|
|
|
|
sed \
|
|
|
|
-e 's/koch$/--warnings:off --hints:off koch/' \
|
|
|
|
-e 's/koch boot/koch boot --warnings:off --hints:off/' \
|
|
|
|
-e '/nimBuildCsourcesIfNeeded/d' \
|
|
|
|
build_all.sh > build_all_custom.sh
|
|
|
|
sh build_all_custom.sh
|
|
|
|
rm build_all_custom.sh
|
|
|
|
else
|
|
|
|
# Don't re-build it multiple times until we get identical
|
|
|
|
# binaries, like "build_all.sh" does. Don't build any tools
|
|
|
|
# either. This is all about build speed, not developer comfort.
|
|
|
|
bin/nim_csources \
|
|
|
|
c \
|
|
|
|
--compileOnly \
|
|
|
|
--nimcache:nimcache \
|
|
|
|
-d:release \
|
|
|
|
--skipUserCfg \
|
|
|
|
--skipParentCfg \
|
|
|
|
--warnings:off \
|
|
|
|
--hints:off \
|
|
|
|
compiler/nim.nim
|
|
|
|
bin/nim_csources \
|
|
|
|
jsonscript \
|
|
|
|
--nimcache:nimcache \
|
|
|
|
--skipUserCfg \
|
|
|
|
--skipParentCfg \
|
|
|
|
compiler/nim.nim
|
|
|
|
cp -a compiler/nim bin/nim1
|
|
|
|
# If we stop here, we risk ending up with a buggy compiler:
|
|
|
|
# https://github.com/status-im/nimbus-eth2/pull/2220
|
|
|
|
# https://github.com/status-im/nimbus-eth2/issues/2310
|
|
|
|
bin/nim1 \
|
|
|
|
c \
|
|
|
|
--compileOnly \
|
|
|
|
--nimcache:nimcache \
|
|
|
|
-d:release \
|
|
|
|
--skipUserCfg \
|
|
|
|
--skipParentCfg \
|
|
|
|
--warnings:off \
|
|
|
|
--hints:off \
|
|
|
|
compiler/nim.nim
|
|
|
|
bin/nim1 \
|
|
|
|
jsonscript \
|
|
|
|
--nimcache:nimcache \
|
|
|
|
--skipUserCfg \
|
|
|
|
--skipParentCfg \
|
|
|
|
compiler/nim.nim
|
|
|
|
rm -f bin/nim
|
|
|
|
cp -a compiler/nim bin/nim
|
|
|
|
rm bin/nim1
|
2019-08-20 21:14:45 +00:00
|
|
|
|
2023-05-22 13:55:06 +00:00
|
|
|
# Do we want Nimble in this quick build?
|
|
|
|
if [[ "${QUICK_AND_DIRTY_NIMBLE}" != "0" ]]; then
|
|
|
|
bin/nim c -d:release --noNimblePath --skipUserCfg --skipParentCfg dist/nimble/src/nimble.nim
|
|
|
|
mv dist/nimble/src/nimble bin/
|
|
|
|
fi
|
|
|
|
fi
|
2023-06-09 18:26:55 +00:00
|
|
|
fi
|
2023-05-22 13:55:06 +00:00
|
|
|
|
2023-06-09 18:26:55 +00:00
|
|
|
if [[ "$QUICK_AND_DIRTY_COMPILER" == "0" || "${QUICK_AND_DIRTY_NIMBLE}" != "0" ]]; then
|
|
|
|
# Nimble needs a CA cert
|
|
|
|
rm -f bin/cacert.pem
|
|
|
|
curl -LsS -o bin/cacert.pem https://curl.se/ca/cacert.pem || echo "Warning: 'curl' failed to download a CA cert needed by Nimble. Ignoring it."
|
2022-03-18 09:29:00 +00:00
|
|
|
fi
|
|
|
|
|
2021-03-02 17:03:30 +00:00
|
|
|
# record the built commit
|
|
|
|
echo ${NIM_COMMIT_HASH} > bin/last_built_commit
|
|
|
|
|
|
|
|
# create the symlink
|
|
|
|
mv bin/nim bin/nim_commit_${NIM_COMMIT_HASH}
|
2021-04-29 11:22:35 +00:00
|
|
|
ln -s nim_commit_${NIM_COMMIT_HASH} bin/nim${EXE_SUFFIX}
|
2019-09-30 01:40:12 +00:00
|
|
|
|
2019-08-20 21:14:45 +00:00
|
|
|
# update the CI cache
|
|
|
|
popd # we were in $NIM_DIR
|
|
|
|
if [[ -n "$CI_CACHE" ]]; then
|
|
|
|
rm -rf "$CI_CACHE"
|
|
|
|
mkdir "$CI_CACHE"
|
2023-01-12 12:38:06 +00:00
|
|
|
cp "$NIM_DIR"/bin/* "$CI_CACHE"/
|
2019-08-20 21:14:45 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if nim_needs_rebuilding; then
|
|
|
|
build_nim
|
|
|
|
fi
|