diff --git a/BAN/CMakeLists.txt b/BAN/CMakeLists.txt index 78d8aed7a8..49e239ec3d 100644 --- a/BAN/CMakeLists.txt +++ b/BAN/CMakeLists.txt @@ -2,7 +2,12 @@ cmake_minimum_required(VERSION 3.26) project(BAN CXX) -add_custom_target(ban-install +add_custom_target(ban-headers COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/include/* ${BANAN_INCLUDE} DEPENDS sysroot ) + +add_custom_target(ban-install + DEPENDS ban-headers +) + diff --git a/CMakeLists.txt b/CMakeLists.txt index 46598c6e48..1c4de99f07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ set(BANAN_SYSROOT ${CMAKE_BINARY_DIR}/sysroot) set(BANAN_INCLUDE ${BANAN_SYSROOT}/usr/include) set(BANAN_BOOT ${BANAN_SYSROOT}/boot) set(DISK_IMAGE_PATH ${CMAKE_BINARY_DIR}/banan-os.img) +set(TOOLCHAIN_PREFIX ${CMAKE_SOURCE_DIR}/toolchain/local) add_subdirectory(kernel) add_subdirectory(BAN) @@ -33,6 +34,18 @@ add_custom_target(sysroot COMMAND cp -r ${CMAKE_SOURCE_DIR}/base/* ${BANAN_SYSROOT}/ ) +add_custom_target(headers + DEPENDS kernel-headers + DEPENDS ban-headers + DEPENDS libc-headers +) + +add_custom_target(toolchain + COMMAND ${CMAKE_COMMAND} -E env SYSROOT="${BANAN_SYSROOT}" PREFIX="${TOOLCHAIN_PREFIX}" ARCH="${BANAN_ARCH}" ${CMAKE_SOURCE_DIR}/toolchain/build.sh + DEPENDS headers + USES_TERMINAL +) + add_custom_target(image COMMAND ${CMAKE_COMMAND} -E env SYSROOT="${BANAN_SYSROOT}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" ${CMAKE_SOURCE_DIR}/image.sh DEPENDS kernel-install diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index eb3ea45924..f9ff2ce40d 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -122,10 +122,14 @@ endif() target_link_options(kernel PUBLIC -ffreestanding -nostdlib -O2) -add_custom_target(kernel-install +add_custom_target(kernel-headers COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/include/* ${BANAN_INCLUDE}/ - COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/kernel ${BANAN_BOOT}/banan-os.kernel DEPENDS sysroot +) + +add_custom_target(kernel-install + COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/kernel ${BANAN_BOOT}/banan-os.kernel + DEPENDS kernel-headers DEPENDS kernel ) diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index c7b9b0e8d8..0205a5ad14 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -2,7 +2,12 @@ cmake_minimum_required(VERSION 3.26) project(libc CXX) -add_custom_target(libc-install +add_custom_target(libc-headers COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/include/* ${BANAN_INCLUDE} DEPENDS sysroot ) + +add_custom_target(libc-install + DEPENDS libc-headers +) + diff --git a/toolchain/build.sh b/toolchain/build.sh index 81415b7dee..2012acde7f 100755 --- a/toolchain/build.sh +++ b/toolchain/build.sh @@ -4,11 +4,7 @@ set -e BINUTILS_VERSION="binutils-2.39" GCC_VERSION="gcc-12.2.0" -SYSROOT="$HOME/dev/banan-os/build/sysroot" -PREFIX="$(pwd)/local" -ARCH="x86_64" - -TARGET="${ARCH}-banan_os" +cd $(dirname "$0") if [[ -z $SYSROOT ]]; then echo "You must set the SYSROOT environment variable" >&2 @@ -20,11 +16,13 @@ if [[ -z $PREFIX ]]; then exit 1 fi -if [[ -z $BANAN_AR ]]; then +if [[ -z $ARCH ]]; then echo "You must set the ARCH environment variable" >&2 exit 1 fi +TARGET="${ARCH}-banan_os" + if [ ! -f ${PREFIX}/bin/${TARGET}-ld ]; then echo "Building ${BINUTILS_VERSION}"