BuildSystem: you can now build the toolchain with cmake
This commit is contained in:
parent
7ab9e420ac
commit
8a8793fd2d
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
@ -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}"
|
||||
|
|
Loading…
Reference in New Issue