diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..acb0e40 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,57 @@ +name: macos + +on: + push: + branches: [ 'main' ] + tags: + - '[0-9]+.[0-9]+.[0-9]+' + pull_request: + branches: [ 'main' ] + +env: + BUILD_TYPE: Release + +jobs: + build: + runs-on: macos-latest + + steps: + - name: 'Checkout' + uses: actions/checkout@v4 + + - name: 'Configure' + run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DAPP_VERSION="${{github.ref_name}}" + + - name: 'Build' + run: cmake --build build --config ${{env.BUILD_TYPE}} + + - name: 'Artifact' + uses: actions/upload-artifact@v4 + with: + name: 'objcurses-macos' + path: | + build/objcurses + + release-to-github: + if: github.ref_type == 'tag' + needs: + - build + runs-on: macos-latest + + permissions: + contents: write + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: 'objcurses-macos' + path: build/ + + - name: Zip + run: zip -j -r objcurses-macos-v${{github.ref_name}}.zip ./build/objcurses + + - name: Release + uses: softprops/action-gh-release@v2 + with: + files: objcurses-macos-v${{github.ref_name}}.zip diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 0000000..0df6235 --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,57 @@ +name: ubuntu + +on: + push: + branches: [ 'main' ] + tags: + - '[0-9]+.[0-9]+.[0-9]+' + pull_request: + branches: [ 'main' ] + +env: + BUILD_TYPE: Release + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: 'Checkout' + uses: actions/checkout@v4 + + - name: 'Configure' + run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DAPP_VERSION="${{github.ref_name}}" + + - name: 'Build' + run: cmake --build build --config ${{env.BUILD_TYPE}} + + - name: 'Artifact' + uses: actions/upload-artifact@v4 + with: + name: 'objcurses-linux' + path: | + build/objcurses + + release-to-github: + if: github.ref_type == 'tag' + needs: + - build + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: 'objcurses-linux' + path: build/ + + - name: Zip + run: zip -j -r objcurses-linux-v${{github.ref_name}}.zip ./build/objcurses + + - name: Release + uses: softprops/action-gh-release@v2 + with: + files: objcurses-linux-v${{github.ref_name}}.zip diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..7c21958 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,84 @@ +name: windows|mingw64 + +on: + push: + branches: [ 'main' ] + tags: + - '[0-9]+.[0-9]+.[0-9]+' + pull_request: + branches: [ 'main' ] + +env: + BUILD_TYPE: Release + +jobs: + build: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + + steps: + - name: 'Checkout' + uses: actions/checkout@v4 + + - name: 'Setup mingw64' + uses: msys2/setup-msys2@v2 + id: msys2 + with: + msystem: MINGW64 + update: true + install: >- + ncurses + ncurses-devel + pacboy: >- + toolchain:p + cmake:p + ninja:p + + - name: 'Configure' + run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DAPP_VERSION="${{github.ref_name}}" + + - name: 'Build' + run: cmake --build build --config ${{env.BUILD_TYPE}} + + - name: 'Run' + run: ./build/objcurses.exe --help + + - name: 'Package' + run: | + cp /mingw64/bin/libgcc_s_seh-1.dll ./build/ + cp /mingw64/bin/libstdc++-6.dll ./build/ + cp /mingw64/bin/libwinpthread-1.dll ./build/ + + - name: 'Artifact' + uses: actions/upload-artifact@v4 + with: + name: 'objcurses-windows' + path: | + build/*.exe + build/*.dll + + release-to-github: + if: github.ref_type == 'tag' + needs: + - build + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: 'objcurses-windows' + path: build/ + + - name: Zip + run: zip -j -r objcurses-windows-v${{github.ref_name}}.zip ./build/*.exe ./build/*.dll + + - name: Release + uses: softprops/action-gh-release@v2 + with: + files: objcurses-windows-v${{github.ref_name}}.zip diff --git a/.gitignore b/.gitignore index 077573b..d850bb4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # build directory +/build/ /cmake-build-debug/ /cmake-build-release/ /cmake-build-sanitize/ @@ -7,4 +8,7 @@ /package/ # ide settings -/.idea \ No newline at end of file +/.idea + +# other +*.zip diff --git a/CMakeLists.txt b/CMakeLists.txt index c6fffcd..4988f63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,18 +18,26 @@ if(SANITIZE) add_compile_definitions(ASAN_OPTIONS="detect_leaks=1:strict_string_checks=1:check_initialization_order=1:detect_stack_use_after_return=1:detect_container_overflow=1:abort_on_error=1") endif() +if (NOT DEFINED APP_VERSION) + set(APP_VERSION "0.0.0") +endif() + +# generate the version.h +configure_file(version.h.in version.h) + # collect all source files recursively, excluding build directory file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/*.cpp") list(FILTER SOURCES EXCLUDE REGEX ".*/.*build.*/.*") # creating executable add_executable(${PROJECT_NAME} ${SOURCES}) -target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}) +target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) +target_compile_definitions(${PROJECT_NAME} PRIVATE "NCURSES_STATIC") # linking ncurses library find_package(Curses REQUIRED) target_link_libraries(${PROJECT_NAME} PRIVATE ${CURSES_LIBRARIES}) -target_include_directories(${PROJECT_NAME} PRIVATE ${CURSES_INCLUDE_DIR}) +target_include_directories(${PROJECT_NAME} PRIVATE ${CURSES_INCLUDE_DIR} ${CURSES_INCLUDE_DIR}/ncurses) # linking math library target_link_libraries(${PROJECT_NAME} PRIVATE m) diff --git a/version.h b/version.h.in similarity index 64% rename from version.h rename to version.h.in index aa3d0ac..eb5c755 100644 --- a/version.h +++ b/version.h.in @@ -5,4 +5,4 @@ #pragma once inline constexpr auto APP_NAME = "objcurses"; -inline constexpr auto APP_VERSION = "2.2.1"; +#cmakedefine APP_VERSION "@APP_VERSION@"