diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c12df0..df27b27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,8 +87,13 @@ jobs: env: CMAKE_BUILD_TYPE: ${{matrix.CMAKE_BUILD_TYPE}} CMAKE_PREFIX_PATH: ${{steps.FETCH.outputs.CMAKE_PREFIX_PATH}} - BUSTER_GITHUB_MAIN_RUN: ${{ github.ref == 'refs/heads/main' }} - IS_CI: true + BB_IS_CI: true + - name: Upload artifact (7z) + uses: actions/upload-artifact@v4 + with: + name: ${{env.BLOAT_BUSTER_RELEASE_NAME_BASE}} + if-no-files-found: 'error' + path: ${{env.BLOAT_BUSTER_RELEASE_PATH_BASE}}.7z* - name: Release uses: softprops/action-gh-release@v2 if: github.ref == 'refs/heads/main' diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f08d03..79a7bfd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,13 +16,19 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_C_STANDARD 23) set(CMAKE_CXX_STANDARD 23) -set(IS_CI OFF CACHE BOOL "Variable that determines if the cmake script is run on the CI or not") +set(LIBRARY_NAME "std") +set(RUNNER_NAME "runner") +if (NOT COMPILER_NAME) + set(COMPILER_NAME "bb" CACHE STRING) +endif() -if (IS_CI) - set(IS_CI_C_FLAG "-DBB_CI=1") +set(BB_IS_CI OFF CACHE BOOL "Variable that determines if the cmake script is run on the CI or not") + +if (BB_IS_CI) + set(BB_IS_CI_C_FLAG "-DBB_CI=1") message(STATUS "CMake is run on CI") else() - set(IS_CI_C_FLAG "-DBB_CI=0") + set(BB_IS_CI_C_FLAG "-DBB_CI=0") message(STATUS "CMake is not run on CI") endif() @@ -33,7 +39,7 @@ add_compile_options( -fno-exceptions -fno-stack-protector -fdiagnostics-color=always -ferror-limit=1 -march=native - ${IS_CI_C_FLAG} + ${BB_IS_CI_C_FLAG} -DCOMPILER_NAME=\"${COMPILER_NAME}\" -DBUILD_DIR=\"${CMAKE_BINARY_DIR}\" -DBB_DIR=\"${BB_DIR}\" ) include_directories("bootstrap/include") @@ -141,10 +147,6 @@ endif() link_directories("${LLVM_LIBDIRS}") -set(LIBRARY_NAME "std") -set(RUNNER_NAME "runner") -set(COMPILER_NAME "bb") - add_library("${LIBRARY_NAME}" "bootstrap/std/base.c" "bootstrap/std/string.c" @@ -172,7 +174,7 @@ target_include_directories(${COMPILER_NAME} PRIVATE ${LLVM_INCLUDE_DIRS}) target_link_directories(${COMPILER_NAME} PRIVATE ${LLVM_LIBRARY_DIRS}) target_link_libraries(${COMPILER_NAME} PRIVATE ${LIBRARY_NAME} ${LLVM_LIBRARIES} ${lld_libs}) -if (NOT IS_CI) +if (NOT BB_IS_CI) set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) diff --git a/bootstrap/bloat-buster/main.c b/bootstrap/bloat-buster/main.c index 0327548..7e9806c 100644 --- a/bootstrap/bloat-buster/main.c +++ b/bootstrap/bloat-buster/main.c @@ -23569,7 +23569,7 @@ fn void code_generation(Thread* restrict thread, CodegenOptions options) VirtualBuffer(u8) code = {}; auto object_path = binary_path_from_options(thread->arena, (BinaryPathOptions) { - .build_directory = strlit(cache_dir), + .build_directory = strlit(BB_DIR), .name = options.test_name, .target = options.target, .backend = options.backend, @@ -23577,7 +23577,7 @@ fn void code_generation(Thread* restrict thread, CodegenOptions options) }); auto exe_path = binary_path_from_options(thread->arena, (BinaryPathOptions) { - .build_directory = strlit(cache_dir), + .build_directory = strlit(BB_DIR), .name = options.test_name, .target = options.target, .backend = options.backend, @@ -24816,7 +24816,7 @@ void entry_point(int argc, char* argv[], char* envp[]) Target target = native_target_get(); - os_directory_make(strlit(cache_dir)); + os_directory_make(strlit(BB_DIR)); File file = { .path = source_file_path, diff --git a/bootstrap/include/bloat-buster/base.h b/bootstrap/include/bloat-buster/base.h index 33b4f99..2631a70 100644 --- a/bootstrap/include/bloat-buster/base.h +++ b/bootstrap/include/bloat-buster/base.h @@ -3,8 +3,6 @@ #include #include -#define cache_dir "bb" - typedef enum CpuArchitecture : u8 { CPU_ARCH_X86_64, diff --git a/bootstrap/runner/runner.c b/bootstrap/runner/runner.c index 7b92c40..8a6fcba 100644 --- a/bootstrap/runner/runner.c +++ b/bootstrap/runner/runner.c @@ -6,8 +6,6 @@ #include -#define bb_dir "bb" - declare_slice(CompilerBackend); typedef enum CMakeBuildType @@ -109,7 +107,7 @@ fn void run_tests(Arena* arena, String compiler_path, TestOptions const * const // if (compiler_backend != COMPILER_BACKEND_INTERPRETER) { auto executable = binary_path_from_options(arena, (BinaryPathOptions) { - .build_directory = strlit(bb_dir), + .build_directory = strlit(BB_DIR), .name = test_name, .target = target, .backend = compiler_backend, @@ -242,7 +240,7 @@ void entry_point(int argc, char* argv[], char* envp[]) build_type = CMAKE_BUILD_TYPE_DEBUG; } - String compiler_path = strlit("build/bb"); + String compiler_path = strlit(BUILD_DIR "/" COMPILER_NAME); switch (command) { diff --git a/project.sh b/project.sh index 7f162a5..fb54762 100755 --- a/project.sh +++ b/project.sh @@ -52,14 +52,18 @@ if [[ -z "${CMAKE_PREFIX_PATH-}" ]]; then CMAKE_PREFIX_PATH="$HOME/Downloads/llvm-$BIRTH_ARCH-$BIRTH_OS-$CMAKE_BUILD_TYPE" fi -if [[ -z "${BUSTER_GITHUB_MAIN_RUN-}" ]]; then - BUSTER_GITHUB_MAIN_RUN=false +if [[ -n "${BB_IS_CI-}" ]]; then + BB_IS_CI=ON +else + BB_IS_CI=OFF fi -if [[ -n "${IS_CI-}" ]]; then - IS_CI=ON -else - IS_CI=OFF +if [[ -z "${COMPILER_NAME-}" ]]; then + COMPILER_NAME=bb +fi + +if [[ -z "${BB_DIR-}" ]]; then + BB_DIR=$COMPILER_NAME fi case $BIRTH_OS in @@ -93,7 +97,9 @@ cmake . \ -DCMAKE_C_COMPILER=$C_COMPILER_PATH \ -DCMAKE_CXX_COMPILER=$CXX_COMPILER_PATH \ -DCMAKE_ASM_COMPILER=$ASM_COMPILER_PATH \ - -DIS_CI=$IS_CI \ + -DCOMPILER_NAME=$COMPILER_NAME \ + -DBB_DIR=$BB_DIR \ + -DBB_IS_CI=$BB_IS_CI \ $USE_MOLD_OPT_ARG \ $C_COMPILER_OPT_ARG \ $CXX_COMPILER_OPT_ARG \ @@ -107,7 +113,7 @@ if [ "$#" -ne 0 ]; then $build_dir/runner $@ fi -if [ "$BUSTER_GITHUB_MAIN_RUN" == "true" ]; then +if [ "$BB_IS_CI" == "ON" ]; then case "$BIRTH_OS" in windows) OPT_EXTENSION=".exe";; @@ -115,7 +121,7 @@ if [ "$BUSTER_GITHUB_MAIN_RUN" == "true" ]; then OPT_EXTENSION="";; esac - BB_EXE_PATH="$build_dir/bb$OPT_EXTENSION" + BB_EXE_PATH="$build_dir/$COMPILER_NAME$OPT_EXTENSION" BB_INSTALL_NAME=bloat-buster-$BIRTH_ARCH-$BIRTH_OS-$CMAKE_BUILD_TYPE BB_INSTALL_PATH="$PWD/$BB_INSTALL_NAME" mkdir -p $BB_INSTALL_PATH @@ -128,5 +134,6 @@ if [ "$BUSTER_GITHUB_MAIN_RUN" == "true" ]; then *) ;; esac + echo "BLOAT_BUSTER_RELEASE_NAME_BASE=$BB_INSTALL_NAME" >> $GITHUB_ENV echo "BLOAT_BUSTER_RELEASE_PATH_BASE=$BB_INSTALL_PATH" >> $GITHUB_ENV fi