Skip to content

Commit e403cb2

Browse files
committed
Build also for aarch64
1 parent 0dcd7ea commit e403cb2

File tree

8 files changed

+60
-42
lines changed

8 files changed

+60
-42
lines changed

scripts/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
22
set -euxo pipefail
33

4-
devcontainer build --workspace-folder src/s-core-devcontainer --image-name ghcr.io/eclipse-score/devcontainer:latest --cache-from ghcr.io/eclipse-score/devcontainer
4+
devcontainer build --platform linux/aarch64 --workspace-folder src/s-core-devcontainer --image-name ghcr.io/eclipse-score/devcontainer:latest --cache-from ghcr.io/eclipse-score/devcontainer
5+
devcontainer build --platform linux/amd64 --workspace-folder src/s-core-devcontainer --image-name ghcr.io/eclipse-score/devcontainer:latest --cache-from ghcr.io/eclipse-score/devcontainer

src/s-core-devcontainer/.devcontainer/devcontainer-lock.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"features": {
3+
"ghcr.io/devcontainers-community/features/bazel": {
4+
"version": "1.2.2",
5+
"resolved": "ghcr.io/devcontainers-community/features/bazel@sha256:587cd6cdd290cfb98c9ba8605a8a27f24fc1e9c736cdd03da099385863386331",
6+
"integrity": "sha256:587cd6cdd290cfb98c9ba8605a8a27f24fc1e9c736cdd03da099385863386331"
7+
},
38
"ghcr.io/devcontainers-community/features/llvm": {
49
"version": "3.2.0",
510
"resolved": "ghcr.io/devcontainers-community/features/llvm@sha256:4f464ab97a59439286a55490b55ba9851616f6f76ac3025e134127ac08ad79e2",

src/s-core-devcontainer/.devcontainer/devcontainer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
// Installs the latest version from the Distribution
1414
"autoPull": "false" // do not automatically pull LFS files when creating the container
1515
},
16+
"ghcr.io/devcontainers-community/features/bazel": {
17+
"bazelisk_version": "v1.27.0",
18+
"buildifier_version": "v8.2.1"
19+
},
1620
"ghcr.io/devcontainers/features/common-utils": {
1721
// Installs latest version from the Distribution
1822
"installZsh": "false",

src/s-core-devcontainer/.devcontainer/s-core-local/install.sh

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ DEBIAN_FRONTEND=noninteractive
1515
# Read tool versions + metadata into environment variables
1616
. /devcontainer/features/s-core-local/versions.sh
1717

18+
ARCHITECTURE=$(dpkg --print-architecture)
19+
1820
apt-get update
1921

2022
# INSTALL CONTAINER BUILD DEPENDENCIES
@@ -28,46 +30,43 @@ apt-get install -y graphviz="${graphviz_version}*"
2830
# Protobuf compiler, via APT (needed by FEO)
2931
apt-get install -y protobuf-compiler="${protobuf_compiler_version}*"
3032

31-
# Bazel, via APT
32-
# - ghcr.io/devcontainers-community/features/bazel uses bazelisk, which has a few problems:
33-
# - It does not install bash autocompletion.
34-
# - The bazel version is not pinned, which is required to be reproducible and to have coordinated, tested tool updates.
35-
# - In general, pre-built containers *shall not* download "more tools" from the internet.
36-
# This is an operational risk (security, availability); it makes the build non-reproducible,
37-
# and it prevents the container from working in air-gapped environments.
38-
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel-archive-keyring.gpg
39-
mv bazel-archive-keyring.gpg /usr/share/keyrings
40-
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list
41-
apt-get update
42-
apt-get install -y bazel=${bazel_version}
43-
44-
# Buildifier, directly from GitHub (apparently no APT repository available)
45-
# The version is pinned to a specific release, and the SHA256 checksum is provided by the devcontainer-features.json file.
46-
curl -L "https://github.com/bazelbuild/buildtools/releases/download/v${buildifier_version}/buildifier-linux-amd64" -o /usr/local/bin/buildifier
47-
echo "${buildifier_amd64_sha256} /usr/local/bin/buildifier" | sha256sum -c - || exit -1
48-
chmod +x /usr/local/bin/buildifier
49-
5033
# Starlark Language Server, directly from GitHub (apparently no APT repository available)
51-
curl -L "https://github.com/withered-magic/starpls/releases/download/v${starpls_version}/starpls-linux-amd64" -o /usr/local/bin/starpls
52-
echo "${starpls_amd64_sha256} /usr/local/bin/starpls" | sha256sum -c - || exit -1
34+
STARPLS_VARIANT="amd64"
35+
SHA256SUM="${starpls_amd64_sha256}"
36+
if [ "${ARCHITECTURE}" = "arm64" ]; then
37+
STARPLS_VARIANT="aarch64"
38+
SHA256SUM="${starpls_arm64_sha256}"
39+
fi
40+
curl -L "https://github.com/withered-magic/starpls/releases/download/v${starpls_version}/starpls-linux-${STARPLS_VARIANT}" -o /usr/local/bin/starpls
41+
echo "${SHA256SUM} /usr/local/bin/starpls" | sha256sum -c - || exit -1
5342
chmod +x /usr/local/bin/starpls
5443

5544
# Code completion for C++ code of Bazel projects
5645
# (see https://github.com/kiron1/bazel-compile-commands)
5746
# The version is pinned to a specific release, and the SHA256 checksum is provided by the devcontainer-features.json file.
5847
source /etc/lsb-release
59-
curl -L "https://github.com/kiron1/bazel-compile-commands/releases/download/v${bazel_compile_commands_version}/bazel-compile-commands_${bazel_compile_commands_version}-${DISTRIB_CODENAME}_amd64.deb" -o /tmp/bazel-compile-commands.deb
48+
curl -L "https://github.com/kiron1/bazel-compile-commands/releases/download/v${bazel_compile_commands_version}/bazel-compile-commands_${bazel_compile_commands_version}-${DISTRIB_CODENAME}_${ARCHITECTURE}.deb" -o /tmp/bazel-compile-commands.deb
6049
# Extract correct sha256 for current DISTRIB_CODENAME and check
61-
echo "${bazel_compile_commands_amd64_sha256} /tmp/bazel-compile-commands.deb" | sha256sum -c - || exit -1
50+
SHA256SUM="${bazel_compile_commands_amd64_sha256}"
51+
if [ "${ARCHITECTURE}" = "arm64" ]; then
52+
SHA256SUM="${bazel_compile_commands_arm64_sha256}"
53+
fi
54+
echo "${SHA256SUM} /tmp/bazel-compile-commands.deb" | sha256sum -c - || exit -1
6255
apt-get install -y --no-install-recommends --fix-broken /tmp/bazel-compile-commands.deb
6356
rm /tmp/bazel-compile-commands.deb
6457

6558
# Code completion for Rust code of Bazel projects (language server part)
6659
# (see https://bazelbuild.github.io/rules_rust/rust_analyzer.html and https://rust-analyzer.github.io/book/rust_analyzer_binary.html)
6760
# The version is pinned to a specific release, and the SHA256 checksum is provided by the devcontainer-features.json file.
6861
# NOTE: For an unknown reason, rust-analyzer uses dates for downloading of releases, while the executable reports an actual release.
69-
curl -L https://github.com/rust-lang/rust-analyzer/releases/download/${rust_analyzer_date}/rust-analyzer-x86_64-unknown-linux-gnu.gz > /tmp/rust-analyzer.gz
70-
echo "${rust_analyzer_amd64_sha256} /tmp/rust-analyzer.gz" | sha256sum -c - || exit -1
62+
RUST_ANALYZER_VARIANT="x86_64"
63+
SHA256SUM="${rust_analyzer_amd64_sha256}"
64+
if [ "${ARCHITECTURE}" = "arm64" ]; then
65+
RUST_ANALYZER_VARIANT="aarch64"
66+
SHA256SUM="${rust_analyzer_arm64_sha256}"
67+
fi
68+
curl -L https://github.com/rust-lang/rust-analyzer/releases/download/${rust_analyzer_date}/rust-analyzer-${RUST_ANALYZER_VARIANT}-unknown-linux-gnu.gz > /tmp/rust-analyzer.gz
69+
echo "${SHA256SUM} /tmp/rust-analyzer.gz" | sha256sum -c - || exit -1
7170
gunzip -d /tmp/rust-analyzer.gz
7271
mv /tmp/rust-analyzer /usr/local/bin/rust-analyzer
7372
chmod +x /usr/local/bin/rust-analyzer

src/s-core-devcontainer/.devcontainer/s-core-local/tests/test_default.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ check "validate graphviz has the correct version" bash -c "dpkg -s graphviz | gr
1313
# Other build-related tools
1414
check "validate protoc is working and has the correct version" bash -c "protoc --version | grep 'libprotoc ${protobuf_compiler_version}'"
1515

16-
# Bazel and related tools
17-
check "validate bazel is working and has the correct version" bash -c "bazel version | grep '${bazel_version}'"
18-
check "validate buildifier is working and has the correct version" bash -c "buildifier --version | grep '${buildifier_version}'"
16+
# Bazel-related tools
1917
check "validate starpls is working and has the correct version" bash -c "starpls version | grep '${starpls_version}'"
2018
check "validate bazel-compile-commands is working and has the correct version" bash -c "bazel-compile-commands --version 2>&1 | grep '${bazel_compile_commands_version}'"
2119

src/s-core-devcontainer/.devcontainer/s-core-local/versions.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
curl -L "https://github.com/mikefarah/yq/releases/download/v4.47.1/yq_linux_amd64" -o /tmp/yq
5-
echo "0fb28c6680193c41b364193d0c0fc4a03177aecde51cfc04d506b1517158c2fb /tmp/yq" | sha256sum -c - || exit -1
4+
ARCHITECTURE=$(dpkg --print-architecture)
5+
VERSION="v4.47.2"
6+
7+
SHA256_FIELD="1bb99e1019e23de33c7e6afc23e93dad72aad6cf2cb03c797f068ea79814ddb0" # Default to amd64
8+
if [ "${ARCHITECTURE}" = "arm64" ]; then
9+
SHA256_FIELD="05df1f6aed334f223bb3e6a967db259f7185e33650c3b6447625e16fea0ed31f"
10+
fi
11+
12+
curl -L "https://github.com/mikefarah/yq/releases/download/${VERSION}/yq_linux_${ARCHITECTURE}" -o /tmp/yq
13+
echo "${SHA256_FIELD} /tmp/yq" | sha256sum -c - || exit -1
614
chmod +x /tmp/yq
715

816
# Read tool versions and metadata into environment variables

src/s-core-devcontainer/.devcontainer/s-core-local/versions.yaml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
bazel:
2-
version: 8.3.0
3-
41
graphviz:
52
version: 2.42.2
63

@@ -13,21 +10,18 @@ qemu_system_arm:
1310
sshpass:
1411
version: 1.09
1512

16-
buildifier:
17-
version: 8.2.1
18-
amd64:
19-
# The following sha256sum is for the binary buildifier-linux-amd64
20-
# from the GitHub release page of buildtools
21-
# It is generated by running 'sha256sum buildifier-linux-amd64'
22-
sha256: 6ceb7b0ab7cf66fceccc56a027d21d9cc557a7f34af37d2101edb56b92fcfa1a
23-
2413
starpls:
2514
version: 0.1.22
2615
amd64:
2716
# The following sha256sum is for the binary starpls-linux-amd64
2817
# from the GitHub release page of starpls
2918
# It is generated by running 'sha256sum starpls-linux-amd64'
3019
sha256: 7c661cdde0d1c026665086d07523d825671e29056276681616bb32d0273c5eab
20+
arm64:
21+
# The following sha256sum is for the binary starpls-linux-arm64
22+
# from the GitHub release page of starpls
23+
# It is generated by running 'sha256sum starpls-linux-arm64'
24+
sha256: 55877ec4c3ff03e1d90d59c76f69a3a144b6c29688747c8ac4d77993e2eef1ad
3125

3226
bazel_compile_commands:
3327
version: 0.18.0
@@ -48,3 +42,8 @@ rust_analyzer:
4842
# from the GitHub release page of rust-analyzer
4943
# It is generated by running 'sha256sum rust-analyzer-x86_64-unknown-linux-gnu.gz'
5044
sha256: 487fb1cb99e567fd6b818cc88a7c1452d5260da57dbc171fc1359a4b604348ae
45+
arm64:
46+
# The following sha256sum is for the binary rust-analyzer-aarch64-unknown-linux-gnu.gz
47+
# from the GitHub release page of rust-analyzer
48+
# It is generated by running 'sha256sum rust-analyzer-aarch64-unknown-linux-gnu.gz'
49+
sha256: c738e00a5caa712f9d9c8f81f9661884c7108ef94db6df48985c11fe3c2695bd

src/s-core-devcontainer/test-project/test.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ check "validate clang-format is working and has the correct version" bash -c "cl
1616
check "validate clang-tidy is working and has the correct version" bash -c "clang-tidy --version | grep '20.1.8'"
1717
check "validate clang is working and has the correct version" bash -c "clang --version | grep '20.1.8'"
1818

19+
# Bazel tooling
20+
check "validate bazelisk is working and has the correct version" bash -c "bazel --version | grep '1.27.0'"
21+
check "validate buildifier is working and has the correct version" bash -c "buildifier --version | grep '8.2.1'"
22+
1923
# Tests from the local s-core-local feature
2024
source /devcontainer/features/s-core-local/tests/test_default.sh
2125

0 commit comments

Comments
 (0)