forked from Bananymous/banan-os
BAN: add helper to cast Span<T> to Span<const T>
This commit is contained in:
parent
e2e5c31d54
commit
781c950af6
|
@ -43,6 +43,8 @@ namespace BAN
|
||||||
|
|
||||||
Span slice(size_type, size_type = ~size_type(0));
|
Span slice(size_type, size_type = ~size_type(0));
|
||||||
|
|
||||||
|
Span<const T> as_const() const { return Span<const T>(m_data, m_size); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T* m_data = nullptr;
|
T* m_data = nullptr;
|
||||||
size_type m_size = 0;
|
size_type m_size = 0;
|
||||||
|
|
|
@ -39,6 +39,14 @@ set(BANAN_BIN ${BANAN_SYSROOT}/usr/bin)
|
||||||
set(BANAN_BOOT ${BANAN_SYSROOT}/boot)
|
set(BANAN_BOOT ${BANAN_SYSROOT}/boot)
|
||||||
set(DISK_IMAGE_PATH ${CMAKE_BINARY_DIR}/banan-os.img)
|
set(DISK_IMAGE_PATH ${CMAKE_BINARY_DIR}/banan-os.img)
|
||||||
|
|
||||||
|
set(BANAN_SCRIPT_ENV
|
||||||
|
BANAN_ARCH="${BANAN_ARCH}"
|
||||||
|
DISK_IMAGE_PATH="${DISK_IMAGE_PATH}"
|
||||||
|
SYSROOT="${BANAN_SYSROOT}"
|
||||||
|
TOOLCHAIN_PREFIX="${TOOLCHAIN_PREFIX}"
|
||||||
|
UEFI_BOOT="${UEFI_BOOT}"
|
||||||
|
)
|
||||||
|
|
||||||
add_subdirectory(kernel)
|
add_subdirectory(kernel)
|
||||||
add_subdirectory(BAN)
|
add_subdirectory(BAN)
|
||||||
add_subdirectory(libc)
|
add_subdirectory(libc)
|
||||||
|
@ -59,7 +67,7 @@ add_custom_target(headers
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(toolchain
|
add_custom_target(toolchain
|
||||||
COMMAND ${CMAKE_COMMAND} -E env SYSROOT="${BANAN_SYSROOT}" PREFIX="${TOOLCHAIN_PREFIX}" ARCH="${BANAN_ARCH}" ${CMAKE_SOURCE_DIR}/toolchain/build.sh
|
COMMAND ${CMAKE_COMMAND} -E env ${BANAN_SCRIPT_ENV} ${CMAKE_SOURCE_DIR}/toolchain/build.sh
|
||||||
DEPENDS headers
|
DEPENDS headers
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
)
|
)
|
||||||
|
@ -71,7 +79,7 @@ add_custom_target(libstdc++
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(image
|
add_custom_target(image
|
||||||
COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" SYSROOT="${BANAN_SYSROOT}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" TOOLCHAIN="${TOOLCHAIN_PREFIX}" UEFI_BOOT="${UEFI_BOOT}" ${CMAKE_SOURCE_DIR}/image.sh
|
COMMAND ${CMAKE_COMMAND} -E env ${BANAN_SCRIPT_ENV} ${CMAKE_SOURCE_DIR}/image.sh
|
||||||
DEPENDS kernel-install
|
DEPENDS kernel-install
|
||||||
DEPENDS ban-install
|
DEPENDS ban-install
|
||||||
DEPENDS libc-install
|
DEPENDS libc-install
|
||||||
|
@ -81,7 +89,7 @@ add_custom_target(image
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(image-full
|
add_custom_target(image-full
|
||||||
COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" SYSROOT="${BANAN_SYSROOT}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" TOOLCHAIN="${TOOLCHAIN_PREFIX}" UEFI_BOOT="${UEFI_BOOT}" ${CMAKE_SOURCE_DIR}/image-full.sh
|
COMMAND ${CMAKE_COMMAND} -E env ${BANAN_SCRIPT_ENV} ${CMAKE_SOURCE_DIR}/image-full.sh
|
||||||
DEPENDS kernel-install
|
DEPENDS kernel-install
|
||||||
DEPENDS ban-install
|
DEPENDS ban-install
|
||||||
DEPENDS libc-install
|
DEPENDS libc-install
|
||||||
|
@ -91,30 +99,30 @@ add_custom_target(image-full
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(check-fs
|
add_custom_target(check-fs
|
||||||
COMMAND ${CMAKE_COMMAND} -E env DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" ${CMAKE_SOURCE_DIR}/check-fs.sh
|
COMMAND ${CMAKE_COMMAND} -E env ${BANAN_SCRIPT_ENV} ${CMAKE_SOURCE_DIR}/check-fs.sh
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(qemu
|
add_custom_target(qemu
|
||||||
COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" UEFI_BOOT="${UEFI_BOOT}" ${CMAKE_SOURCE_DIR}/qemu.sh -serial stdio ${QEMU_ACCEL}
|
COMMAND ${CMAKE_COMMAND} -E env ${BANAN_SCRIPT_ENV} ${CMAKE_SOURCE_DIR}/qemu.sh -serial stdio ${QEMU_ACCEL}
|
||||||
DEPENDS image
|
DEPENDS image
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(qemu-nographic
|
add_custom_target(qemu-nographic
|
||||||
COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" UEFI_BOOT="${UEFI_BOOT}" ${CMAKE_SOURCE_DIR}/qemu.sh -nographic ${QEMU_ACCEL}
|
COMMAND ${CMAKE_COMMAND} -E env ${BANAN_SCRIPT_ENV} ${CMAKE_SOURCE_DIR}/qemu.sh -nographic ${QEMU_ACCEL}
|
||||||
DEPENDS image
|
DEPENDS image
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(qemu-debug
|
add_custom_target(qemu-debug
|
||||||
COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" UEFI_BOOT="${UEFI_BOOT}" ${CMAKE_SOURCE_DIR}/qemu.sh -serial stdio -d int -no-reboot
|
COMMAND ${CMAKE_COMMAND} -E env ${BANAN_SCRIPT_ENV} ${CMAKE_SOURCE_DIR}/qemu.sh -serial stdio -d int -no-reboot
|
||||||
DEPENDS image
|
DEPENDS image
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(bochs
|
add_custom_target(bochs
|
||||||
COMMAND ${CMAKE_COMMAND} -E env DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" ${CMAKE_SOURCE_DIR}/bochs.sh
|
COMMAND ${CMAKE_COMMAND} -E env ${BANAN_SCRIPT_ENV} ${CMAKE_SOURCE_DIR}/bochs.sh
|
||||||
DEPENDS image
|
DEPENDS image
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
)
|
)
|
||||||
|
|
|
@ -59,18 +59,18 @@ if [[ "$UEFI_BOOT" == "1" ]]; then
|
||||||
sudo mkfs.fat $PARTITION1 > /dev/null
|
sudo mkfs.fat $PARTITION1 > /dev/null
|
||||||
sudo mount $PARTITION1 "$MOUNT_DIR"
|
sudo mount $PARTITION1 "$MOUNT_DIR"
|
||||||
sudo mkdir -p "$MOUNT_DIR/EFI/BOOT"
|
sudo mkdir -p "$MOUNT_DIR/EFI/BOOT"
|
||||||
sudo "$TOOLCHAIN/bin/grub-mkstandalone" -O "$BANAN_ARCH-efi" -o "$MOUNT_DIR/EFI/BOOT/BOOTX64.EFI" "boot/grub/grub.cfg=$TOOLCHAIN/grub-memdisk.cfg"
|
sudo "$TOOLCHAIN_PREFIX/bin/grub-mkstandalone" -O "$BANAN_ARCH-efi" -o "$MOUNT_DIR/EFI/BOOT/BOOTX64.EFI" "boot/grub/grub.cfg=$TOOLCHAIN_PREFIX/grub-memdisk.cfg"
|
||||||
sudo umount "$MOUNT_DIR"
|
sudo umount "$MOUNT_DIR"
|
||||||
|
|
||||||
sudo mount $PARTITION2 "$MOUNT_DIR"
|
sudo mount $PARTITION2 "$MOUNT_DIR"
|
||||||
sudo mkdir -p "$MOUNT_DIR/boot/grub"
|
sudo mkdir -p "$MOUNT_DIR/boot/grub"
|
||||||
sudo cp "$TOOLCHAIN/grub-uefi.cfg" "$MOUNT_DIR/boot/grub/grub.cfg"
|
sudo cp "$TOOLCHAIN_PREFIX/grub-uefi.cfg" "$MOUNT_DIR/boot/grub/grub.cfg"
|
||||||
sudo umount "$MOUNT_DIR"
|
sudo umount "$MOUNT_DIR"
|
||||||
else
|
else
|
||||||
sudo mount $PARTITION2 "$MOUNT_DIR"
|
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 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 mkdir -p "$MOUNT_DIR/boot/grub"
|
||||||
sudo cp "$TOOLCHAIN/grub-legacy-boot.cfg" "$MOUNT_DIR/boot/grub/grub.cfg"
|
sudo cp "$TOOLCHAIN_PREFIX/grub-legacy-boot.cfg" "$MOUNT_DIR/boot/grub/grub.cfg"
|
||||||
sudo umount "$MOUNT_DIR"
|
sudo umount "$MOUNT_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -19,19 +19,19 @@ if [[ -z $SYSROOT ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $PREFIX ]]; then
|
if [[ -z $TOOLCHAIN_PREFIX ]]; then
|
||||||
echo "You must set the PREFIX environment variable" >&2
|
echo "You must set the TOOLCHAIN_PREFIX environment variable" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $ARCH ]]; then
|
if [[ -z $BANAN_ARCH ]]; then
|
||||||
echo "You must set the ARCH environment variable" >&2
|
echo "You must set the BANAN_ARCH environment variable" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TARGET="${ARCH}-banan_os"
|
TARGET="${BANAN_ARCH}-banan_os"
|
||||||
|
|
||||||
if [ ! -f ${PREFIX}/bin/${TARGET}-ld ]; then
|
if [ ! -f ${TOOLCHAIN_PREFIX}/bin/${TARGET}-ld ]; then
|
||||||
|
|
||||||
echo "Building ${BINUTILS_VERSION}"
|
echo "Building ${BINUTILS_VERSION}"
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ if [ ! -f ${PREFIX}/bin/${TARGET}-ld ]; then
|
||||||
|
|
||||||
../../${BINUTILS_VERSION}/configure \
|
../../${BINUTILS_VERSION}/configure \
|
||||||
--target="$TARGET" \
|
--target="$TARGET" \
|
||||||
--prefix="$PREFIX" \
|
--prefix="$TOOLCHAIN_PREFIX" \
|
||||||
--with-sysroot="$SYSROOT" \
|
--with-sysroot="$SYSROOT" \
|
||||||
--disable-nls \
|
--disable-nls \
|
||||||
--disable-werror
|
--disable-werror
|
||||||
|
@ -61,7 +61,7 @@ if [ ! -f ${PREFIX}/bin/${TARGET}-ld ]; then
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f ${PREFIX}/bin/${TARGET}-g++ ]; then
|
if [ ! -f ${TOOLCHAIN_PREFIX}/bin/${TARGET}-g++ ]; then
|
||||||
|
|
||||||
echo "Building ${GCC_VERSION}"
|
echo "Building ${GCC_VERSION}"
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ if [ ! -f ${PREFIX}/bin/${TARGET}-g++ ]; then
|
||||||
|
|
||||||
../../${GCC_VERSION}/configure \
|
../../${GCC_VERSION}/configure \
|
||||||
--target="$TARGET" \
|
--target="$TARGET" \
|
||||||
--prefix="$PREFIX" \
|
--prefix="$TOOLCHAIN_PREFIX" \
|
||||||
--with-sysroot="$SYSROOT" \
|
--with-sysroot="$SYSROOT" \
|
||||||
--disable-nls \
|
--disable-nls \
|
||||||
--enable-languages=c,c++
|
--enable-languages=c,c++
|
||||||
|
@ -92,7 +92,7 @@ if [ ! -f ${PREFIX}/bin/${TARGET}-g++ ]; then
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f ${PREFIX}/bin/grub-mkstandalone ]; then
|
if [ ! -f ${TOOLCHAIN_PREFIX}/bin/grub-mkstandalone ]; then
|
||||||
|
|
||||||
echo "Building ${GRUB_VERSION}"
|
echo "Building ${GRUB_VERSION}"
|
||||||
|
|
||||||
|
@ -108,8 +108,8 @@ if [ ! -f ${PREFIX}/bin/grub-mkstandalone ]; then
|
||||||
pushd build/${GRUB_VERSION}/
|
pushd build/${GRUB_VERSION}/
|
||||||
|
|
||||||
../../${GRUB_VERSION}/configure \
|
../../${GRUB_VERSION}/configure \
|
||||||
--target="$ARCH" \
|
--target="$BANAN_ARCH" \
|
||||||
--prefix="$PREFIX" \
|
--prefix="$TOOLCHAIN_PREFIX" \
|
||||||
--with-platform="efi" \
|
--with-platform="efi" \
|
||||||
--disable-werror
|
--disable-werror
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
*/
|
Loading…
Reference in New Issue