Skip to content

Commit 8dc6dea

Browse files
committed
Consistency tweaks and syntax cleanup in scripts that deal with solc version
1 parent a6945de commit 8dc6dea

File tree

4 files changed

+57
-62
lines changed

4 files changed

+57
-62
lines changed

scripts/build.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
ROOTDIR="$(dirname "$0")/.."
4+
ROOTDIR=$(dirname "$0")/..
55
BUILDDIR="${ROOTDIR}/build"
66

7-
if [[ $# -eq 0 ]]; then
7+
if (( $# == 0 )); then
88
BUILD_TYPE=Release
99
else
1010
BUILD_TYPE="$1"
1111
fi
1212

13-
if [[ "$(git tag --points-at HEAD 2>/dev/null)" == v* ]]; then
14-
touch "${ROOTDIR}/prerelease.txt"
13+
if [[ $(git tag --points-at HEAD 2> /dev/null) == v* ]]; then
14+
echo -n > prerelease.txt
1515
fi
1616

17-
mkdir -p "${BUILDDIR}"
18-
cd "${BUILDDIR}"
17+
mkdir -p "$BUILDDIR"
18+
cd "$BUILDDIR"
1919

2020
cmake .. -DCMAKE_BUILD_TYPE="$BUILD_TYPE" "${@:2}"
2121
make -j2
2222

23-
if [[ "${CI}" == "" ]]; then
24-
echo "Installing ..."
25-
sudo make install
23+
if [[ $CI == "" ]]; then
24+
echo "Installing ..."
25+
sudo make install
2626
fi

scripts/ci/build.sh

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,23 @@ prerelease_source="${1:-ci}"
99

1010
cd "${ROOTDIR}"
1111

12-
# shellcheck disable=SC2166
13-
if [ "$CIRCLE_BRANCH" = release -o -n "$CIRCLE_TAG" -o -n "$FORCE_RELEASE" ]
14-
then
15-
echo -n >prerelease.txt
12+
if [[ $CIRCLE_BRANCH == release || -n $CIRCLE_TAG || -n $FORCE_RELEASE ]]; then
13+
echo -n > prerelease.txt
1614
else
1715
# Use last commit date rather than build date to avoid ending up with builds for
1816
# different platforms having different version strings (and therefore producing different bytecode)
1917
# if the CI is triggered just before midnight.
20-
TZ=UTC git show --quiet --date="format-local:%Y.%-m.%-d" --format="${prerelease_source}.%cd" >prerelease.txt
18+
TZ=UTC git show --quiet --date="format-local:%Y.%-m.%-d" --format="${prerelease_source}.%cd" > prerelease.txt
2119
fi
2220

23-
if [ -n "$CIRCLE_SHA1" ]
24-
then
25-
echo -n "$CIRCLE_SHA1" >commit_hash.txt
21+
if [[ -n $CIRCLE_SHA1 ]]; then
22+
echo -n "$CIRCLE_SHA1" > commit_hash.txt
2623
fi
2724

2825
mkdir -p build
2926
cd build
3027

31-
# shellcheck disable=SC2166
32-
[ -n "$COVERAGE" -a "$CIRCLE_BRANCH" != release -a -z "$CIRCLE_TAG" ] && CMAKE_OPTIONS="$CMAKE_OPTIONS -DCOVERAGE=ON"
28+
[[ -n $COVERAGE && $CIRCLE_BRANCH != release && -z $CIRCLE_TAG ]] && CMAKE_OPTIONS="$CMAKE_OPTIONS -DCOVERAGE=ON"
3329

3430
# shellcheck disable=SC2086
3531
cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" $CMAKE_OPTIONS

scripts/ci/build_emscripten.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,16 @@ function build() {
4545

4646
cd "${ROOT_DIR}"
4747

48-
# shellcheck disable=SC2166
49-
if [[ "$CIRCLE_BRANCH" = release || -n "$CIRCLE_TAG" || -n "$FORCE_RELEASE" || "$(git tag --points-at HEAD 2>/dev/null)" == v* ]]
50-
then
51-
echo -n >prerelease.txt
48+
if [[ $CIRCLE_BRANCH == release || -n $CIRCLE_TAG || -n $FORCE_RELEASE || $(git tag --points-at HEAD 2> /dev/null) == v* ]]; then
49+
echo -n > prerelease.txt
5250
else
5351
# Use last commit date rather than build date to avoid ending up with builds for
5452
# different platforms having different version strings (and therefore producing different bytecode)
5553
# if the CI is triggered just before midnight.
56-
TZ=UTC git show --quiet --date="format-local:%Y.%-m.%-d" --format="${prerelease_source}.%cd" >prerelease.txt
54+
TZ=UTC git show --quiet --date="format-local:%Y.%-m.%-d" --format="${prerelease_source}.%cd" > prerelease.txt
5755
fi
58-
if [ -n "$CIRCLE_SHA1" ]
59-
then
60-
echo -n "$CIRCLE_SHA1" >commit_hash.txt
56+
if [[ -n $CIRCLE_SHA1 ]]; then
57+
echo -n "$CIRCLE_SHA1" > commit_hash.txt
6158
fi
6259

6360
# Disable warnings for unqualified `move()` calls, introduced and enabled by

scripts/create_source_tarball.sh

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,41 @@
1-
#!/usr/bin/env sh
2-
#
3-
4-
set -e
1+
#!/usr/bin/env bash
2+
set -euo pipefail
53

64
REPO_ROOT="$(dirname "$0")"/..
7-
(
8-
cd "$REPO_ROOT"
9-
version=$(scripts/get_version.sh)
10-
commithash=$(git rev-parse --short=8 HEAD)
11-
commitdate=$(git show --format=%ci HEAD | head -n 1 | cut - -b1-10 | sed -e 's/-0?/./' | sed -e 's/-0?/./')
5+
cd "$REPO_ROOT"
6+
version=$(scripts/get_version.sh)
7+
commit_hash=$(git rev-parse --short=8 HEAD)
8+
commit_date=$(git show --format=%ci HEAD | head -n 1 | cut - -b1-10 | sed -e 's/-0?/./' | sed -e 's/-0?/./')
9+
10+
# File exists and has zero size -> not a prerelease
11+
if [[ -e prerelease.txt && ! -s prerelease.txt ]]; then
12+
version_string="$version"
13+
else
14+
version_string="${version}-nightly-${commit_date}-${commit_hash}"
15+
fi
16+
17+
TEMPDIR=$(mktemp -d -t "solc-src-tarball-XXXXXX")
18+
SOLDIR="${TEMPDIR}/solidity_${version_string}/"
19+
mkdir "$SOLDIR"
20+
21+
# Ensure that submodules are initialized.
22+
git submodule update --init --recursive
23+
# Store the current source
24+
git checkout-index --all --prefix="$SOLDIR"
25+
# shellcheck disable=SC2016
26+
SOLDIR="$SOLDIR" git submodule foreach 'git checkout-index --all --prefix="${SOLDIR}/${sm_path}/"'
1227

13-
# file exists and has zero size -> not a prerelease
14-
if [ -e prerelease.txt ] && [ ! -s prerelease.txt ]
15-
then
16-
versionstring="$version"
17-
else
18-
versionstring="$version-nightly-$commitdate-$commithash"
19-
fi
28+
# Include the commit hash and prerelease suffix in the tarball
29+
echo "$commit_hash" > "${SOLDIR}/commit_hash.txt"
30+
[[ -e prerelease.txt && ! -s prerelease.txt ]] && cp prerelease.txt "${SOLDIR}/"
2031

21-
TEMPDIR=$(mktemp -d)
22-
SOLDIR="$TEMPDIR/solidity_$versionstring/"
23-
mkdir "$SOLDIR"
24-
# Ensure that submodules are initialized.
25-
git submodule update --init --recursive
26-
# Store the current source
27-
git checkout-index -a --prefix="$SOLDIR"
28-
# shellcheck disable=SC2016
29-
SOLDIR="$SOLDIR" git submodule foreach 'git checkout-index -a --prefix="$SOLDIR/$sm_path/"'
30-
# Store the commit hash
31-
echo "$commithash" > "$SOLDIR/commit_hash.txt"
32-
if [ -e prerelease.txt ] && [ ! -s prerelease.txt ]
33-
then
34-
cp prerelease.txt "$SOLDIR/"
35-
fi
36-
mkdir -p "$REPO_ROOT/upload"
37-
tar --owner 0 --group 0 -czf "$REPO_ROOT/upload/solidity_$versionstring.tar.gz" -C "$TEMPDIR" "solidity_$versionstring"
38-
rm -r "$TEMPDIR"
39-
)
32+
mkdir -p "$REPO_ROOT/upload"
33+
tar \
34+
--owner 0 \
35+
--group 0 \
36+
--create \
37+
--gzip \
38+
--file "${REPO_ROOT}/upload/solidity_${version_string}.tar.gz" \
39+
--directory "$TEMPDIR" \
40+
"solidity_${version_string}"
41+
rm -r "$TEMPDIR"

0 commit comments

Comments
 (0)