Make the build system more platform-agnostic
This commit is contained in:
parent
8cae20a82c
commit
83e6bd1322
@ -16,5 +16,9 @@ set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH ${LUNA_ROOT}/toolchain/x86-64-luna)
|
||||
|
||||
set(ARCH $ENV{ARCH})
|
||||
|
||||
message(STATUS "Configuring Luna for ${ARCH}")
|
||||
|
||||
add_subdirectory(luna)
|
||||
add_subdirectory(kernel)
|
@ -6,7 +6,7 @@ set(SOURCES
|
||||
src/arch/Serial.cpp
|
||||
)
|
||||
|
||||
# x86-64 specific
|
||||
if("${ARCH}" MATCHES "x86_64")
|
||||
set(SOURCES
|
||||
${SOURCES}
|
||||
src/arch/x86_64/IO.cpp
|
||||
@ -14,17 +14,26 @@ set(SOURCES
|
||||
src/arch/x86_64/MMU.cpp
|
||||
src/arch/x86_64/CPU.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
# x86-64 specific
|
||||
set(ASM_SOURCES)
|
||||
|
||||
if("${ARCH}" MATCHES "x86_64")
|
||||
set(ASM_SOURCES
|
||||
${ASM_SOURCES}
|
||||
src/arch/x86_64/CPU.asm
|
||||
)
|
||||
|
||||
add_library(moon-asm STATIC ${ASM_SOURCES})
|
||||
endif()
|
||||
|
||||
add_executable(moon ${SOURCES})
|
||||
|
||||
target_link_libraries(moon moon-asm luna-freestanding)
|
||||
if("${ARCH}" MATCHES "x86_64")
|
||||
target_link_libraries(moon moon-asm)
|
||||
endif()
|
||||
|
||||
target_link_libraries(moon luna-freestanding)
|
||||
|
||||
target_compile_definitions(moon PRIVATE IN_MOON)
|
||||
|
||||
@ -38,14 +47,16 @@ target_compile_options(moon PRIVATE -fno-rtti -ffreestanding -fno-exceptions)
|
||||
target_compile_options(moon PRIVATE -fno-asynchronous-unwind-tables -fno-omit-frame-pointer)
|
||||
target_compile_options(moon PRIVATE -nostdlib -mcmodel=kernel)
|
||||
|
||||
# x86-64 specific
|
||||
if("${ARCH}" MATCHES "x86_64")
|
||||
target_compile_options(moon PRIVATE -mno-red-zone)
|
||||
target_compile_options(moon PRIVATE -mno-80387 -mno-mmx -mno-sse -mno-sse2)
|
||||
endif()
|
||||
|
||||
target_link_options(moon PRIVATE -lgcc -Wl,--build-id=none -z max-page-size=0x1000 -mcmodel=kernel)
|
||||
|
||||
# x86-64 specific
|
||||
if("${ARCH}" MATCHES "x86_64")
|
||||
target_link_options(moon PRIVATE -mno-red-zone)
|
||||
endif()
|
||||
|
||||
set_target_properties(moon PROPERTIES CXX_STANDARD 20)
|
||||
|
||||
|
@ -19,9 +19,10 @@ target_compile_options(luna-freestanding PRIVATE -fno-rtti -ffreestanding -fno-e
|
||||
target_compile_options(luna-freestanding PRIVATE -fno-asynchronous-unwind-tables -fno-omit-frame-pointer)
|
||||
target_compile_options(luna-freestanding PRIVATE -nostdlib -mcmodel=kernel)
|
||||
|
||||
# x86-64 specific
|
||||
if("${ARCH}" MATCHES "x86_64")
|
||||
target_compile_options(luna-freestanding PRIVATE -mno-red-zone)
|
||||
target_compile_options(luna-freestanding PRIVATE -mno-80387 -mno-mmx -mno-sse -mno-sse2)
|
||||
endif()
|
||||
|
||||
target_include_directories(luna-freestanding PUBLIC ${LUNA_ROOT}/luna)
|
||||
set_target_properties(luna-freestanding PROPERTIES CXX_STANDARD 20)
|
||||
|
@ -9,12 +9,9 @@ tools/setup.sh
|
||||
|
||||
#tools/install-headers.sh
|
||||
|
||||
mkdir -p build
|
||||
if [ "$USE_NINJA" = "1" ]
|
||||
then
|
||||
cmake -S . -B build -G Ninja
|
||||
fi
|
||||
cmake --build build
|
||||
cmake --install build
|
||||
mkdir -p $BUILD_DIR
|
||||
cmake -S . -B $BUILD_DIR -G "$CMAKE_GEN"
|
||||
cmake --build $BUILD_DIR
|
||||
cmake --install $BUILD_DIR
|
||||
|
||||
mkbootimg luna.json Luna.iso
|
@ -9,9 +9,6 @@ tools/setup.sh
|
||||
|
||||
#tools/install-headers.sh
|
||||
|
||||
mkdir -p build
|
||||
if [ "$USE_NINJA" = "1" ]
|
||||
then
|
||||
cmake -S . -B build -G Ninja
|
||||
fi
|
||||
cmake --build build
|
||||
mkdir -p $BUILD_DIR
|
||||
cmake -S . -B $BUILD_DIR -G "$CMAKE_GEN"
|
||||
cmake --build $BUILD_DIR
|
@ -3,6 +3,6 @@ set -e
|
||||
|
||||
source $(dirname $0)/env.sh
|
||||
|
||||
cd $LUNA_ROOT
|
||||
cd $BUILD_DIR
|
||||
|
||||
make clean
|
||||
$BUILD clean
|
@ -3,4 +3,4 @@
|
||||
set -e
|
||||
source $(dirname $0)/env.sh
|
||||
|
||||
qemu-system-x86_64 -cdrom Luna.iso -smp 1 -m 256M -serial stdio -d int,cpu_reset -s $@
|
||||
qemu-system-$ARCH -cdrom Luna.iso -smp 1 -m 256M -serial stdio -d int,cpu_reset -s $@
|
15
tools/env.sh
15
tools/env.sh
@ -3,4 +3,17 @@ export LUNA_ROOT=${LUNA_ROOT:-$(realpath $(dirname $0)/..)}
|
||||
export LUNA_BASE=${LUNA_BASE:-$LUNA_ROOT/base}
|
||||
export PATH=$LUNA_ROOT/toolchain/x86-64-luna/bin:$LUNA_ROOT/toolchain/dist:$PATH
|
||||
|
||||
[ -f "$LUNA_ROOT/env-local.sh" ] && source $LUNA_ROOT/env-local.sh
|
||||
[ -f "$LUNA_ROOT/env-local.sh" ] && source $LUNA_ROOT/env-local.sh
|
||||
|
||||
export ARCH=${ARCH:-x86_64}
|
||||
|
||||
if [ "$USE_NINJA" = "1" ]
|
||||
then
|
||||
export BUILD=ninja
|
||||
export CMAKE_GEN=Ninja
|
||||
else
|
||||
export BUILD=make
|
||||
export CMAKE_GEN="Unix Makefiles"
|
||||
fi
|
||||
|
||||
export BUILD_DIR=$LUNA_ROOT/build/$BUILD-$ARCH
|
@ -5,4 +5,4 @@ source $(dirname $0)/env.sh
|
||||
|
||||
cd $LUNA_ROOT
|
||||
|
||||
qemu-system-x86_64 -cdrom Luna.iso -smp 1 -m 256M -serial stdio -enable-kvm $@
|
||||
qemu-system-$ARCH -cdrom Luna.iso -smp 1 -m 256M -serial stdio -enable-kvm $@
|
@ -1,53 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
source $(dirname $0)/env.sh
|
||||
|
||||
cd $LUNA_ROOT/ports
|
||||
|
||||
unset_vars()
|
||||
{
|
||||
unset pkgname
|
||||
unset pkgver
|
||||
unset pkgurl
|
||||
unset pkgmode
|
||||
unset setupdir
|
||||
unset builddir
|
||||
unset installdir
|
||||
unset srcdir
|
||||
unset port_unpack
|
||||
unset port_patch
|
||||
unset port_configure
|
||||
unset port_build
|
||||
unset port_install
|
||||
unset port_uninstall
|
||||
unset islib
|
||||
}
|
||||
|
||||
if ! [ -f ./ports.list ]
|
||||
then
|
||||
echo "No ports built."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
install_port()
|
||||
{
|
||||
unset_vars
|
||||
cd $LUNA_ROOT/ports
|
||||
export DESTDIR=${DESTDIR:-"$LUNA_ROOT/initrd"}
|
||||
export portdir=$PWD/$1
|
||||
export workdir=$portdir/workdir
|
||||
source $portdir/package.sh
|
||||
if ! [ "$islib" = "1" ]
|
||||
then
|
||||
echo "installing port: $pkgname version $pkgver"
|
||||
mkdir -p $installdir
|
||||
cd $installdir
|
||||
port_install | filter-lines $pkgname "install"
|
||||
fi
|
||||
}
|
||||
|
||||
while read package; do
|
||||
install_port $package
|
||||
done < ./ports.list
|
@ -5,4 +5,4 @@ source $(dirname $0)/env.sh
|
||||
|
||||
cd $LUNA_ROOT
|
||||
|
||||
cmake --install build
|
||||
cmake --install $BUILD_DIR
|
@ -7,11 +7,12 @@ cd $LUNA_ROOT
|
||||
|
||||
tools/setup.sh
|
||||
|
||||
make clean
|
||||
cd $BUILD_DIR
|
||||
$BUILD clean
|
||||
cd -
|
||||
|
||||
tools/install-headers.sh
|
||||
|
||||
make -j$(nproc)
|
||||
make install
|
||||
cmake -S . -B $BUILD_DIR -G "$CMAKE_GEN"
|
||||
cmake --build $BUILD_DIR
|
||||
cmake --install $BUILD_DIR
|
||||
|
||||
mkbootimg luna.json Luna.iso
|
@ -7,8 +7,9 @@ cd $LUNA_ROOT
|
||||
|
||||
tools/setup.sh
|
||||
|
||||
tools/install-headers.sh
|
||||
cd $BUILD_DIR
|
||||
$BUILD clean
|
||||
cd -
|
||||
|
||||
make clean
|
||||
|
||||
make -j$(nproc)
|
||||
cmake -S . -B $BUILD_DIR -G "$CMAKE_GEN"
|
||||
cmake --build $BUILD_DIR
|
@ -1,13 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
source $(dirname $0)/env.sh
|
||||
|
||||
cd $LUNA_ROOT
|
||||
|
||||
tools/install-headers.sh
|
||||
|
||||
cd libs/
|
||||
|
||||
$LUNA_ROOT/tools/buildstep.sh libc build
|
||||
$LUNA_ROOT/tools/buildstep.sh libc install
|
Loading…
Reference in New Issue
Block a user