fayalite-deps/build-container.sh
Jacob Lifshay e48685b5fb
Some checks failed
/ build (push) Failing after 8s
WIP creating build script
2025-10-12 03:32:40 -07:00

137 lines
No EOL
3.9 KiB
Bash
Executable file

#!/bin/bash
# SPDX-License-Identifier: LGPL-3.0-or-later
# See Notices.txt for copyright information
set -e
function build_in_container()
{
if [[ "$0" != "/build.sh" ]]; then
echo "you shouldn't run this outside of the container being built" >&2
return 1
fi
set -xe
mkdir -p /build
cd /build
apt update -qq
apt install -qqy \
bison \
build-essential \
ccache \
clang \
cmake \
cvc5 \
default-jre-headless \
flex \
g++ \
gawk \
git \
libantlr4-runtime-dev \
libboost-filesystem-dev \
libboost-iostreams-dev \
libboost-program-options-dev \
libboost-python-dev \
libboost-system-dev \
libboost-thread-dev \
libeigen3-dev \
libffi-dev \
libreadline-dev \
lld \
openfpgaloader \
pkg-config \
python3 \
python3-click \
python3-venv \
tcl-dev \
uuid-dev \
wget \
zlib1g-dev
update-ccache-symlinks # ccache seems to miss cc/c++ when installing, try to fix that here
export PATH="/usr/lib/ccache:$PATH"
python3 -m venv /opt/fayalite-deps/venv
source /opt/fayalite-deps/venv/bin/activate
git clone https://github.com/SymbiFlow/prjxray.git /build/prjxray
cd /build/prjxray
git checkout c9f02d8576042325425824647ab5555b1bc77833
git submodule update --init --recursive
mkdir -p build
cd build
cmake ..
make -j$(nproc)
make install
cd ..
sed -i 's/-e //' requirements.txt
pip install -r requirements.txt
git clone https://github.com/openXC7/prjxray-db.git /opt/fayalite-deps/prjxray-db
cd /opt/fayalite-deps/prjxray-db
git checkout 381966a746cb4cf4a7f854f0e53caa3bf74fbe62
git clone https://github.com/chipsalliance/f4pga-xc-fasm.git /build/f4pga-xc-fasm
cd /build/f4pga-xc-fasm
git checkout 25dc605c9c0896204f0c3425b52a332034cf5e5c
pip install .
git clone https://github.com/openXC7/nextpnr-xilinx.git /build/nextpnr-xilinx
cd /build/nextpnr-xilinx
git checkout 724db28b41e68568690a5ea1dd9ce5082362bb91
git submodule update --init --recursive
mkdir -p build
cd build
cmake -DARCH=xilinx -DUSE_OPENMP=ON -DBUILD_GUI=OFF ..
make -j$(nproc)
make install
install bbasm /usr/local/bin/
cd /build
wget -O firrtl.tar.gz https://github.com/llvm/circt/releases/download/firtool-1.86.0/firrtl-bin-linux-x64.tar.gz
sha256sum -c - <<<'bf6f4ab18ae76f135c944efbd81e25391c31c1bd0617c58ab0592640abefee14 firrtl.tar.gz'
tar -xvaf firrtl.tar.gz
install firtool-1.86.0/bin/firtool /usr/local/bin/
# TODO: add yosys, sby, and z3
# get rid of caches and stuff
rm -rf \
/build \
/var/cache/apt/*.bin \
/var/cache/apt/archives/*.deb \
/var/cache/apt/archives/lock \
/var/lib/apt/lists/*Packages* \
/var/lib/apt/lists/*Release* \
/var/lib/apt/lists/lock \
/etc/apt/apt.conf.d/01autoremove-kernels \
/var/log/apt/history.log \
/var/log/apt/term.log \
/var/lib/systemd/catalog/database
}
function build_container()
{
rm -rf build-container/ build/
skopeo copy docker://debian:12 oci:build-container:latest
proot -0 umoci unpack --image=build-container:latest build
cp "$0" build/rootfs/build.sh
mkdir -p .cache/ccache
mkdir -p .cache/apt
proot -S build/rootfs \
-b .cache/ccache:/root/.ccache \
-b .cache/apt:/var/cache/apt \
env -i -C / \
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
"TERM=xterm" \
"HOME=/root" \
"CCACHE_COMPILERCHECK=content" \
/build.sh --build-in-container < /dev/null
rm build/rootfs/build.sh
proot -0 umoci repack --image=build-container:latest build
}
if [[ "$*" == "--build-in-container" ]]; then
build_in_container
else
build_container
fi