feat: added docker build container and improved build script
This commit is contained in:
35
build-container/Dockerfile
Normal file
35
build-container/Dockerfile
Normal file
@@ -0,0 +1,35 @@
|
||||
FROM ubuntu:22.10
|
||||
|
||||
RUN rm -f /etc/apt/apt.conf.d/docker-clean
|
||||
|
||||
RUN --mount=type=cache,target=/var/cache/apt \
|
||||
--mount=type=cache,target=/var/lib/apt/lists \
|
||||
DEBIAN_FRONTEND="noninteractive" apt-get update \
|
||||
&& apt-get -y install tzdata
|
||||
|
||||
RUN --mount=type=cache,target=/var/cache/apt \
|
||||
--mount=type=cache,target=/var/lib/apt/lists \
|
||||
apt-get update \
|
||||
&& apt-get install -y \
|
||||
autoconf \
|
||||
automake \
|
||||
build-essential \
|
||||
clang \
|
||||
cmake \
|
||||
dos2unix \
|
||||
g++ \
|
||||
gcc \
|
||||
gdb \
|
||||
git \
|
||||
libtool \
|
||||
locales-all \
|
||||
make \
|
||||
ninja-build \
|
||||
python3 \
|
||||
python3-dev \
|
||||
rsync \
|
||||
tar \
|
||||
valgrind \
|
||||
wget \
|
||||
xorriso \
|
||||
&& apt-get clean
|
||||
6
build-container/build.sh
Normal file
6
build-container/build.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
IMAGE=yak-build-container
|
||||
|
||||
DOCKER_BUILDKIT=1 docker build . -t "${IMAGE}:latest"
|
||||
docker image prune -f
|
||||
@@ -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