tools+CMake: Prefix all environment variables with LUNA_
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
a3d0fa7d0a
commit
a6974b605e
@ -10,23 +10,23 @@ project(Luna LANGUAGES C CXX ASM ASM_NASM VERSION 0.1.0)
|
||||
set(LUNA_ROOT ${CMAKE_CURRENT_LIST_DIR})
|
||||
set(LUNA_BASE ${CMAKE_CURRENT_LIST_DIR}/base)
|
||||
|
||||
set(ARCH $ENV{ARCH})
|
||||
set(LUNA_ARCH $ENV{LUNA_ARCH})
|
||||
|
||||
if(NOT DEFINED ARCH)
|
||||
set(ARCH "x86_64")
|
||||
if(NOT DEFINED LUNA_ARCH)
|
||||
set(LUNA_ARCH "x86_64")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_COMPILER ${ARCH}-luna-gcc)
|
||||
set(CMAKE_CXX_COMPILER ${ARCH}-luna-g++)
|
||||
set(CMAKE_ASM_COMPILER ${ARCH}-luna-gcc)
|
||||
set(CMAKE_C_COMPILER ${LUNA_ARCH}-luna-gcc)
|
||||
set(CMAKE_CXX_COMPILER ${LUNA_ARCH}-luna-g++)
|
||||
set(CMAKE_ASM_COMPILER ${LUNA_ARCH}-luna-gcc)
|
||||
|
||||
set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64)
|
||||
|
||||
set(CMAKE_ASM_NASM_LINK_EXECUTABLE "${ARCH}-luna-ld <FLAGS> <CMAKE_ASM_NASM_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
||||
set(CMAKE_ASM_NASM_LINK_EXECUTABLE "${LUNA_ARCH}-luna-ld <FLAGS> <CMAKE_ASM_NASM_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH ${LUNA_ROOT}/toolchain/${ARCH}-luna)
|
||||
set(CMAKE_FIND_ROOT_PATH ${LUNA_ROOT}/toolchain/${LUNA_ARCH}-luna)
|
||||
|
||||
message(STATUS "Configuring Luna for ${ARCH}")
|
||||
message(STATUS "Configuring Luna for ${LUNA_ARCH}")
|
||||
|
||||
add_subdirectory(luna)
|
||||
add_subdirectory(libc)
|
||||
|
@ -26,7 +26,7 @@ set(SOURCES
|
||||
src/ELF.cpp
|
||||
)
|
||||
|
||||
if("${ARCH}" MATCHES "x86_64")
|
||||
if("${LUNA_ARCH}" MATCHES "x86_64")
|
||||
set(SOURCES
|
||||
${SOURCES}
|
||||
src/arch/x86_64/IO.cpp
|
||||
@ -43,7 +43,7 @@ endif()
|
||||
|
||||
add_executable(moon ${SOURCES})
|
||||
|
||||
if("${ARCH}" MATCHES "x86_64")
|
||||
if("${LUNA_ARCH}" MATCHES "x86_64")
|
||||
set(ASM_SOURCES
|
||||
src/arch/x86_64/CPU.asm
|
||||
src/arch/x86_64/Entry.asm
|
||||
@ -66,7 +66,7 @@ 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)
|
||||
|
||||
if("${ARCH}" MATCHES "x86_64")
|
||||
if("${LUNA_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)
|
||||
target_link_options(moon PRIVATE -mno-red-zone)
|
||||
|
@ -13,14 +13,14 @@ set(SOURCES
|
||||
src/sys/mman.cpp
|
||||
)
|
||||
|
||||
if(${ARCH} STREQUAL "x86_64")
|
||||
if(${LUNA_ARCH} STREQUAL "x86_64")
|
||||
set(SOURCES
|
||||
${SOURCES}
|
||||
src/arch/x86_64/syscall.S
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(crt0 STATIC src/arch/${ARCH}/crt0.S)
|
||||
add_library(crt0 STATIC src/arch/${LUNA_ARCH}/crt0.S)
|
||||
add_custom_command(
|
||||
TARGET crt0
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy $<TARGET_OBJECTS:crt0> ${LUNA_BASE}/usr/lib/crt0.o
|
||||
|
@ -46,7 +46,7 @@ target_compile_options(luna PRIVATE -fno-asynchronous-unwind-tables -fno-omit-fr
|
||||
target_include_directories(luna PUBLIC include/)
|
||||
target_include_directories(luna PUBLIC ${LUNA_BASE}/usr/include)
|
||||
|
||||
if("${ARCH}" MATCHES "x86_64")
|
||||
if("${LUNA_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)
|
||||
target_compile_definitions(luna-freestanding PUBLIC ARCH_X86_64)
|
||||
|
@ -11,8 +11,8 @@ tools/full-clean.sh
|
||||
|
||||
tools/install-headers.sh
|
||||
|
||||
cmake -S . -B $BUILD_DIR -DMOON_DEBUG_SYMBOLS=ON -DLUNA_DEBUG_SYMBOLS=ON -G "$CMAKE_GEN"
|
||||
cmake --build $BUILD_DIR
|
||||
cmake --install $BUILD_DIR
|
||||
cmake -S . -B $LUNA_BUILD_DIR -DMOON_DEBUG_SYMBOLS=ON -DLUNA_DEBUG_SYMBOLS=ON -G "$LUNA_CMAKE_GENERATOR_NAME"
|
||||
cmake --build $LUNA_BUILD_DIR
|
||||
cmake --install $LUNA_BUILD_DIR
|
||||
|
||||
mkbootimg luna.json Luna.iso
|
||||
|
@ -9,9 +9,9 @@ tools/setup.sh
|
||||
|
||||
tools/install-headers.sh
|
||||
|
||||
mkdir -p $BUILD_DIR
|
||||
cmake -S . -B $BUILD_DIR -G "$CMAKE_GEN"
|
||||
cmake --build $BUILD_DIR
|
||||
cmake --install $BUILD_DIR
|
||||
mkdir -p $LUNA_BUILD_DIR
|
||||
cmake -S . -B $LUNA_BUILD_DIR -G "$LUNA_CMAKE_GENERATOR_NAME"
|
||||
cmake --build $LUNA_BUILD_DIR
|
||||
cmake --install $LUNA_BUILD_DIR
|
||||
|
||||
mkbootimg luna.json Luna.iso
|
||||
|
@ -9,6 +9,6 @@ tools/setup.sh
|
||||
|
||||
tools/install-headers.sh
|
||||
|
||||
mkdir -p $BUILD_DIR
|
||||
cmake -S . -B $BUILD_DIR -G "$CMAKE_GEN"
|
||||
cmake --build $BUILD_DIR
|
||||
mkdir -p $LUNA_BUILD_DIR
|
||||
cmake -S . -B $LUNA_BUILD_DIR -G "$LUNA_CMAKE_GENERATOR_NAME"
|
||||
cmake --build $LUNA_BUILD_DIR
|
||||
|
@ -3,6 +3,6 @@ set -e
|
||||
|
||||
source $(dirname $0)/env.sh
|
||||
|
||||
cd $BUILD_DIR
|
||||
cd $LUNA_BUILD_DIR
|
||||
|
||||
$BUILD clean
|
||||
$LUNA_BUILD clean
|
||||
|
@ -3,4 +3,4 @@
|
||||
set -e
|
||||
source $(dirname $0)/env.sh
|
||||
|
||||
qemu-system-$ARCH -cdrom Luna.iso -smp 1 -m 256M -serial stdio -d int,cpu_reset -s $@
|
||||
qemu-system-$LUNA_ARCH -cdrom Luna.iso -smp 1 -m 256M -serial stdio -d int,cpu_reset -s $@
|
||||
|
14
tools/env.sh
14
tools/env.sh
@ -4,16 +4,16 @@ export LUNA_BASE=${LUNA_BASE:-$LUNA_ROOT/base}
|
||||
|
||||
[ -f "$LUNA_ROOT/env-local.sh" ] && source $LUNA_ROOT/env-local.sh
|
||||
|
||||
export ARCH=${ARCH:-x86_64}
|
||||
export PATH=$LUNA_ROOT/toolchain/$ARCH-luna/bin:$LUNA_ROOT/toolchain/dist:$PATH
|
||||
export LUNA_ARCH=${LUNA_ARCH:-x86_64}
|
||||
export PATH=$LUNA_ROOT/toolchain/$LUNA_ARCH-luna/bin:$LUNA_ROOT/toolchain/dist:$PATH
|
||||
|
||||
if [ "$USE_MAKE" = "1" ]
|
||||
then
|
||||
export BUILD=make
|
||||
export CMAKE_GEN="Unix Makefiles"
|
||||
export LUNA_BUILD=make
|
||||
export LUNA_CMAKE_GENERATOR_NAME="Unix Makefiles"
|
||||
else
|
||||
export BUILD=ninja
|
||||
export CMAKE_GEN="Ninja"
|
||||
export LUNA_BUILD=ninja
|
||||
export LUNA_CMAKE_GENERATOR_NAME="Ninja"
|
||||
fi
|
||||
|
||||
export BUILD_DIR=$LUNA_ROOT/build/$BUILD-$ARCH
|
||||
export LUNA_BUILD_DIR=$LUNA_ROOT/build/$LUNA_BUILD-$LUNA_ARCH
|
||||
|
@ -5,4 +5,4 @@ source $(dirname $0)/env.sh
|
||||
|
||||
cd $LUNA_ROOT
|
||||
|
||||
qemu-system-$ARCH -cdrom Luna.iso -smp 1 -m 256M -serial stdio -enable-kvm $@
|
||||
qemu-system-$LUNA_ARCH -cdrom Luna.iso -smp 1 -m 256M -serial stdio -enable-kvm $@
|
||||
|
@ -3,5 +3,5 @@ set -e
|
||||
|
||||
source $(dirname $0)/env.sh
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
rm -rf $LUNA_BUILD_DIR
|
||||
mkdir -p $LUNA_BUILD_DIR
|
||||
|
@ -3,6 +3,6 @@
|
||||
set -e
|
||||
source $(dirname $0)/env.sh
|
||||
|
||||
cd $BUILD_DIR
|
||||
cd $LUNA_BUILD_DIR
|
||||
|
||||
gdb -x $LUNA_ROOT/.gdbconf
|
||||
gdb -x $LUNA_ROOT/.gdbconf
|
||||
|
@ -5,4 +5,4 @@ source $(dirname $0)/env.sh
|
||||
|
||||
cd $LUNA_ROOT
|
||||
|
||||
cmake --install $BUILD_DIR
|
||||
cmake --install $LUNA_BUILD_DIR
|
||||
|
@ -11,8 +11,8 @@ tools/full-clean.sh
|
||||
|
||||
tools/install-headers.sh
|
||||
|
||||
cmake -S . -B $BUILD_DIR -G "$CMAKE_GEN"
|
||||
cmake --build $BUILD_DIR
|
||||
cmake --install $BUILD_DIR
|
||||
cmake -S . -B $LUNA_BUILD_DIR -G "$LUNA_CMAKE_GENERATOR_NAME"
|
||||
cmake --build $LUNA_BUILD_DIR
|
||||
cmake --install $LUNA_BUILD_DIR
|
||||
|
||||
mkbootimg luna.json Luna.iso
|
||||
|
@ -11,5 +11,5 @@ tools/full-clean.sh
|
||||
|
||||
tools/install-headers.sh
|
||||
|
||||
cmake -S . -B $BUILD_DIR -G "$CMAKE_GEN"
|
||||
cmake --build $BUILD_DIR
|
||||
cmake -S . -B $LUNA_BUILD_DIR -G "$LUNA_CMAKE_GENERATOR_NAME"
|
||||
cmake --build $LUNA_BUILD_DIR
|
||||
|
@ -13,7 +13,7 @@ if [ ! -f toolchain/tarballs/binutils-$LUNA_BINUTILS_VERSION_REQUIRED.tar.xz ];
|
||||
wget -Otoolchain/tarballs/binutils-$LUNA_BINUTILS_VERSION_REQUIRED.tar.xz https://ftp.gnu.org/gnu/binutils/binutils-$LUNA_BINUTILS_VERSION_REQUIRED.tar.xz
|
||||
fi
|
||||
|
||||
rm -rf toolchain/build/binutils-$ARCH
|
||||
rm -rf toolchain/build/binutils-$LUNA_ARCH
|
||||
rm -rf toolchain/build/binutils-$LUNA_BINUTILS_VERSION_REQUIRED
|
||||
|
||||
echo Extracting Binutils...
|
||||
@ -30,9 +30,9 @@ cd -
|
||||
|
||||
echo Configuring Binutils...
|
||||
|
||||
mkdir -p toolchain/build/binutils-$ARCH
|
||||
mkdir -p toolchain/build/binutils-$LUNA_ARCH
|
||||
|
||||
cd toolchain/build/binutils-$ARCH
|
||||
cd toolchain/build/binutils-$LUNA_ARCH
|
||||
|
||||
unset CC
|
||||
unset CXX
|
||||
|
@ -4,6 +4,6 @@ source $(dirname $0)/env.sh
|
||||
export LUNA_GCC_VERSION_REQUIRED=12.2.0
|
||||
export LUNA_BINUTILS_VERSION_REQUIRED=2.39
|
||||
|
||||
export BUILD_PREFIX=$LUNA_ROOT/toolchain/$ARCH-luna
|
||||
export BUILD_TARGET=$ARCH-luna
|
||||
export BUILD_PREFIX=$LUNA_ROOT/toolchain/$LUNA_ARCH-luna
|
||||
export BUILD_TARGET=$LUNA_ARCH-luna
|
||||
export BUILD_SYSROOT=$LUNA_ROOT/base
|
||||
|
@ -4,7 +4,7 @@ source $(dirname $0)/setup-env.sh
|
||||
|
||||
cd $LUNA_ROOT
|
||||
|
||||
if [ ! -x $(command -v $ARCH-luna-as) ]
|
||||
if [ ! -x $(command -v $LUNA_ARCH-luna-as) ]
|
||||
then
|
||||
echo Binutils should be cross-built before GCC.
|
||||
exit 1
|
||||
@ -21,7 +21,7 @@ if [ ! -f toolchain/tarballs/gcc-$LUNA_GCC_VERSION_REQUIRED.tar.xz ]; then
|
||||
wget -Otoolchain/tarballs/gcc-$LUNA_GCC_VERSION_REQUIRED.tar.xz https://ftp.gnu.org/gnu/gcc/gcc-$LUNA_GCC_VERSION_REQUIRED/gcc-$LUNA_GCC_VERSION_REQUIRED.tar.xz
|
||||
fi
|
||||
|
||||
rm -rf toolchain/build/gcc-$ARCH
|
||||
rm -rf toolchain/build/gcc-$LUNA_ARCH
|
||||
rm -rf toolchain/build/gcc-$LUNA_GCC_VERSION_REQUIRED
|
||||
|
||||
echo Extracting GCC...
|
||||
@ -38,9 +38,9 @@ cd -
|
||||
|
||||
echo Configuring GCC...
|
||||
|
||||
mkdir -p toolchain/build/gcc-$ARCH
|
||||
mkdir -p toolchain/build/gcc-$LUNA_ARCH
|
||||
|
||||
cd toolchain/build/gcc-$ARCH
|
||||
cd toolchain/build/gcc-$LUNA_ARCH
|
||||
|
||||
unset CC
|
||||
unset CXX
|
||||
|
@ -2,9 +2,9 @@
|
||||
set -e
|
||||
source $(dirname $0)/setup-env.sh
|
||||
|
||||
if [ -x "$(command -v $ARCH-luna-ar)" ]
|
||||
if [ -x "$(command -v $LUNA_ARCH-luna-ar)" ]
|
||||
then
|
||||
if [ "$($ARCH-luna-ar --version | head -n 1 | awk '{ print $5 }')" == "$LUNA_BINUTILS_VERSION_REQUIRED" ]
|
||||
if [ "$($LUNA_ARCH-luna-ar --version | head -n 1 | awk '{ print $5 }')" == "$LUNA_BINUTILS_VERSION_REQUIRED" ]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
|
@ -2,9 +2,9 @@
|
||||
set -e
|
||||
source $(dirname $0)/setup-env.sh
|
||||
|
||||
if [ -x "$(command -v $ARCH-luna-gcc)" ]
|
||||
if [ -x "$(command -v $LUNA_ARCH-luna-gcc)" ]
|
||||
then
|
||||
if [ "$($ARCH-luna-gcc --version | head -n 1 | awk '{ print $3 }')" == "$LUNA_GCC_VERSION_REQUIRED" ]
|
||||
if [ "$($LUNA_ARCH-luna-gcc --version | head -n 1 | awk '{ print $3 }')" == "$LUNA_GCC_VERSION_REQUIRED" ]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user