tools+CMake: Prefix all environment variables with LUNA_
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-01-21 22:44:16 +01:00
parent a3d0fa7d0a
commit a6974b605e
Signed by: apio
GPG Key ID: B8A7D06E42258954
21 changed files with 59 additions and 59 deletions

View File

@ -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_ROOT ${CMAKE_CURRENT_LIST_DIR})
set(LUNA_BASE ${CMAKE_CURRENT_LIST_DIR}/base) set(LUNA_BASE ${CMAKE_CURRENT_LIST_DIR}/base)
set(ARCH $ENV{ARCH}) set(LUNA_ARCH $ENV{LUNA_ARCH})
if(NOT DEFINED ARCH) if(NOT DEFINED LUNA_ARCH)
set(ARCH "x86_64") set(LUNA_ARCH "x86_64")
endif() endif()
set(CMAKE_C_COMPILER ${ARCH}-luna-gcc) set(CMAKE_C_COMPILER ${LUNA_ARCH}-luna-gcc)
set(CMAKE_CXX_COMPILER ${ARCH}-luna-g++) set(CMAKE_CXX_COMPILER ${LUNA_ARCH}-luna-g++)
set(CMAKE_ASM_COMPILER ${ARCH}-luna-gcc) set(CMAKE_ASM_COMPILER ${LUNA_ARCH}-luna-gcc)
set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64) 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(luna)
add_subdirectory(libc) add_subdirectory(libc)

View File

@ -26,7 +26,7 @@ set(SOURCES
src/ELF.cpp src/ELF.cpp
) )
if("${ARCH}" MATCHES "x86_64") if("${LUNA_ARCH}" MATCHES "x86_64")
set(SOURCES set(SOURCES
${SOURCES} ${SOURCES}
src/arch/x86_64/IO.cpp src/arch/x86_64/IO.cpp
@ -43,7 +43,7 @@ endif()
add_executable(moon ${SOURCES}) add_executable(moon ${SOURCES})
if("${ARCH}" MATCHES "x86_64") if("${LUNA_ARCH}" MATCHES "x86_64")
set(ASM_SOURCES set(ASM_SOURCES
src/arch/x86_64/CPU.asm src/arch/x86_64/CPU.asm
src/arch/x86_64/Entry.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 -fno-asynchronous-unwind-tables -fno-omit-frame-pointer)
target_compile_options(moon PRIVATE -nostdlib -mcmodel=kernel) 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-red-zone)
target_compile_options(moon PRIVATE -mno-80387 -mno-mmx -mno-sse -mno-sse2) target_compile_options(moon PRIVATE -mno-80387 -mno-mmx -mno-sse -mno-sse2)
target_link_options(moon PRIVATE -mno-red-zone) target_link_options(moon PRIVATE -mno-red-zone)

View File

@ -13,14 +13,14 @@ set(SOURCES
src/sys/mman.cpp src/sys/mman.cpp
) )
if(${ARCH} STREQUAL "x86_64") if(${LUNA_ARCH} STREQUAL "x86_64")
set(SOURCES set(SOURCES
${SOURCES} ${SOURCES}
src/arch/x86_64/syscall.S src/arch/x86_64/syscall.S
) )
endif() endif()
add_library(crt0 STATIC src/arch/${ARCH}/crt0.S) add_library(crt0 STATIC src/arch/${LUNA_ARCH}/crt0.S)
add_custom_command( add_custom_command(
TARGET crt0 TARGET crt0
COMMAND "${CMAKE_COMMAND}" -E copy $<TARGET_OBJECTS:crt0> ${LUNA_BASE}/usr/lib/crt0.o COMMAND "${CMAKE_COMMAND}" -E copy $<TARGET_OBJECTS:crt0> ${LUNA_BASE}/usr/lib/crt0.o

View File

@ -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 include/)
target_include_directories(luna PUBLIC ${LUNA_BASE}/usr/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-red-zone)
target_compile_options(luna-freestanding PRIVATE -mno-80387 -mno-mmx -mno-sse -mno-sse2) target_compile_options(luna-freestanding PRIVATE -mno-80387 -mno-mmx -mno-sse -mno-sse2)
target_compile_definitions(luna-freestanding PUBLIC ARCH_X86_64) target_compile_definitions(luna-freestanding PUBLIC ARCH_X86_64)

View File

@ -11,8 +11,8 @@ tools/full-clean.sh
tools/install-headers.sh tools/install-headers.sh
cmake -S . -B $BUILD_DIR -DMOON_DEBUG_SYMBOLS=ON -DLUNA_DEBUG_SYMBOLS=ON -G "$CMAKE_GEN" cmake -S . -B $LUNA_BUILD_DIR -DMOON_DEBUG_SYMBOLS=ON -DLUNA_DEBUG_SYMBOLS=ON -G "$LUNA_CMAKE_GENERATOR_NAME"
cmake --build $BUILD_DIR cmake --build $LUNA_BUILD_DIR
cmake --install $BUILD_DIR cmake --install $LUNA_BUILD_DIR
mkbootimg luna.json Luna.iso mkbootimg luna.json Luna.iso

View File

@ -9,9 +9,9 @@ tools/setup.sh
tools/install-headers.sh tools/install-headers.sh
mkdir -p $BUILD_DIR mkdir -p $LUNA_BUILD_DIR
cmake -S . -B $BUILD_DIR -G "$CMAKE_GEN" cmake -S . -B $LUNA_BUILD_DIR -G "$LUNA_CMAKE_GENERATOR_NAME"
cmake --build $BUILD_DIR cmake --build $LUNA_BUILD_DIR
cmake --install $BUILD_DIR cmake --install $LUNA_BUILD_DIR
mkbootimg luna.json Luna.iso mkbootimg luna.json Luna.iso

View File

@ -9,6 +9,6 @@ tools/setup.sh
tools/install-headers.sh tools/install-headers.sh
mkdir -p $BUILD_DIR mkdir -p $LUNA_BUILD_DIR
cmake -S . -B $BUILD_DIR -G "$CMAKE_GEN" cmake -S . -B $LUNA_BUILD_DIR -G "$LUNA_CMAKE_GENERATOR_NAME"
cmake --build $BUILD_DIR cmake --build $LUNA_BUILD_DIR

View File

@ -3,6 +3,6 @@ set -e
source $(dirname $0)/env.sh source $(dirname $0)/env.sh
cd $BUILD_DIR cd $LUNA_BUILD_DIR
$BUILD clean $LUNA_BUILD clean

View File

@ -3,4 +3,4 @@
set -e set -e
source $(dirname $0)/env.sh 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 $@

View File

@ -4,16 +4,16 @@ export LUNA_BASE=${LUNA_BASE:-$LUNA_ROOT/base}
[ -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} export LUNA_ARCH=${LUNA_ARCH:-x86_64}
export PATH=$LUNA_ROOT/toolchain/$ARCH-luna/bin:$LUNA_ROOT/toolchain/dist:$PATH export PATH=$LUNA_ROOT/toolchain/$LUNA_ARCH-luna/bin:$LUNA_ROOT/toolchain/dist:$PATH
if [ "$USE_MAKE" = "1" ] if [ "$USE_MAKE" = "1" ]
then then
export BUILD=make export LUNA_BUILD=make
export CMAKE_GEN="Unix Makefiles" export LUNA_CMAKE_GENERATOR_NAME="Unix Makefiles"
else else
export BUILD=ninja export LUNA_BUILD=ninja
export CMAKE_GEN="Ninja" export LUNA_CMAKE_GENERATOR_NAME="Ninja"
fi fi
export BUILD_DIR=$LUNA_ROOT/build/$BUILD-$ARCH export LUNA_BUILD_DIR=$LUNA_ROOT/build/$LUNA_BUILD-$LUNA_ARCH

View File

@ -5,4 +5,4 @@ source $(dirname $0)/env.sh
cd $LUNA_ROOT 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 $@

View File

@ -3,5 +3,5 @@ set -e
source $(dirname $0)/env.sh source $(dirname $0)/env.sh
rm -rf $BUILD_DIR rm -rf $LUNA_BUILD_DIR
mkdir -p $BUILD_DIR mkdir -p $LUNA_BUILD_DIR

View File

@ -3,6 +3,6 @@
set -e set -e
source $(dirname $0)/env.sh source $(dirname $0)/env.sh
cd $BUILD_DIR cd $LUNA_BUILD_DIR
gdb -x $LUNA_ROOT/.gdbconf gdb -x $LUNA_ROOT/.gdbconf

View File

@ -5,4 +5,4 @@ source $(dirname $0)/env.sh
cd $LUNA_ROOT cd $LUNA_ROOT
cmake --install $BUILD_DIR cmake --install $LUNA_BUILD_DIR

View File

@ -11,8 +11,8 @@ tools/full-clean.sh
tools/install-headers.sh tools/install-headers.sh
cmake -S . -B $BUILD_DIR -G "$CMAKE_GEN" cmake -S . -B $LUNA_BUILD_DIR -G "$LUNA_CMAKE_GENERATOR_NAME"
cmake --build $BUILD_DIR cmake --build $LUNA_BUILD_DIR
cmake --install $BUILD_DIR cmake --install $LUNA_BUILD_DIR
mkbootimg luna.json Luna.iso mkbootimg luna.json Luna.iso

View File

@ -11,5 +11,5 @@ tools/full-clean.sh
tools/install-headers.sh tools/install-headers.sh
cmake -S . -B $BUILD_DIR -G "$CMAKE_GEN" cmake -S . -B $LUNA_BUILD_DIR -G "$LUNA_CMAKE_GENERATOR_NAME"
cmake --build $BUILD_DIR cmake --build $LUNA_BUILD_DIR

View File

@ -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 wget -Otoolchain/tarballs/binutils-$LUNA_BINUTILS_VERSION_REQUIRED.tar.xz https://ftp.gnu.org/gnu/binutils/binutils-$LUNA_BINUTILS_VERSION_REQUIRED.tar.xz
fi fi
rm -rf toolchain/build/binutils-$ARCH rm -rf toolchain/build/binutils-$LUNA_ARCH
rm -rf toolchain/build/binutils-$LUNA_BINUTILS_VERSION_REQUIRED rm -rf toolchain/build/binutils-$LUNA_BINUTILS_VERSION_REQUIRED
echo Extracting Binutils... echo Extracting Binutils...
@ -30,9 +30,9 @@ cd -
echo Configuring Binutils... 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 CC
unset CXX unset CXX

View File

@ -4,6 +4,6 @@ source $(dirname $0)/env.sh
export LUNA_GCC_VERSION_REQUIRED=12.2.0 export LUNA_GCC_VERSION_REQUIRED=12.2.0
export LUNA_BINUTILS_VERSION_REQUIRED=2.39 export LUNA_BINUTILS_VERSION_REQUIRED=2.39
export BUILD_PREFIX=$LUNA_ROOT/toolchain/$ARCH-luna export BUILD_PREFIX=$LUNA_ROOT/toolchain/$LUNA_ARCH-luna
export BUILD_TARGET=$ARCH-luna export BUILD_TARGET=$LUNA_ARCH-luna
export BUILD_SYSROOT=$LUNA_ROOT/base export BUILD_SYSROOT=$LUNA_ROOT/base

View File

@ -4,7 +4,7 @@ source $(dirname $0)/setup-env.sh
cd $LUNA_ROOT cd $LUNA_ROOT
if [ ! -x $(command -v $ARCH-luna-as) ] if [ ! -x $(command -v $LUNA_ARCH-luna-as) ]
then then
echo Binutils should be cross-built before GCC. echo Binutils should be cross-built before GCC.
exit 1 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 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 fi
rm -rf toolchain/build/gcc-$ARCH rm -rf toolchain/build/gcc-$LUNA_ARCH
rm -rf toolchain/build/gcc-$LUNA_GCC_VERSION_REQUIRED rm -rf toolchain/build/gcc-$LUNA_GCC_VERSION_REQUIRED
echo Extracting GCC... echo Extracting GCC...
@ -38,9 +38,9 @@ cd -
echo Configuring GCC... 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 CC
unset CXX unset CXX

View File

@ -2,9 +2,9 @@
set -e set -e
source $(dirname $0)/setup-env.sh source $(dirname $0)/setup-env.sh
if [ -x "$(command -v $ARCH-luna-ar)" ] if [ -x "$(command -v $LUNA_ARCH-luna-ar)" ]
then 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 then
exit 0 exit 0
else else

View File

@ -2,9 +2,9 @@
set -e set -e
source $(dirname $0)/setup-env.sh source $(dirname $0)/setup-env.sh
if [ -x "$(command -v $ARCH-luna-gcc)" ] if [ -x "$(command -v $LUNA_ARCH-luna-gcc)" ]
then 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 then
exit 0 exit 0
else else