5d04ddc593
The driver-list filter ran `grep -R "^name = \"$bin\"$" $COOKBOOK_SOURCE` once PER bin (~40 bins). $COOKBOOK_SOURCE is local/sources/base, whose target/ build tree is ~8.7 GB, so each grep re-scanned gigabytes and the whole loop scanned hundreds of GB — a very slow build phase. Collect the workspace's crate names ONCE from Cargo.toml files (skipping target/ via --exclude-dir), into a bash associative array, then do an O(1) membership check per bin. Verified equivalent (same bins selected) and near-instant: the single scan of local/sources/base completes in ~0.02s vs minutes for the per-bin recursive greps.
205 lines
6.5 KiB
TOML
205 lines
6.5 KiB
TOML
# Use the Red Bear base fork at local/sources/base. This is the durable
|
|
# source of truth for the Red Bear OS base build (drivers, daemons,
|
|
# initfs, etc). Upstream + overlay patches proved unmaintainable due
|
|
# to constant upstream drift — switching to a fork matches how
|
|
# Redox kernel, relibc, and other core components are already built.
|
|
#
|
|
# To import new commits from upstream redox-os/base.git:
|
|
# cd local/sources/base
|
|
# git remote add upstream https://gitlab.redox-os.org/redox-os/base.git
|
|
# git fetch upstream
|
|
# git merge upstream/master --no-ff
|
|
# # resolve conflicts, then commit
|
|
[source]
|
|
path = "../../../local/sources/base"
|
|
upstream = "https://gitlab.redox-os.org/redox-os/base.git"
|
|
branch = "0.2.3"
|
|
|
|
[package]
|
|
version = "0.3.1"
|
|
installs = [
|
|
"/lib/pcid.d/ac97d.toml",
|
|
"/lib/pcid.d/e1000d.toml",
|
|
"/lib/pcid.d/ihdad.toml",
|
|
"/lib/pcid.d/ihdgd.toml",
|
|
"/lib/pcid.d/ixgbed.toml",
|
|
"/lib/pcid.d/rtl8139d.toml",
|
|
"/lib/pcid.d/rtl8168d.toml",
|
|
"/lib/pcid.d/vboxd.toml",
|
|
"/lib/pcid.d/virtio-netd.toml",
|
|
"/lib/pcid.d/xhcid.toml",
|
|
"/usr/bin/audiod",
|
|
"/usr/bin/dhcpd",
|
|
"/usr/bin/dw-acpi-i2cd",
|
|
"/usr/bin/gpiod",
|
|
"/usr/bin/i2cd",
|
|
"/usr/bin/i2c-gpio-expanderd",
|
|
"/usr/bin/i2c-hidd",
|
|
"/usr/bin/fbcond",
|
|
"/usr/bin/inputd",
|
|
"/usr/bin/intel-gpiod",
|
|
"/usr/bin/ipcd",
|
|
"/usr/bin/netstack",
|
|
"/usr/bin/pcid",
|
|
"/usr/bin/pcid-spawner",
|
|
"/usr/bin/ptyd",
|
|
"/usr/bin/redoxerd",
|
|
"/usr/bin/smolnetd",
|
|
"/usr/bin/ucsid",
|
|
"/usr/lib/drivers/ac97d",
|
|
"/usr/lib/drivers/amd-mp2-i2cd",
|
|
"/usr/lib/drivers/e1000d",
|
|
"/usr/lib/drivers/ihdad",
|
|
"/usr/lib/drivers/ihdgd",
|
|
"/usr/lib/drivers/intel-lpss-i2cd",
|
|
"/usr/lib/drivers/intel-thc-hidd",
|
|
"/usr/lib/drivers/ixgbed",
|
|
"/usr/lib/drivers/rtl8139d",
|
|
"/usr/lib/drivers/rtl8168d",
|
|
"/usr/lib/drivers/sb16d",
|
|
"/usr/lib/drivers/thermald",
|
|
"/usr/lib/drivers/usbctl",
|
|
"/usr/lib/drivers/usbhidd",
|
|
"/usr/lib/drivers/usbhubd",
|
|
"/usr/lib/drivers/usbscsid",
|
|
"/usr/lib/drivers/vboxd",
|
|
"/usr/lib/drivers/virtio-gpud",
|
|
"/usr/lib/drivers/virtio-netd",
|
|
"/usr/lib/drivers/xhcid",
|
|
"/usr/lib/init.d/00_base.target",
|
|
"/usr/lib/init.d/00_fbcond.service",
|
|
"/usr/lib/init.d/00_ipcd.service",
|
|
"/usr/lib/init.d/00_pcid-spawner.service",
|
|
"/usr/lib/init.d/00_ptyd.service",
|
|
"/usr/lib/init.d/00_sudo.service",
|
|
"/usr/lib/init.d/00_tmp",
|
|
"/usr/lib/init.d/05_boot_essential.target",
|
|
"/usr/lib/init.d/10_dhcpd.service",
|
|
"/usr/lib/init.d/10_net.target",
|
|
"/usr/lib/init.d/10_smolnetd.service",
|
|
"/usr/lib/init.d/12_boot_late.target",
|
|
"/usr/lib/init.d/12_dbus.service",
|
|
"/usr/lib/init.d/13_seatd.service",
|
|
"/usr/lib/init.d/13_sessiond.service",
|
|
"/usr/lib/init.d/20_audiod.service",
|
|
"/usr/lib/init.d/29_activate_console.service",
|
|
"/usr/lib/init.d/30_console.service",
|
|
"/usr/lib/init.d/30_thermald.service",
|
|
"/usr/lib/init.d/31_debug_console.service",
|
|
]
|
|
|
|
[build]
|
|
template = "custom"
|
|
script = """
|
|
mkdir -pv "${COOKBOOK_STAGE}/usr/bin"
|
|
for package in audiod ipcd ptyd dhcpd; do
|
|
"${COOKBOOK_CARGO}" build \
|
|
--manifest-path "${COOKBOOK_SOURCE}/${package}/Cargo.toml" \
|
|
--target "${TARGET}" \
|
|
${build_flags}
|
|
cp -v \
|
|
"target/${TARGET}/${build_type}/${package}" \
|
|
"${COOKBOOK_STAGE}/usr/bin/${package}"
|
|
done
|
|
|
|
"${COOKBOOK_CARGO}" build \
|
|
--manifest-path "${COOKBOOK_SOURCE}/netstack/Cargo.toml" \
|
|
--target "${TARGET}" \
|
|
${build_flags}
|
|
cp -v \
|
|
"target/${TARGET}/${build_type}/netstack" \
|
|
"${COOKBOOK_STAGE}/usr/bin/netstack"
|
|
cp -v \
|
|
"target/${TARGET}/${build_type}/netstack" \
|
|
"${COOKBOOK_STAGE}/usr/bin/smolnetd"
|
|
|
|
# Drivers that are built on all architectures, and NOT in drivers-initfs
|
|
BINS=(
|
|
gpiod
|
|
i2c-gpio-expanderd
|
|
intel-gpiod
|
|
amd-mp2-i2cd
|
|
dw-acpi-i2cd
|
|
e1000d
|
|
ihdad
|
|
ihdgd
|
|
i2c-hidd
|
|
intel-thc-hidd
|
|
intel-lpss-i2cd
|
|
ixgbed
|
|
pcid
|
|
pcid-spawner
|
|
rtl8139d
|
|
rtl8168d
|
|
usbctl
|
|
usbhidd
|
|
thermald
|
|
usbhubd
|
|
ucsid
|
|
usbscsid
|
|
virtio-gpud
|
|
virtio-netd
|
|
xhcid
|
|
i2cd
|
|
inputd
|
|
fbcond
|
|
redoxerd
|
|
)
|
|
|
|
# Add additional drivers to the list to build, that are not in drivers-initfs
|
|
# depending on the target architecture
|
|
case "${TARGET}" in
|
|
i586-unknown-redox | i686-unknown-redox | x86_64-unknown-redox)
|
|
BINS+=(ac97d sb16d vboxd)
|
|
;;
|
|
*)
|
|
;;
|
|
esac
|
|
|
|
#Build each driver in the list
|
|
mkdir -pv "${COOKBOOK_STAGE}/usr/bin" "${COOKBOOK_STAGE}/usr/lib/drivers"
|
|
export CARGO_PROFILE_RELEASE_OPT_LEVEL=s
|
|
export CARGO_PROFILE_RELEASE_PANIC=abort
|
|
# Only build drivers that actually have source Cargo.toml entries.
|
|
# Collect the workspace's crate names ONCE from Cargo.toml files, skipping the
|
|
# multi-GB target/ build trees. The previous code ran a full recursive grep of
|
|
# the entire source (including target/, ~8.7 GB) for EVERY bin (~40 of them),
|
|
# re-scanning gigabytes per entry — extremely slow. One scan + O(1) membership
|
|
# lookup is equivalent and near-instant.
|
|
declare -A HAVE_CRATE=()
|
|
while IFS= read -r crate_name
|
|
do
|
|
HAVE_CRATE["${crate_name}"]=1
|
|
done < <(grep -Rhs --include=Cargo.toml --exclude-dir=target '^name = ' "${COOKBOOK_SOURCE}" | sed -E 's/^name = "([^"]+)".*/\\1/')
|
|
EXISTING_BINS=()
|
|
for bin in "${BINS[@]}"
|
|
do
|
|
if [[ -n "${HAVE_CRATE[${bin}]:-}" ]]; then
|
|
EXISTING_BINS+=("${bin}")
|
|
fi
|
|
done
|
|
"${COOKBOOK_CARGO}" build ${build_flags} \
|
|
--manifest-path "${COOKBOOK_SOURCE}/Cargo.toml" \
|
|
--target "${TARGET}" \
|
|
$(for bin in "${EXISTING_BINS[@]}"; do echo "-p" "${bin}"; done)
|
|
for bin in "${EXISTING_BINS[@]}"
|
|
do
|
|
if [[ "${bin}" == "gpiod" || "${bin}" == "i2c-gpio-expanderd" || "${bin}" == "intel-gpiod" || "${bin}" == "i2cd" || "${bin}" == "dw-acpi-i2cd" || "${bin}" == "i2c-hidd" || "${bin}" == "inputd" || "${bin}" == "fbcond" || "${bin}" == "pcid" || "${bin}" == "pcid-spawner" || "${bin}" == "redoxerd" || "${bin}" == "ucsid" ]]; then
|
|
mkdir -pv "${COOKBOOK_STAGE}/usr/bin"
|
|
cp -v "target/${TARGET}/${build_type}/${bin}" "${COOKBOOK_STAGE}/usr/bin"
|
|
else
|
|
cp -v "target/${TARGET}/${build_type}/${bin}" "${COOKBOOK_STAGE}/usr/lib/drivers"
|
|
fi
|
|
done
|
|
|
|
mkdir -pv "${COOKBOOK_STAGE}/lib/pcid.d"
|
|
find "${COOKBOOK_SOURCE}/drivers" -maxdepth 3 -type f -name 'config.toml' | while read conf
|
|
do
|
|
driver="$(basename "$(dirname "$conf")")"
|
|
cp -v "$conf" "${COOKBOOK_STAGE}/lib/pcid.d/$driver.toml"
|
|
done
|
|
|
|
mkdir -pv "${COOKBOOK_STAGE}/usr/lib/init.d"
|
|
cp -v "${COOKBOOK_SOURCE}/init.d"/* "${COOKBOOK_STAGE}/usr/lib/init.d/"
|
|
"""
|