diff --git a/.github/workflows/publish_deb.yml b/.github/workflows/publish_deb.yml index 50ca97c..15dfe37 100644 --- a/.github/workflows/publish_deb.yml +++ b/.github/workflows/publish_deb.yml @@ -1,6 +1,7 @@ name: Publish deb package on: + workflow_dispatch: push: branches: master @@ -20,55 +21,45 @@ jobs: release_branch: master use_api: true - build_deb_2004: + build_and_publish: needs: create_release - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04] steps: - - name: Install git - run: sudo apt-get -qq update -y && sudo apt-get -qq install cmake ninja-build rapidjson-dev -y + - name: Install dependencies + run: | + sudo apt-get -qq update -y + sudo apt-get -qq install cmake ninja-build rapidjson-dev libgtest-dev -y - name: Check out uses: actions/checkout@v4 - - name: Build package + - name: Build with testing enabled and run tests working-directory: . - run: mkdir build && cd build && cmake -GNinja .. && ninja && ninja package - - - name: Upload debian package to release - uses: softprops/action-gh-release@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ needs.create_release.outputs.v-version }} - files: | - build/*.deb - - build_deb_2204: - needs: create_release - runs-on: ubuntu-22.04 - - steps: - - name: Install dependencies - run: sudo apt-get -qq update -y && sudo apt-get -qq install cmake ninja-build rapidjson-dev -y - - - name: Check out - uses: actions/checkout@v4 + run: | + cmake -B build -GNinja -DENABLE_TESTING=ON + ninja -C build test + + - name: Remove build directory after tests + if: success() # Only run if tests pass + run: rm -rf build - name: Build package + if: success() # Only run if tests pass working-directory: . run: | - mkdir build - cd build - cmake -GNinja .. -DVERSION=${{ needs.create_release.outputs.v-version }} - ninja - ninja package + cmake -B build -GNinja -DVERSION=${{ needs.create_release.outputs.v-version }} -DCMAKE_INSTALL_PREFIX=/usr + ninja -C build package - name: Upload debian package to release + if: success() # Only run if package build succeeds uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ needs.create_release.outputs.v-version }} files: | - build/*.deb \ No newline at end of file + build/*.deb diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cc09f6..1591049 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ +cmake_minimum_required(VERSION 3.15) project(libosi) +include(GNUInstallDirs) -cmake_minimum_required(VERSION 3.0.2) - -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) @@ -112,9 +112,11 @@ target_link_libraries(osi offset ${GLIB_PKG_LIBRARIES}) # Install everything install(TARGETS osi osi-static offset offset-static iohal iohal-static - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) # Install the headers install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ diff --git a/CPackConfig.txt b/CPackConfig.txt index 122736e..428394c 100644 --- a/CPackConfig.txt +++ b/CPackConfig.txt @@ -34,5 +34,7 @@ if(UBUNTU_CHECK STREQUAL "Ubuntu") set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${UBUNTU_VERSION}") endif() -include(CPack) +# Include additional control files +set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/triggers") +include(CPack) \ No newline at end of file diff --git a/README.md b/README.md index fcc7355..8476513 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,8 @@ sudo apt-get install cmake ninja-build rapidjson-dev To build libosi, from the root of this repo run: ```bash -mkdir build && cd $_ -cmake -GNinja .. -ninja +cmake -B build -GNinja +ninja -C build ``` ### Installing @@ -45,8 +44,9 @@ ninja Installing libosi includes running: ```bash -cd build && ninja package -sudo dpkg -i libosi-[version].deb +ninja -C build package +cd build +sudo dpkg -i libosi_[ubuntu-version].deb ``` ### Testing @@ -57,13 +57,10 @@ first need to install dependencies and enable testing: ```bash sudo apt-get install libgtest-dev -cd build -cmake -GNinja -DENABLE_TESTING=ON .. -ninja +cmake -B build -GNinja -DENABLE_TESTING=ON +ninja -C build test ``` -You can then run the tests with just `ninja test`. - ### Development Adding support for other Windows and Linux kernels can be as simple as adding a new profile diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9407c3f..dddb813 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.15) set(GTEST_SRC_DIR "/usr/src/gtest" CACHE PATH "Path to google test source") if (NOT EXISTS ${GTEST_SRC_DIR}) message(WARNING "Could not find ${GTEST_SRC_DIR}") diff --git a/tests/iohal/CMakeLists.txt b/tests/iohal/CMakeLists.txt index 1a7cfe7..b25f726 100644 --- a/tests/iohal/CMakeLists.txt +++ b/tests/iohal/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.15) add_executable(test-sparsemem ${CMAKE_CURRENT_SOURCE_DIR}/sparse_pmem.h ${CMAKE_CURRENT_SOURCE_DIR}/sparse_pmem.cc ${CMAKE_CURRENT_SOURCE_DIR}/test_sparse_pmem.cc) diff --git a/tests/offset/CMakeLists.txt b/tests/offset/CMakeLists.txt index 3672602..19dddbc 100644 --- a/tests/offset/CMakeLists.txt +++ b/tests/offset/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.15) add_executable(test-offset-basic ${CMAKE_CURRENT_SOURCE_DIR}/test_basic.cc) target_link_libraries(test-offset-basic offset-static gtest_main) add_test(TestBasicOffsets test-offset-basic) diff --git a/tests/wintrospection/CMakeLists.txt b/tests/wintrospection/CMakeLists.txt index cbe6716..066abdc 100644 --- a/tests/wintrospection/CMakeLists.txt +++ b/tests/wintrospection/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.15) add_executable(test-basic test_basic.cc) target_link_libraries(test-basic wintrospection gtest_main offset iohal) add_test(Wintrospection test-basic) diff --git a/triggers b/triggers new file mode 100644 index 0000000..c8e3b01 --- /dev/null +++ b/triggers @@ -0,0 +1,2 @@ +# Trigger ldconfig after install +activate-noawait ldconfig \ No newline at end of file