11[config ]
22skip_core_tasks = true
3+ default_to_workspace = false
34
45[env ]
56# The directory into which Twoliter has installed tools (e.g. buildsys,
@@ -15,6 +16,8 @@ BUILDSYS_IMAGES_DIR = "${BUILDSYS_BUILD_DIR}/images"
1516BUILDSYS_TOOLS_DIR = " ${BUILDSYS_ROOT_DIR}/tools"
1617BUILDSYS_SOURCES_DIR = " ${BUILDSYS_ROOT_DIR}/sources"
1718BUILDSYS_SBKEYS_DIR = " ${BUILDSYS_ROOT_DIR}/sbkeys"
19+ BUILDSYS_METADATA_DIR = " ${BUILDSYS_BUILD_DIR}/metadata"
20+ BUILDSYS_CARGO_METADATA_PATH = " ${BUILDSYS_METADATA_DIR}/cargo_metadata.json"
1821BUILDSYS_SBKEYS_PROFILE = { script = [' echo "${BUILDSYS_SBKEYS_PROFILE:-local}"' ] }
1922BUILDSYS_TIMESTAMP = { script = [" date +%s" ] }
2023BUILDSYS_VERSION_BUILD = { script = [" git describe --always --dirty --exclude '*' || echo 00000000" ] }
@@ -278,6 +281,7 @@ mkdir -p ${BUILDSYS_BUILD_DIR}
278281mkdir -p ${BUILDSYS_OUTPUT_DIR}
279282mkdir -p ${BUILDSYS_PACKAGES_DIR}
280283mkdir -p ${BUILDSYS_STATE_DIR}
284+ mkdir -p ${BUILDSYS_METADATA_DIR}
281285mkdir -p ${GO_MOD_CACHE}
282286'''
283287]
@@ -321,10 +325,12 @@ dependencies = ["setup"]
321325script_runner = " bash"
322326script = [
323327'''
324- for ws in sources variants; do
325- [ -d "${ws}" ] || continue
326- cargo fetch --locked --manifest-path ${ws}/Cargo.toml
327- done
328+ if [ -f "${BUILDSYS_SOURCES_DIR}/Cargo.toml" ]; then
329+ cargo fetch --locked --manifest-path "${BUILDSYS_SOURCES_DIR}/Cargo.toml"
330+ fi
331+
332+ cargo fetch --locked --manifest-path "${BUILDSYS_ROOT_DIR}/Cargo.toml"
333+
328334chmod -R o+r ${CARGO_HOME}
329335'''
330336]
@@ -727,9 +733,26 @@ docker run --rm \
727733'''
728734]
729735
736+ # Reads the project's workspace Cargo dependency graph to a json file. Needed by buildsys when
737+ # building packages, kits and variants.
738+ [tasks .cargo-metadata ]
739+ dependencies = [" setup" ]
740+ script_runner = " bash"
741+ script = [
742+ '''
743+ rm -f "${BUILDSYS_CARGO_METADATA_PATH}"
744+ cargo metadata \
745+ --format-version 1 \
746+ --manifest-path "${BUILDSYS_ROOT_DIR}/Cargo.toml" \
747+ --offline \
748+ --all-features \
749+ > "${BUILDSYS_CARGO_METADATA_PATH}"
750+ '''
751+ ]
752+
730753# Builds a package including its build-time and runtime dependency packages.
731754[tasks .build-package ]
732- dependencies = [" check-cargo-version" , " fetch-sdk" , " publish-setup" , " fetch-licenses" ]
755+ dependencies = [" check-cargo-version" , " fetch-sdk" , " publish-setup" , " fetch-licenses" , " cargo-metadata " ]
733756script_runner = " bash"
734757script = [
735758'''
@@ -757,13 +780,12 @@ cargo build \
757780 ${CARGO_BUILD_ARGS} \
758781 ${CARGO_MAKE_CARGO_ARGS} \
759782 ${CARGO_MAKE_CARGO_LIMIT_JOBS} \
760- --manifest-path "variants/Cargo.toml" \
761- --package "${PACKAGE}"
783+ --manifest-path "${BUILDSYS_ROOT_DIR}/packages/${PACKAGE}/Cargo.toml"
762784'''
763785]
764786
765787[tasks .build-variant ]
766- dependencies = [" fetch-sdk" , " build-sbkeys" , " publish-setup" ]
788+ dependencies = [" fetch-sdk" , " build-sbkeys" , " publish-setup" , " cargo-metadata " ]
767789script = [
768790'''
769791export PATH="${TWOLITER_TOOLS_DIR}:${PATH}"
@@ -777,7 +799,7 @@ export BUILDSYS_VARIANT_FLAVOR="${BUILDSYS_VARIANT_FLAVOR}"
777799
778800# Save built artifacts for each architecture. We don't set this everywhere
779801# because we build host tools with cargo as well, like buildsys and pubsys.
780- export CARGO_TARGET_DIR=${BUILDSYS_ROOT_DIR}/variants/ target/${BUILDSYS_ARCH}
802+ export CARGO_TARGET_DIR=${BUILDSYS_ROOT_DIR}/target/${BUILDSYS_ARCH}
781803
782804rm -rf "${BUILDSYS_OUTPUT_DIR}/latest"
783805cargo build \
@@ -1471,16 +1493,20 @@ dependencies = [
14711493 " clean-repos" ,
14721494 " clean-state" ,
14731495 " clean-tools" ,
1496+ " clean-metadata" ,
14741497]
14751498
14761499[tasks .clean-sources ]
14771500script_runner = " bash"
14781501script = [
14791502'''
1480- for ws in sources; do
1481- [ -d "${ws}" ] || continue
1482- cargo clean --manifest-path ${ws}/Cargo.toml
1483- done
1503+
1504+ if [ -f "${BUILDSYS_SOURCES_DIR}/Cargo.toml" ]; then
1505+ cargo clean --manifest-path "${BUILDSYS_SOURCES_DIR}/Cargo.toml"
1506+ fi
1507+
1508+ cargo clean --manifest-path "${BUILDSYS_ROOT_DIR}/Cargo.toml"
1509+
14841510rm -f ${BUILDSYS_TOOLS_DIR}/bin/*
14851511'''
14861512]
@@ -1489,10 +1515,6 @@ rm -f ${BUILDSYS_TOOLS_DIR}/bin/*
14891515script_runner = " bash"
14901516script = [
14911517'''
1492- for ws in variants; do
1493- [ -d "${ws}" ] || continue
1494- cargo clean --manifest-path ${ws}/Cargo.toml
1495- done
14961518rm -rf ${BUILDSYS_PACKAGES_DIR}
14971519'''
14981520]
@@ -1531,6 +1553,14 @@ fi
15311553'''
15321554]
15331555
1556+ [tasks .clean-metadata ]
1557+ script_runner = " bash"
1558+ script = [
1559+ '''
1560+ rm -rf "${BUILDSYS_METADATA_DIR}"
1561+ '''
1562+ ]
1563+
15341564# Deletes cached code used for Bottlerocket builds
15351565[tasks .purge-cache ]
15361566dependencies = [
0 commit comments