feat: added docker build container and improved build script
This commit is contained in:
@@ -1,9 +1,25 @@
|
||||
project(yak-kernel)
|
||||
|
||||
# Configure global options
|
||||
set(CMAKE_SYSROOT "/does-not-exist")
|
||||
set(CMAKE_SYSTEM_NAME yak)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||
set(CMAKE_CROSSCOMPILING 1)
|
||||
|
||||
if (NOT ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
|
||||
message(WARNING "Only clang is supported, not ${CMAKE_C_COMPILER_ID}")
|
||||
endif ()
|
||||
|
||||
# Define global options
|
||||
option(USE_LIMINE "Enable support for the limine boot protocol" ON)
|
||||
|
||||
# Find builtins
|
||||
list(APPEND BUILTINS_SEARCH /usr/lib/clang/15/lib/linux /usr/lib/clang/${CMAKE_C_COMPILER_VERSION}/lib/linux /usr/lib/clang/15.*.*/lib/linux)
|
||||
find_library(BUILTINS_LIB
|
||||
libclang_rt.builtins-x86_64.a
|
||||
PATHS ${BUILTINS_SEARCH})
|
||||
|
||||
# Set compiler options
|
||||
add_compile_options(
|
||||
-ffreestanding
|
||||
-fno-lto
|
||||
@@ -25,6 +41,7 @@ add_link_options(
|
||||
-T ${CMAKE_CURRENT_SOURCE_DIR}/linker.lds
|
||||
)
|
||||
|
||||
# add printf library for complete printf functionality
|
||||
FetchContent_Declare(printf_library
|
||||
GIT_REPOSITORY https://github.com/eyalroz/printf.git
|
||||
GIT_TAG v6.1.0)
|
||||
@@ -34,10 +51,12 @@ if (NOT printf_library_POPULATED)
|
||||
endif ()
|
||||
|
||||
|
||||
# Validate options
|
||||
if (NOT ${USE_LIMINE})
|
||||
message(FATAL_ERROR "At least one boot protocol is required")
|
||||
endif ()
|
||||
|
||||
# Find sources
|
||||
file(GLOB KERNEL_SOURCES src/rt/*.c src/ulibc/*.c)
|
||||
file(GLOB PLATFORM_GENERIC_SOURCES src/platform/generic/*.c)
|
||||
|
||||
@@ -50,8 +69,10 @@ endif ()
|
||||
|
||||
file(GLOB PLATFORM_SPECIFIC_SOURCES src/platform/x86_64/*.c)
|
||||
|
||||
# Define aggregate sources
|
||||
set(KERNEL_SOURCE_FILES ${KERNEL_SOURCES} ${LIMINE_KERNEL_SOURCES} ${PLATFORM_GENERIC_SOURCES} ${PLATFORM_SPECIFIC_SOURCES})
|
||||
|
||||
# Define executable
|
||||
add_executable(yak.elf ${KERNEL_SOURCE_FILES})
|
||||
target_link_libraries(yak.elf PRIVATE /usr/lib/clang/15.0.7/lib/linux/libclang_rt.builtins-x86_64.a)
|
||||
target_link_libraries(yak.elf PRIVATE ${BUILTINS_LIB})
|
||||
target_include_directories(yak.elf PRIVATE include ../limine/include ${printf_library_SOURCE_DIR}/src)# ${printf_library_SOURCE_DIR}/src)
|
||||
Reference in New Issue
Block a user