BuildSystem: you can now build the toolchain with cmake

This commit is contained in:
Bananymous 2023-04-06 00:23:02 +03:00
parent 7ab9e420ac
commit 8a8793fd2d
5 changed files with 35 additions and 10 deletions

View File

@ -2,7 +2,12 @@ cmake_minimum_required(VERSION 3.26)
project(BAN CXX) project(BAN CXX)
add_custom_target(ban-install add_custom_target(ban-headers
COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/include/* ${BANAN_INCLUDE} COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/include/* ${BANAN_INCLUDE}
DEPENDS sysroot DEPENDS sysroot
) )
add_custom_target(ban-install
DEPENDS ban-headers
)

View File

@ -21,6 +21,7 @@ set(BANAN_SYSROOT ${CMAKE_BINARY_DIR}/sysroot)
set(BANAN_INCLUDE ${BANAN_SYSROOT}/usr/include) set(BANAN_INCLUDE ${BANAN_SYSROOT}/usr/include)
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(TOOLCHAIN_PREFIX ${CMAKE_SOURCE_DIR}/toolchain/local)
add_subdirectory(kernel) add_subdirectory(kernel)
add_subdirectory(BAN) add_subdirectory(BAN)
@ -33,6 +34,18 @@ add_custom_target(sysroot
COMMAND cp -r ${CMAKE_SOURCE_DIR}/base/* ${BANAN_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 add_custom_target(image
COMMAND ${CMAKE_COMMAND} -E env SYSROOT="${BANAN_SYSROOT}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" ${CMAKE_SOURCE_DIR}/image.sh COMMAND ${CMAKE_COMMAND} -E env SYSROOT="${BANAN_SYSROOT}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" ${CMAKE_SOURCE_DIR}/image.sh
DEPENDS kernel-install DEPENDS kernel-install

View File

@ -122,10 +122,14 @@ endif()
target_link_options(kernel PUBLIC -ffreestanding -nostdlib -O2) 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 -r ${CMAKE_CURRENT_SOURCE_DIR}/include/* ${BANAN_INCLUDE}/
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/kernel ${BANAN_BOOT}/banan-os.kernel
DEPENDS sysroot DEPENDS sysroot
)
add_custom_target(kernel-install
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/kernel ${BANAN_BOOT}/banan-os.kernel
DEPENDS kernel-headers
DEPENDS kernel DEPENDS kernel
) )

View File

@ -2,7 +2,12 @@ cmake_minimum_required(VERSION 3.26)
project(libc CXX) project(libc CXX)
add_custom_target(libc-install add_custom_target(libc-headers
COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/include/* ${BANAN_INCLUDE} COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/include/* ${BANAN_INCLUDE}
DEPENDS sysroot DEPENDS sysroot
) )
add_custom_target(libc-install
DEPENDS libc-headers
)

View File

@ -4,11 +4,7 @@ set -e
BINUTILS_VERSION="binutils-2.39" BINUTILS_VERSION="binutils-2.39"
GCC_VERSION="gcc-12.2.0" GCC_VERSION="gcc-12.2.0"
SYSROOT="$HOME/dev/banan-os/build/sysroot" cd $(dirname "$0")
PREFIX="$(pwd)/local"
ARCH="x86_64"
TARGET="${ARCH}-banan_os"
if [[ -z $SYSROOT ]]; then if [[ -z $SYSROOT ]]; then
echo "You must set the SYSROOT environment variable" >&2 echo "You must set the SYSROOT environment variable" >&2
@ -20,11 +16,13 @@ if [[ -z $PREFIX ]]; then
exit 1 exit 1
fi fi
if [[ -z $BANAN_AR ]]; then if [[ -z $ARCH ]]; then
echo "You must set the ARCH environment variable" >&2 echo "You must set the ARCH environment variable" >&2
exit 1 exit 1
fi fi
TARGET="${ARCH}-banan_os"
if [ ! -f ${PREFIX}/bin/${TARGET}-ld ]; then if [ ! -f ${PREFIX}/bin/${TARGET}-ld ]; then
echo "Building ${BINUTILS_VERSION}" echo "Building ${BINUTILS_VERSION}"