diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index dce2b5c..9861071 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -18,5 +18,4 @@ jobs: with: imageName: ghcr.io/dragonruby/internal-lightstorm-ci runCmd: | - cmake --preset lightstorm - cmake --build ./build.debug.dir/build -t run-integration-tests + cmake --workflow --preset lightstorm-ubuntu-ci diff --git a/.github/workflows/macos-ci.yml b/.github/workflows/macos-ci.yml index 88a53f5..05c08c9 100644 --- a/.github/workflows/macos-ci.yml +++ b/.github/workflows/macos-ci.yml @@ -15,21 +15,6 @@ jobs: run: brew install llvm@19 ninja - name: Install Python dependencies run: pip install lit filecheck==0.0.24 - - name: Set reusable strings - id: strings - shell: bash + - name: Build and test run: | - echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" - - name: Configure CMake - run: | - cmake -G Ninja \ - -B ${{ steps.strings.outputs.build-output-dir }} \ - -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \ - -DCMAKE_PREFIX_PATH=/opt/homebrew/opt/llvm@19/ \ - -DCMAKE_BUILD_TYPE=Release \ - -S ${{ github.workspace }} - - name: Build - run: cmake --build ${{ steps.strings.outputs.build-output-dir }} - - name: Test - working-directory: ${{ steps.strings.outputs.build-output-dir }} - run: ninja run-integration-tests + cmake --workflow --preset lightstorm-macos-ci diff --git a/.gitignore b/.gitignore index 46f8468..3ab094d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ Output build*dir +install*dir *.lit_test_times.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index c6fe6bc..51a76d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,12 @@ cmake_minimum_required(VERSION 3.27) -project(LightStorm) +project(lightstorm) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +include(GNUInstallDirs) + include(cmake/mruby.cmake) include(cmake/lightstorm.cmake) diff --git a/CMakePresets.json b/CMakePresets.json index 73c8daf..8576589 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -2,18 +2,115 @@ "version": 8, "configurePresets": [ { - "name": "lightstorm", - "displayName": "lightstorm", - "description": "Sets Ninja generator, build and install directory", + "name": "lightstorm-defaults", "generator": "Ninja", - "binaryDir": "${sourceDir}/build.debug.dir/build", + "binaryDir": "${sourceDir}/build.dir", + "installDir": "${sourceDir}/install.dir", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "lightstorm-ubuntu", + "inherits": "lightstorm-defaults", "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", "CMAKE_C_COMPILER": "clang-19", "CMAKE_CXX_COMPILER": "clang++-19", - "CMAKE_PREFIX_PATH": "/usr/lib/llvm-19/lib/cmake", - "CMAKE_INSTALL_PREFIX": "${sourceDir}/build.debug.dir/install" + "CMAKE_PREFIX_PATH": "/usr/lib/llvm-19/lib/cmake" } + }, + { + "name": "lightstorm-macos", + "inherits": "lightstorm-defaults", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++", + "CMAKE_PREFIX_PATH": "/opt/homebrew/opt/llvm@19" + } + } + ], + "buildPresets": [ + { + "name": "lightstorm-ubuntu", + "configurePreset": "lightstorm-ubuntu" + }, + { + "name": "lightstorm-ubuntu-tests", + "inherits": "lightstorm-ubuntu", + "targets": "run-integration-tests" + }, + { + "name": "lightstorm-ubuntu-install", + "inherits": "lightstorm-ubuntu", + "targets": "install" + }, + { + "name": "lightstorm-macos", + "configurePreset": "lightstorm-macos" + }, + { + "name": "lightstorm-macos-tests", + "inherits": "lightstorm-macos", + "targets": "run-integration-tests" + }, + { + "name": "lightstorm-macos-install", + "inherits": "lightstorm-macos", + "targets": "install" + } + ], + "workflowPresets": [ + { + "name": "lightstorm-ubuntu-ci", + "steps": [ + { + "type": "configure", + "name": "lightstorm-ubuntu" + }, + { + "type": "build", + "name": "lightstorm-ubuntu-tests" + } + ] + }, + { + "name": "lightstorm-ubuntu-install", + "steps": [ + { + "type": "configure", + "name": "lightstorm-ubuntu" + }, + { + "type": "build", + "name": "lightstorm-ubuntu-install" + } + ] + }, + { + "name": "lightstorm-macos-ci", + "steps": [ + { + "type": "configure", + "name": "lightstorm-macos" + }, + { + "type": "build", + "name": "lightstorm-macos-tests" + } + ] + }, + { + "name": "lightstorm-macos-install", + "steps": [ + { + "type": "configure", + "name": "lightstorm-macos" + }, + { + "type": "build", + "name": "lightstorm-macos-install" + } + ] } ] } diff --git a/cmake/mruby.cmake b/cmake/mruby.cmake index a47acda..467b791 100644 --- a/cmake/mruby.cmake +++ b/cmake/mruby.cmake @@ -20,11 +20,23 @@ ExternalProject_Add( add_executable(mruby_binary IMPORTED GLOBAL) set_property(TARGET mruby_binary PROPERTY IMPORTED_LOCATION ${MRUBY_BINARY}) add_dependencies(mruby_binary mruby) +install( + FILES $ + DESTINATION ${CMAKE_INSTALL_BINDIR} + RENAME lightstorm-mruby) add_executable(mrbc_binary IMPORTED GLOBAL) set_property(TARGET mrbc_binary PROPERTY IMPORTED_LOCATION ${MRBC_BINARY}) add_dependencies(mrbc_binary mruby) +install( + FILES $ + DESTINATION ${CMAKE_INSTALL_BINDIR} + RENAME lightstorm-mrbc) add_library(mruby_static STATIC IMPORTED GLOBAL) set_property(TARGET mruby_static PROPERTY IMPORTED_LOCATION ${MRUBY_STATIC}) add_dependencies(mruby_static mruby) +install( + FILES $ + DESTINATION ${CMAKE_INSTALL_LIBDIR} + RENAME liblightstorm_mruby.a) diff --git a/lib/runtime/CMakeLists.txt b/lib/runtime/CMakeLists.txt index e6de777..0299382 100644 --- a/lib/runtime/CMakeLists.txt +++ b/lib/runtime/CMakeLists.txt @@ -8,3 +8,5 @@ target_compile_options(lightstorm_runtime_main PRIVATE ${LIGHTSTORM_CFLAGS}) target_link_options(lightstorm_runtime_main PRIVATE ${LIGHTSTORM_CFLAGS}) target_link_libraries(lightstorm_runtime_main PUBLIC m) add_dependencies(lightstorm_runtime_main mruby_static) +install(TARGETS lightstorm_runtime_main) +install(FILES lightstorm_runtime.c DESTINATION ${CMAKE_INSTALL_LIBDIR})