WIP creating build script
This commit is contained in:
commit
4e6b86f737
7 changed files with 480 additions and 0 deletions
29
.forgejo/workflows/build.yml
Normal file
29
.forgejo/workflows/build.yml
Normal file
|
@ -0,0 +1,29 @@
|
|||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
# See Notices.txt for copyright information
|
||||
on:
|
||||
schedule:
|
||||
# every Monday at 00:00
|
||||
- cron: "0 0 * * 1"
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: debian-12
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: |
|
||||
scripts/check-copyright.sh
|
||||
- run: |
|
||||
apt-get update -qq
|
||||
apt-get install -qq fakeroot fakechroot skopeo umoci
|
||||
#- run: |
|
||||
# ./build-container.sh
|
||||
#- if: contains(fromJSON('["push", "schedule"]'), forgejo.event_name)
|
||||
# run: |
|
||||
# BASE="$(echo "${{ forgejo.server_url }}" | sed 's@https://@@')"
|
||||
# skopeo login --password-stdin -u "${{ forgejo.repository_owner }}" "$BASE" <<<"${{ secrets.CONTAINER_PUBLISH_TOKEN }}"
|
||||
# CONTAINER="$BASE/${{ forgejo.repository }}"
|
||||
# skopeo copy oci:build-container:latest "docker://$CONTAINER:g${{ forgejo.sha }}"
|
||||
# skopeo copy "docker://$CONTAINER:g${{ forgejo.sha }}" "docker://$CONTAINER:latest"
|
||||
# skopeo copy "docker://$CONTAINER:g${{ forgejo.sha }}" "docker://$CONTAINER:${{ forgejo.ref_name }}"
|
30
.forgejo/workflows/podman-rootless.yml
Normal file
30
.forgejo/workflows/podman-rootless.yml
Normal file
|
@ -0,0 +1,30 @@
|
|||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
# See Notices.txt for copyright information
|
||||
on:
|
||||
schedule:
|
||||
# every Monday at 00:00
|
||||
- cron: "0 0 * * 1"
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
podman-rootless-build:
|
||||
runs-on: debian-12
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: |
|
||||
scripts/check-copyright.sh
|
||||
- run: |
|
||||
apt-get update -qq
|
||||
apt-get install -qq skopeo umoci
|
||||
- run: |
|
||||
skopeo copy docker://quay.io/podman/stable oci:podman-rootless:latest
|
||||
umoci config --image=podman-rootless:latest --config.user=podman
|
||||
- if: contains(fromJSON('["push", "schedule"]'), forgejo.event_name)
|
||||
run: |
|
||||
BASE="$(echo "${{ forgejo.server_url }}" | sed 's@https://@@')"
|
||||
skopeo login --password-stdin -u "${{ forgejo.repository_owner }}" "$BASE" <<<"${{ secrets.CONTAINER_PUBLISH_TOKEN }}"
|
||||
CONTAINER="$BASE/${{ forgejo.repository }}-podman-rootless"
|
||||
skopeo copy oci:podman-rootless:latest "docker://$CONTAINER:g${{ forgejo.sha }}"
|
||||
skopeo copy "docker://$CONTAINER:g${{ forgejo.sha }}" "docker://$CONTAINER:latest"
|
||||
skopeo copy "docker://$CONTAINER:g${{ forgejo.sha }}" "docker://$CONTAINER:${{ forgejo.ref_name }}"
|
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
# See Notices.txt for copyright information
|
||||
|
||||
/build
|
||||
/build-container/
|
||||
/.cache
|
157
LICENSE.md
Normal file
157
LICENSE.md
Normal file
|
@ -0,0 +1,157 @@
|
|||
### GNU LESSER GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates the
|
||||
terms and conditions of version 3 of the GNU General Public License,
|
||||
supplemented by the additional permissions listed below.
|
||||
|
||||
#### 0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the
|
||||
GNU General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License, other
|
||||
than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
#### 1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
#### 2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
- a) under this License, provided that you make a good faith effort
|
||||
to ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
- b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
#### 3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from a
|
||||
header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
- a) Give prominent notice with each copy of the object code that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
- b) Accompany the object code with a copy of the GNU GPL and this
|
||||
license document.
|
||||
|
||||
#### 4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that, taken
|
||||
together, effectively do not restrict modification of the portions of
|
||||
the Library contained in the Combined Work and reverse engineering for
|
||||
debugging such modifications, if you also do each of the following:
|
||||
|
||||
- a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
- b) Accompany the Combined Work with a copy of the GNU GPL and this
|
||||
license document.
|
||||
- c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
- d) Do one of the following:
|
||||
- 0) Convey the Minimal Corresponding Source under the terms of
|
||||
this License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
- 1) Use a suitable shared library mechanism for linking with
|
||||
the Library. A suitable mechanism is one that (a) uses at run
|
||||
time a copy of the Library already present on the user's
|
||||
computer system, and (b) will operate properly with a modified
|
||||
version of the Library that is interface-compatible with the
|
||||
Linked Version.
|
||||
- e) Provide Installation Information, but only if you would
|
||||
otherwise be required to provide such information under section 6
|
||||
of the GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the Application
|
||||
with a modified version of the Linked Version. (If you use option
|
||||
4d0, the Installation Information must accompany the Minimal
|
||||
Corresponding Source and Corresponding Application Code. If you
|
||||
use option 4d1, you must provide the Installation Information in
|
||||
the manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.)
|
||||
|
||||
#### 5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the Library
|
||||
side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
- a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities, conveyed under the terms of this License.
|
||||
- b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
#### 6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
as you received it specifies that a certain numbered version of the
|
||||
GNU Lesser General Public License "or any later version" applies to
|
||||
it, you have the option of following the terms and conditions either
|
||||
of that published version or of any later version published by the
|
||||
Free Software Foundation. If the Library as you received it does not
|
||||
specify a version number of the GNU Lesser General Public License, you
|
||||
may choose any version of the GNU Lesser General Public License ever
|
||||
published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
16
Notices.txt
Normal file
16
Notices.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
Copyright 2024 Jacob Lifshay
|
||||
|
||||
This file is part of Fayalite.
|
||||
|
||||
Fayalite is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Fayalite is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Fayalite. If not, see <https://www.gnu.org/licenses/>.
|
180
build-container.sh
Executable file
180
build-container.sh
Executable file
|
@ -0,0 +1,180 @@
|
|||
#!/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
|
||||
|
||||
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 --depth=1 --recursive --branch=0.45 https://git.libre-chip.org/mirrors/yosys /build/yosys
|
||||
cd /build/yosys
|
||||
make -j"$(nproc)" PRETTY=0
|
||||
make install
|
||||
|
||||
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
|
||||
cd build
|
||||
make -j"$(nproc)"
|
||||
make install
|
||||
|
||||
# get rid of caches and stuff
|
||||
rm -rf \
|
||||
/build \
|
||||
/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 prepare_mounts()
|
||||
{
|
||||
mount --rbind /proc build/rootfs/proc
|
||||
mount --rbind /dev build/rootfs/dev
|
||||
mount --rbind /sys build/rootfs/sys
|
||||
mount --rbind .cache/.ccache build/rootfs/root/.ccache
|
||||
mount --rbind .cache/.cache build/rootfs/root/.cache
|
||||
mount --rbind .cache/apt build/rootfs/var/cache/apt
|
||||
exec chroot build/rootfs /build.sh --build-in-container
|
||||
}
|
||||
|
||||
function build_container()
|
||||
{
|
||||
rm -rf build-container/ build/
|
||||
skopeo copy docker://debian:12 oci:build-container:latest
|
||||
umoci unpack --rootless --image=build-container:latest build
|
||||
cp "$0" build/rootfs/build.sh
|
||||
mkdir -p .cache/.ccache
|
||||
mkdir -p .cache/.cache
|
||||
mkdir -p .cache/apt
|
||||
mv build/rootfs/var/cache/apt build/rootfs/var/cache/apt_old
|
||||
mkdir -p build/rootfs/root/.ccache
|
||||
mkdir -p build/rootfs/root/.cache
|
||||
mkdir -p build/rootfs/var/cache/apt
|
||||
# ln -s "$(realpath .cache/.ccache)" build/rootfs/root/.ccache
|
||||
# ln -s "$(realpath .cache/.cache)" build/rootfs/root/.cache
|
||||
# ln -s "$(realpath .cache/apt)" build/rootfs/var/cache/apt
|
||||
mv build/rootfs/etc/apt/apt.conf.d/docker-clean build/rootfs/etc/apt/
|
||||
fakechroot fakeroot chroot build/rootfs apt-get -qq update
|
||||
fakechroot fakeroot chroot build/rootfs apt-get -qq install \
|
||||
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
|
||||
unshare -fr --user --mount --kill-child --keep-caps \
|
||||
env -i \
|
||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
|
||||
"TERM=xterm" \
|
||||
"HOME=/root" \
|
||||
"CCACHE_COMPILERCHECK=content" \
|
||||
bash build/rootfs/build.sh --prepare-mounts < /dev/null
|
||||
mv build/rootfs/etc/apt/docker-clean build/rootfs/etc/apt/apt.conf.d/
|
||||
rm build/rootfs/root/.ccache build/rootfs/root/.cache build/rootfs/var/cache/apt
|
||||
mv build/rootfs/var/cache/apt_old build/rootfs/var/cache/apt
|
||||
rm build/rootfs/build.sh
|
||||
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
|
||||
elif [[ "$*" == "--prepare-mounts" ]]; then
|
||||
prepare_mounts
|
||||
else
|
||||
build_container
|
||||
fi
|
62
scripts/check-copyright.sh
Executable file
62
scripts/check-copyright.sh
Executable file
|
@ -0,0 +1,62 @@
|
|||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
# See Notices.txt for copyright information
|
||||
set -e
|
||||
|
||||
function fail()
|
||||
{
|
||||
local error="$1"
|
||||
echo "error: $error" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
function fail_file()
|
||||
{
|
||||
local file="$1" line="$2" error="$3"
|
||||
fail "$file:$((line + 1)): $error"
|
||||
}
|
||||
|
||||
function check_file()
|
||||
{
|
||||
local file="$1" regexes=("${@:2}")
|
||||
local lines
|
||||
mapfile -t lines < "$file"
|
||||
local line
|
||||
for line in "${!regexes[@]}"; do
|
||||
eval '[[ "${lines[i]}" =~ '"${regexes[i]}"' ]]' ||
|
||||
fail_file "$file" "$line" "doesn't match regex: ${regexes[i]}"
|
||||
done
|
||||
}
|
||||
|
||||
POUND_HEADER=('^"# SPDX-License-Identifier: LGPL-3.0-or-later"$' '^"# See Notices.txt for copyright information"$')
|
||||
SLASH_HEADER=('^"// SPDX-License-Identifier: LGPL-3.0-or-later"$' '^"// See Notices.txt for copyright information"$')
|
||||
MD_HEADER=('^"<!--"$' '^"SPDX-License-Identifier: LGPL-3.0-or-later"$' '^"See Notices.txt for copyright information"$')
|
||||
JSON_HEADER=('^"{"$' '^" \"license_header\": ["$' '^" \"SPDX-License-Identifier: LGPL-3.0-or-later\","$' '^" \"See Notices.txt for copyright information\""')
|
||||
|
||||
function main()
|
||||
{
|
||||
local IFS=$'\n'
|
||||
[[ -z "$(git status --porcelain)" ]] || fail "git repo is dirty"
|
||||
local file
|
||||
for file in $(git ls-tree --name-only --full-tree -r HEAD); do
|
||||
case "/$file" in
|
||||
*/LICENSE.md|*/Notices.txt)
|
||||
# copyright file
|
||||
;;
|
||||
/.forgejo/workflows/*.yml|*/.gitignore)
|
||||
check_file "$file" "${POUND_HEADER[@]}"
|
||||
;;
|
||||
Containerfile)
|
||||
check_file "$file" "${MD_HEADER[@]}"
|
||||
;;
|
||||
*.sh)
|
||||
check_file "$file" '^'\''#!'\' "${POUND_HEADER[@]}"
|
||||
;;
|
||||
*)
|
||||
fail_file "$file" 0 "unimplemented file kind -- you need to add it to $0"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
main
|
Loading…
Add table
Add a link
Reference in a new issue