#!/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-get update -qq apt-get install -qq \ bison \ build-essential \ ccache \ clang \ cmake \ curl \ 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 pip install click==8.1.3 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.89.0 source "$HOME/.cargo/env" rustup component add rust-src 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/ git clone --depth=1 --branch=yosys-0.45 https://git.libre-chip.org/mirrors/sby /build/sby cd /build/sby make install git clone --depth=1 --recursive --branch=z3-4.13.3 https://git.libre-chip.org/mirrors/z3 /build/z3 cd /build/z3 PYTHON=python3 ./configure --prefix=/usr/local make -j"$(nproc)" make install git clone --depth=1 --recursive --branch=0.45 https://git.libre-chip.org/mirrors/yosys /build/yosys cd /build/yosys make -j"$(nproc)" make install # 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 rm -rf build echo "built oci container is in ./build-container:latest" } if [[ "$*" == "--build-in-container" ]]; then build_in_container else build_container fi