forked from eclipse-kuksa/kuksa-databroker
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-all-targets-cli.sh
executable file
·76 lines (65 loc) · 2.8 KB
/
build-all-targets-cli.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
#
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# Building all currently supported targets for databroker-cli.
# Uses cross for cross-compiling. Needs to be executed
# before docker build, as docker collects the artifacts
# created by this script
# this needs the have cross, cargo-license and createbom dependencies installed
#
# SPDX-License-Identifier: Apache-2.0
# exit on error, to not waste any time
set -e
SCRIPT_PATH=$(realpath "$0")
SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
# We need to clean this folder in target, otherwise we get weird side
# effects building for different archs, complaining libc crate can not find
# GLIBC, i.e
# Compiling libc v0.2.149
#error: failed to run custom build command for `libc v0.2.149`
#
#Caused by:
# process didn't exit successfully: `/target/release/build/libc-2dd22ab6b5fb9fd2/#build-script-build` (exit status: 1)
# --- stderr
# /target/release/build/libc-2dd22ab6b5fb9fd2/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.29' not found (required by /target/release/build/libc-2dd22ab6b5fb9fd2/build-script-build)
#
# It seems cross/cargo is reusing something from previous builds it shouldn't.
# the finished artifact resides in ../target/x86_64-unknown-linux-musl/release
# so deleting the temporary files in target/releae is no problem
cleanup_target_release_dir() {
echo "Clean up target dir..."
rm -rf "$SCRIPT_DIR/target/release"
}
# Create thirdparty bom
rm -rf "$SCRIPT_DIR/databroker/thirdparty" || true
pushd createbom/
python3 createbom.py ../databroker-cli
popd
# Building AMD46
echo "Building AMD64"
cleanup_target_release_dir
cross build --target x86_64-unknown-linux-musl --bin databroker-cli --release
# Building ARM64
echo "Building ARM64"
cleanup_target_release_dir
cross build --target aarch64-unknown-linux-musl --bin databroker-cli --release
# Build RISCV64, this is a glibc based build, as musl is not
# yet supported
echo "Building RISCV64"
cleanup_target_release_dir
cross build --target riscv64gc-unknown-linux-gnu --bin databroker-cli --release
# Prepare dist folders
echo "Prepare amd64 dist folder"
mkdir -p "$SCRIPT_DIR/dist/amd64"
cp "$SCRIPT_DIR/target/x86_64-unknown-linux-musl/release/databroker-cli" "$SCRIPT_DIR/dist/amd64"
cp -r "$SCRIPT_DIR/databroker-cli/thirdparty" "$SCRIPT_DIR/dist/amd64"
echo "Prepare arm64 dist folder"
mkdir -p "$SCRIPT_DIR/dist/arm64"
cp "$SCRIPT_DIR/target/aarch64-unknown-linux-musl/release/databroker-cli" "$SCRIPT_DIR/dist/arm64"
cp -r "$SCRIPT_DIR/databroker-cli/thirdparty" "$SCRIPT_DIR/dist/arm64"
echo "Prepare riscv64 dist folder"
mkdir -p "$SCRIPT_DIR/dist/riscv64"
cp "$SCRIPT_DIR/target/riscv64gc-unknown-linux-gnu/release/databroker-cli" "$SCRIPT_DIR/dist/riscv64"
cp -r "$SCRIPT_DIR/databroker-cli/thirdparty" "$SCRIPT_DIR/dist/riscv64"