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