BuildSystem: Fix bugs in new build system

I had not tested the new build system with clean toolchain build
but it seems to work now.
This commit is contained in:
2023-10-24 16:48:46 +03:00
parent 2d0da93ac4
commit c71ac588b2
13 changed files with 106 additions and 90 deletions

View File

@@ -1,5 +1,4 @@
#!/bin/bash
set -e
BOCHS_CONFIG_FILE=bochsrc
COM1_TERMINAL=kitty
@@ -25,4 +24,4 @@ EOF
bochs -qf $BOCHS_CONFIG_FILE
kill $COM1_TERM_PID
rm $BOCHS_CONFIG_FILE
rm $BOCHS_CONFIG_FILE

View File

@@ -1,24 +1,20 @@
#!/bin/bash
set -e
if [[ -z $BANAN_ARCH ]]; then
export BANAN_ARCH=x86_64
fi
export BANAN_SCRIPT_DIR=$(dirname $(realpath $0))
source $BANAN_SCRIPT_DIR/config.sh
make_build_dir () {
if ! [[ -d $BANAN_BUILD_DIR ]]; then
mkdir -p $BANAN_BUILD_DIR
cd $BANAN_BUILD_DIR
cmake --toolchain=$BANAN_TOOLCHAIN_DIR/Toolchain.txt -G Ninja $BANAN_ROOT_DIR $BANAN_CMAKE_ARGS
mkdir -p $BANAN_BUILD_DIR
cd $BANAN_BUILD_DIR
if ! [[ -f "build.ninja" ]]; then
cmake --toolchain=$BANAN_TOOLCHAIN_DIR/Toolchain.txt -G Ninja $BANAN_ROOT_DIR
fi
}
build_target () {
make_build_dir
if [[ -z $1 ]]; then
if [[ $# -eq 0 ]]; then
echo "No target provided"
exit 1
fi
@@ -27,6 +23,15 @@ build_target () {
}
build_toolchain () {
if [[ -f $BANAN_TOOLCHAIN_PREFIX/bin/$BANAN_TOOLCHAIN_TRIPLE_PREFIX-gcc ]]; then
echo "You already seem to have a toolchain."
read -e -p "Do you want to rebuild it [y/N]? " choice
if ! [[ "$choice" == [Yy]* ]]; then
echo "Aborting toolchain rebuild"
exit 0
fi
fi
$BANAN_TOOLCHAIN_DIR/build.sh
build_target libc-install
$BANAN_TOOLCHAIN_DIR/build.sh libstdc++
@@ -51,57 +56,42 @@ run_bochs () {
$BANAN_SCRIPT_DIR/bochs.sh $@
}
if [[ "$1" == "toolchain" ]]; then
if [[ -f $BANAN_TOOLCHAIN_PREFIX/bin/$BANAN_TOOLCHAIN_TRIPLE_PREFIX-gcc ]]; then
echo "You already seem to have build toolchain."
read -e -p "Do you want to rebuild it [y/N]? " choice
if ! [[ "$choice" == [Yy]* ]]; then
echo "Aborting toolchain rebuild"
exit 0
fi
fi
build_toolchain
exit 0
fi
if [[ "$1" == "image" ]]; then
create_image
exit 0
fi
if [[ "$1" == "image-full" ]]; then
create_image full
exit 0
fi
if [[ "$(uname)" == "Linux" ]]; then
QEMU_ACCEL="-accel kvm"
fi
if [[ "$1" == "qemu" ]]; then
run_qemu -serial stdio $QEMU_ACCEL
exit 0
if [[ $# -eq 0 ]]; then
echo "No argument given"
exit 1
fi
if [[ "$1" == "qemu-nographic" ]]; then
run_qemu -nographic $QEMU_ACCEL
exit 0
fi
case $1 in
toolchain)
build_toolchain
;;
image)
create_image
;;
image-full)
create_image full
;;
qemu)
run_qemu -serial stdio $QEMU_ACCEL
;;
qemu-nographic)
run_qemu -nographic $QEMU_ACCEL
;;
qemu-debug)
run_qemu -serial stdio -d int -no-reboot
;;
bochs)
run_bochs
;;
check-fs)
$BANAN_SCRIPT_DIR/check-fs.sh
;;
*)
build_target $1
;;
esac
if [[ "$1" == "qemu-debug" ]]; then
run_qemu -serial stdio -d int -no-reboot
exit 0
fi
if [[ "$1" == "bochs" ]]; then
run_bochs
exit 0
fi
if [[ "$1" == "check-fs" ]]; then
$BANAN_SCRIPT_DIR/check-fs.sh
exit 0
fi
build_target $1

View File

@@ -1,5 +1,4 @@
#!/bin/bash
set -e
if [[ -z $BANAN_DISK_IMAGE_PATH ]]; then
echo "You must set BANAN_DISK_IMAGE_PATH environment variable" >&2

View File

@@ -1,5 +1,5 @@
if [[ -z $BANAN_ROOT_DIR ]]; then
if [[ -z $BANAN_SCRIPT_DIR ]]; then
if ! [[ -z $BANAN_SCRIPT_DIR ]]; then
export BANAN_ROOT_DIR=$BANAN_SCRIPT_DIR/..
else
echo "You must set the BANAN_ROOT_DIR environment variable" >&2
@@ -8,8 +8,7 @@ if [[ -z $BANAN_ROOT_DIR ]]; then
fi
if [[ -z $BANAN_ARCH ]]; then
echo "You must set the BANAN_ARCH environment variable" >&2
exit 1
export BANAN_ARCH=x86_64
fi
export BANAN_TOOLCHAIN_DIR=$BANAN_ROOT_DIR/toolchain

View File

@@ -1,5 +1,4 @@
#!/bin/bash
set -e
if [[ -z $BANAN_DISK_IMAGE_PATH ]]; then
echo "You must set the BANAN_DISK_IMAGE_PATH environment variable" >&2
@@ -79,18 +78,18 @@ if [[ "$BANAN_UEFI_BOOT" == "1" ]]; then
sudo mkfs.fat $PARTITION1 > /dev/null
sudo mount $PARTITION1 "$MOUNT_DIR"
sudo mkdir -p "$MOUNT_DIR/EFI/BOOT"
sudo "$BANAN_TOOLCHAIN_PREFIX/bin/grub-mkstandalone" -O "$BANAN_ARCH-efi" -o "$MOUNT_DIR/EFI/BOOT/BOOTX64.EFI" "boot/grub/grub.cfg=$BANAN_TOOLCHAIN_PREFIX/grub-memdisk.cfg"
sudo "$BANAN_TOOLCHAIN_PREFIX/bin/grub-mkstandalone" -O "$BANAN_ARCH-efi" -o "$MOUNT_DIR/EFI/BOOT/BOOTX64.EFI" "boot/grub/grub.cfg=$BANAN_TOOLCHAIN_DIR/grub-memdisk.cfg"
sudo umount "$MOUNT_DIR"
sudo mount $PARTITION2 "$MOUNT_DIR"
sudo mkdir -p "$MOUNT_DIR/boot/grub"
sudo cp "$BANAN_TOOLCHAIN_PREFIX/grub-uefi.cfg" "$MOUNT_DIR/boot/grub/grub.cfg"
sudo cp "$BANAN_TOOLCHAIN_DIR/grub-uefi.cfg" "$MOUNT_DIR/boot/grub/grub.cfg"
sudo umount "$MOUNT_DIR"
else
sudo mount $PARTITION2 "$MOUNT_DIR"
sudo grub-install --no-floppy --target=i386-pc --modules="normal ext2 multiboot" --boot-directory="$MOUNT_DIR/boot" $LOOP_DEV
sudo mkdir -p "$MOUNT_DIR/boot/grub"
sudo cp "$BANAN_TOOLCHAIN_PREFIX/grub-legacy-boot.cfg" "$MOUNT_DIR/boot/grub/grub.cfg"
sudo cp "$BANAN_TOOLCHAIN_DIR/grub-legacy-boot.cfg" "$MOUNT_DIR/boot/grub/grub.cfg"
sudo umount "$MOUNT_DIR"
fi

View File

@@ -1,5 +1,4 @@
#!/bin/bash
set -e
if [[ -z $BANAN_DISK_IMAGE_PATH ]]; then
echo "You must set the BANAN_DISK_IMAGE_PATH environment variable" >&2