ladybird/Ports/zig/package.sh
sin-ack cda5a530e6 Ports: Add zig port :^)
:yakkie:

The build process for the Zig compiler is more involved than most of
the other ports, because the Zig compiler is mostly self-hosting. In
order to build it, the zig-bootstrap build system is used, which does
the following:

1) Build LLVM for the host OS;
2) Build Zig for the host OS with the SerenityOS target enabled;
3) Build zlib, zstd and LLVM for SerenityOS using `zig cc` as the C/C++
   compiler;
4) Build Zig for SerenityOS using the host Zig.

A few hacks are required in order to tell `zig cc` and zig about what
Serenity's libc looks like in the build process, but other than that
it's fairly straightforward. All of the patches that are included with
this commit are Zig-upstream ready once the LLVM patches are upstreamed.
2022-12-11 19:55:37 -07:00

28 lines
869 B
Bash
Executable File

#!/usr/bin/env -S bash ../.port_include.sh
port='zig'
version='0.11.0-dev.670+f7fea080b'
files='https://github.com/ziglang/zig-bootstrap/archive/b9a466fd23d7777e1b3b87d49074ce66370fb7b3.tar.gz zig-bootstrap-b9a466f.tar.gz 84cf91d727c53ef49220ea6b2864dae3bd48e5e5a73be95bf3672c38a72b0946'
auth_type='sha256'
workdir='zig-bootstrap-b9a466fd23d7777e1b3b87d49074ce66370fb7b3'
post_fetch() {
run mkdir -p out
run cp -r "${PORT_META_DIR}/scripts" out/
}
build() {
host_env
cd "${workdir}"
./build "${SERENITY_ARCH}-serenity-none" "native"
}
install() {
zig_install_dir="${workdir}/out/zig-${SERENITY_ARCH}-serenity-none-native"
mkdir -p "${DESTDIR}/usr/local/bin/."
mkdir -p "${DESTDIR}/usr/local/lib/."
cp -rv "${zig_install_dir}/bin/"* "${DESTDIR}/usr/local/bin/"
cp -rv "${zig_install_dir}/lib/"* "${DESTDIR}/usr/local/lib/"
}