2017-06-14 23:43:16 +00:00
|
|
|
################################################################################
|
|
|
|
# Build all of the platforms manually since the `all_platforms' target
|
|
|
|
# doesn't preserve all of the build outputs and overrides CFLAGS.
|
|
|
|
set -e
|
|
|
|
set -u
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Prevent a warning from shellcheck:
|
|
|
|
out=${out:-/tmp}
|
|
|
|
|
|
|
|
################################################################################
|
2019-08-14 00:05:34 +00:00
|
|
|
export MAKEFLAGS="\
|
treewide: drop -l$NIX_BUILD_CORES
Passing `-l$NIX_BUILD_CORES` improperly limits the overall system load.
For a build machine which is configured to run `$B` builds where each
build gets `total cores / B` cores (`$C`), passing `-l $C` to make will
improperly limit the load to `$C` instead of `$B * $C`.
This effect becomes quite pronounced on machines with 80 cores, with
40 simultaneous builds and a cores limit of 2. On a machine with this
configuration, Nix will run 40 builds and make will limit the overall
system load to approximately 2. A build machine with this many cores
can happily run with a load approaching 80.
A non-solution is to oversubscribe the machine, by picking a larger
`$C`. However, there is no way to divide the number of cores in a way
which fairly subdivides the available cores when `$B` is greater than
1.
There has been exploration of passing a jobserver in to the sandbox,
or sharing a jobserver between all the builds. This is one option, but
relatively complicated and only supports make. Lots of other software
uses its own implementation of `-j` and doesn't support either `-l` or
the Make jobserver.
For the case of an interactive user machine, the user should limit
overall system load using `$B`, `$C`, and optionally systemd's
cpu/network/io limiting features.
Making this change should significantly improve the utilization of our
build farm, and improve the throughput of Hydra.
2022-09-22 15:17:14 +00:00
|
|
|
${enableParallelBuilding:+-j${NIX_BUILD_CORES}}"
|
2017-06-14 23:43:16 +00:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
PRODUCTS="blackmagic.bin blackmagic.hex blackmagic_dfu.bin blackmagic_dfu.hex"
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
make_platform() {
|
|
|
|
echo "Building for hardware platform $1"
|
|
|
|
|
|
|
|
make clean
|
|
|
|
make PROBE_HOST="$1"
|
|
|
|
|
2020-08-09 08:46:01 +00:00
|
|
|
if [ "$1" = "hosted" ]; then
|
2017-06-14 23:43:16 +00:00
|
|
|
install -m 0555 blackmagic "$out/bin"
|
|
|
|
fi
|
|
|
|
|
|
|
|
for f in $PRODUCTS; do
|
|
|
|
if [ -r "$f" ]; then
|
|
|
|
mkdir -p "$out/firmware/$1"
|
|
|
|
install -m 0444 "$f" "$out/firmware/$1"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Start by building libopencm3:
|
|
|
|
make -C libopencm3
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# And now all of the platforms:
|
|
|
|
cd src
|
|
|
|
|
2020-02-01 17:40:01 +00:00
|
|
|
mkdir -p "$out/bin"
|
|
|
|
|
2017-06-14 23:43:16 +00:00
|
|
|
for platform in platforms/*/Makefile.inc; do
|
|
|
|
probe=$(basename "$(dirname "$platform")")
|
|
|
|
make_platform "$probe"
|
|
|
|
done
|