v / .github / workflows / build_vinix_locally.sh
56 lines · 44 sloc · 1.19 KB · 4e62b53ab6914b2f868cb1854cdc56f09f55a05c
Raw
1#!/usr/bin/env bash
2
3set -e
4
5V=$PWD/v
6
7if [[ -x "$V" ]]
8then
9 echo "The v executable exists."
10else
11 echo "This script should be run from the top level folder of a V repository"
12 echo "i.e. the folder where your V executable is."
13 exit 1
14fi
15
16BUILD=$PWD/vinix_build
17
18echo "Creating $BUILD folder..."
19rm -rf $BUILD
20mkdir -p $BUILD
21
22cd $BUILD
23echo "Clone current Vinix"
24./v retry -- git clone --depth=1 https://github.com/vlang/vinix.git
25
26cd $BUILD
27echo "Clone current mlibc"
28./v retry -- git clone --depth=1 https://github.com/managarm/mlibc.git
29
30cd $BUILD
31echo "Patch mlibc for Vinix"
32cd mlibc
33patch -p3 < ../vinix/patches/mlibc/mlibc.patch
34
35cd $BUILD
36echo "Install mlibc headers"
37mkdir mlibc-build
38cd mlibc-build
39meson --cross-file ../vinix/cross_file.txt --prefix=/ -Dheaders_only=true ../mlibc
40ninja
41mkdir ../mlibc-headers
42DESTDIR=`realpath ../mlibc-headers` ninja install
43
44cd $BUILD
45echo "Attempt to build the Vinix kernel (debug)"
46cd vinix/kernel
47make PROD=false CFLAGS="-D__vinix__ -O2 -g -pipe -I../../mlibc-headers/include"
48make clean
49
50cd $BUILD
51echo "Attempt to build the Vinix kernel (prod)"
52cd vinix/kernel
53make PROD=true CFLAGS="-D__vinix__ -O2 -g -pipe -I../../mlibc-headers/include"
54make clean
55
56rm -rf $BUILD
57