diff --git a/.github/workflows/_src_android_builds.yml b/.github/workflows/_src_android_builds.yml new file mode 100644 index 0000000..a8b97e2 --- /dev/null +++ b/.github/workflows/_src_android_builds.yml @@ -0,0 +1,90 @@ +# xrlib + +name: _src_android_builds + +on: + workflow_call: + inputs: + matrix-json: + description: 'Build matrix json' + required: true + type: string + build-as-static: + description: 'Whether to build as a static library (ON/OFF)' + required: true + type: string + export-artifacts: + description: 'Whether to export artifacts (ON/OFF)' + required: true + type: string + + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: ${{ fromJson(inputs['matrix-json']) }} + + steps: + - name: Checkout code + uses: actions/checkout@v4.1.7 + with: + submodules: recursive + fetch-depth: 1 + + - name: Get cmake-latest + uses: lukka/get-cmake@latest + + - name: Setup ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: android-arm64-v8a-${{ matrix.build_type }}-c++_shared + + - name: Configure CMake on Android (shared library) + if: ${{ inputs.build-as-static == 'OFF' }} + run: | + cmake -S . -B build/ --toolchain $ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \ + -D ANDROID_PLATFORM=33 \ + -D CMAKE_ANDROID_ARCH_ABI=arm64-v8a \ + -D CMAKE_ANDROID_STL_TYPE=c++_shared \ + -D ANDROID_NDK=$ANDROID_NDK_ROOT \ + -D ANDROID_USE_LEGACY_TOOLCHAIN_FILE=NO \ + -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -D BUILD_AS_STATIC=OFF \ + -D ENABLE_XRVK=${{ matrix.enable_xrvk }} \ + -D BUILD_TESTS=OFF \ + -D UPDATE_DEPS=ON \ + -D BUILD_WERROR=ON + env: + CMAKE_C_COMPILER_LAUNCHER: ccache + CMAKE_CXX_COMPILER_LAUNCHER: ccache + + - name: Configure CMake on Android (static library) + if: ${{ inputs.build-as-static == 'ON' }} + run: | + cmake -S . -B build/ --toolchain $ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \ + -D ANDROID_PLATFORM=33 \ + -D CMAKE_ANDROID_ARCH_ABI=arm64-v8a \ + -D CMAKE_ANDROID_STL_TYPE=c++_static \ + -D ANDROID_NDK=$ANDROID_NDK_ROOT \ + -D ANDROID_USE_LEGACY_TOOLCHAIN_FILE=NO \ + -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -D BUILD_AS_STATIC=ON \ + -D ENABLE_XRVK=${{ matrix.enable_xrvk }} \ + -D BUILD_TESTS=OFF \ + -D UPDATE_DEPS=ON \ + -D BUILD_WERROR=ON + env: + CMAKE_C_COMPILER_LAUNCHER: ccache + CMAKE_CXX_COMPILER_LAUNCHER: ccache + + - name: Build xrlib + run: cmake --build build/ + + - name: Upload build artifact + if: ${{ inputs.export-artifacts == 'ON' }} + uses: actions/upload-artifact@v4 + with: + name: xrlib-static_${{ inputs.build-as-static }}-xrvk_${{ matrix.enable_xrvk }} + path: lib diff --git a/.github/workflows/_src_desktop_builds.yml b/.github/workflows/_src_desktop_builds.yml new file mode 100644 index 0000000..50983ae --- /dev/null +++ b/.github/workflows/_src_desktop_builds.yml @@ -0,0 +1,102 @@ +# xrlib +# Vulkan is installed on the runner prior to compilation + +name: _src_desktop_builds + +on: + workflow_call: + inputs: + matrix-json: + description: 'Build matrix json' + required: true + type: string + build-as-static: + description: 'Whether to build as a static library (ON/OFF)' + required: true + type: string + export-artifacts: + description: 'Whether to export artifacts (ON/OFF)' + required: true + type: string + + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: ${{ fromJson(inputs['matrix-json']) }} + + steps: + - name: Checkout code + uses: actions/checkout@v4.1.7 + with: + submodules: recursive + fetch-depth: 1 + + - name: Archive source code + if: ${{ (inputs.export-artifacts == 'ON') && (matrix.os == 'windows-latest') && (inputs.build-as-static == 'OFF') && (matrix.enable_xrvk == 'ON') }} + uses: actions/upload-artifact@v4 + with: + name: xrlib-source + path: ./ + + - name: Set reusable strings + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: Prepare Vulkan SDK + uses: humbletim/setup-vulkan-sdk@main + with: + vulkan-query-version: 1.3.204.0 + vulkan-components: Vulkan-Headers, Vulkan-Loader + vulkan-use-cache: true + + - name: Configure CMake on Linux + if: runner.os == 'Linux' + run: | + cmake -B ${{ steps.strings.outputs.build-output-dir }} \ + -D CMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ + -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -D BUILD_AS_STATIC=${{ inputs.build-as-static }} \ + -D ENABLE_XRVK=${{ matrix.enable_xrvk }} \ + -S ${{ github.workspace }} + + - name: Configure CMake on Windows + if: runner.os == 'Windows' + run: | + cmake -B ${{ steps.strings.outputs.build-output-dir }} ` + -D CMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} ` + -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} ` + -D BUILD_AS_STATIC=${{ inputs.build-as-static }} ` + -D ENABLE_XRVK=${{ matrix.enable_xrvk }} ` + -S ${{ github.workspace }} + + - name: Build xrlib + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + + - name: Upload build artifact (windows dll & symbol exports) + if: ${{ inputs.export-artifacts == 'ON' && (matrix.os == 'windows-latest') && (inputs.build-as-static == 'OFF') }} + uses: actions/upload-artifact@v4 + with: + name: xrlib-${{ matrix.os }}_compiler_${{ matrix.cpp_compiler }}_static_${{ inputs.build-as-static }}-xrvk_${{ matrix.enable_xrvk }} + path: | + bin + lib + + - name: Upload build artifact (windows static) + if: ${{ inputs.export-artifacts == 'ON' && (matrix.os == 'windows-latest') && (inputs.build-as-static == 'ON') }} + uses: actions/upload-artifact@v4 + with: + name: xrlib-${{ matrix.os }}_compiler_${{ matrix.cpp_compiler }}_static_${{ inputs.build-as-static }}-xrvk_${{ matrix.enable_xrvk }} + path: lib + + - name: Upload build artifact (linux) + if: ${{ inputs.export-artifacts == 'ON' && (matrix.os == 'ubuntu-latest') }} + uses: actions/upload-artifact@v4 + with: + name: xrlib-${{ matrix.os }}_compiler_${{ matrix.cpp_compiler }}_static_${{ inputs.build-as-static }}-xrvk_${{ matrix.enable_xrvk }} + path: lib diff --git a/.github/workflows/android_builds.yml b/.github/workflows/android_builds.yml index 7862fd5..ef58938 100644 --- a/.github/workflows/android_builds.yml +++ b/.github/workflows/android_builds.yml @@ -1,48 +1,22 @@ # xrlib -name: Android builds [ arm64-v8a, Debug|Release ] +name: android-latest on: push: - branches: [ "**" ] + branches: ['**'] pull_request: - branches: [ "**" ] + branches: ['main'] -jobs: - build: - - runs-on: ubuntu-latest - - strategy: - matrix: - build_type: [Debug, Release] - - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: lukka/get-cmake@latest - - - name: Setup ccache - uses: hendrikmuhs/ccache-action@v1.2 +jobs: + build-shared: + uses: ./.github/workflows/_src_android_builds.yml with: - key: android-arm64-v8a-${{ matrix.build_type }}-c++_shared - - - name: Configure CMake on Android - run: | - cmake -S . -B build/ --toolchain $ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \ - -D ANDROID_PLATFORM=26 \ - -D CMAKE_ANDROID_ARCH_ABI=arm64-v8a \ - -D CMAKE_ANDROID_STL_TYPE=c++_shared \ - -D ANDROID_NDK=$ANDROID_NDK_ROOT \ - -D ANDROID_USE_LEGACY_TOOLCHAIN_FILE=NO \ - -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -D BUILD_TESTS=OFF \ - -D UPDATE_DEPS=ON \ - -D BUILD_WERROR=ON - env: - CMAKE_C_COMPILER_LAUNCHER: ccache - CMAKE_CXX_COMPILER_LAUNCHER: ccache - - - run: cmake --build build/ + matrix-json: > + { + "build_type": ["debug", "release"], + "enable_xrvk": ["ON", "OFF"] + } + build-as-static : "OFF" + export-artifacts: "OFF" diff --git a/.github/workflows/android_releases.yml b/.github/workflows/android_releases.yml new file mode 100644 index 0000000..1aafe1c --- /dev/null +++ b/.github/workflows/android_releases.yml @@ -0,0 +1,83 @@ +# xrlib + +name: android-releases + +on: + push: + tags: + - 'v*.*.*.*' + + +jobs: + build-shared: + uses: ./.github/workflows/_src_android_builds.yml + with: + matrix-json: > + { + "build_type": ["release"], + "enable_xrvk": ["ON", "OFF"] + } + build-as-static : "OFF" + export-artifacts: "ON" + + build-static: + uses: ./.github/workflows/_src_android_builds.yml + with: + matrix-json: > + { + "build_type": ["release"], + "enable_xrvk": ["ON", "OFF"] + } + build-as-static : "ON" + export-artifacts: "ON" + + package-release: + runs-on: ubuntu-latest + needs: [build-shared, build-static] + steps: + - run: | + mkdir ${{ github.ref_name }}_xrlib_binaries_android-shared + mkdir ${{ github.ref_name }}_xrlib_binaries_android-shared/with_renderer + mkdir ${{ github.ref_name }}_xrlib_binaries_android-shared/no_renderer + mkdir ${{ github.ref_name }}_xrlib_binaries_android-static + mkdir ${{ github.ref_name }}_xrlib_binaries_android-static/with_renderer + mkdir ${{ github.ref_name }}_xrlib_binaries_android-static/no_renderer + + # Download build artifacts + - uses: actions/download-artifact@v4 + with: + name: xrlib-static_OFF-xrvk_ON + path: ${{ github.ref_name }}_xrlib_binaries_android-shared/with_renderer + + - uses: actions/download-artifact@v4 + with: + name: xrlib-static_OFF-xrvk_OFF + path: ${{ github.ref_name }}_xrlib_binaries_android-shared/no_renderer + + - uses: actions/download-artifact@v4 + with: + name: xrlib-static_ON-xrvk_ON + path: ${{ github.ref_name }}_xrlib_binaries_android-static/with_renderer + + - uses: actions/download-artifact@v4 + with: + name: xrlib-static_ON-xrvk_OFF + path: ${{ github.ref_name }}_xrlib_binaries_android-static/no_renderer + + # Upload final release artifacts + - uses: actions/upload-artifact@v4 + with: + name: xrlib-${{ github.ref_name }}-android-shared-libs + path: ./${{ github.ref_name }}_xrlib_binaries_android-shared + + - uses: actions/upload-artifact@v4 + with: + name: xrlib-${{ github.ref_name }}-android-static-libs + path: ./${{ github.ref_name }}_xrlib_binaries_android-static + + - uses: geekyeggo/delete-artifact@v5 + with: + name: | + xrlib-shared_* + xrlib-static_* + failOnError: false diff --git a/.github/workflows/desktop_builds.yml b/.github/workflows/desktop_builds.yml deleted file mode 100644 index c3d3d38..0000000 --- a/.github/workflows/desktop_builds.yml +++ /dev/null @@ -1,77 +0,0 @@ -# xrlib -# Vulkan is installed on the runner prior to compilation - -name: Desktop builds [ Linux|Windows, Debug|Release, g++|clang++|cl ] - -on: - push: - branches: [ "**" ] - pull_request: - branches: [ "**" ] - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest] - build_type: [Debug, Release] - cpp_compiler: [g++, clang++, cl] - include: - - os: windows-latest - cpp_compiler: cl - - os: ubuntu-latest - cpp_compiler: g++ - - os: ubuntu-latest - cpp_compiler: clang++ - exclude: - - os: windows-latest - cpp_compiler: g++ - - os: windows-latest - cpp_compiler: clang++ - - os: ubuntu-latest - cpp_compiler: cl - - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - fetch-depth: 1 - - - name: Set reusable strings - id: strings - shell: bash - run: | - echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" - - - name: Prepare Vulkan SDK - uses: humbletim/setup-vulkan-sdk@v1.2.0 - with: - vulkan-query-version: 1.3.204.0 - vulkan-components: Vulkan-Headers, Vulkan-Loader - vulkan-use-cache: true - - - name: Configure CMake on Linux - if: runner.os == 'Linux' - run: | - cmake -B ${{ steps.strings.outputs.build-output-dir }} \ - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -S ${{ github.workspace }} - - - name: Configure CMake on Windows - if: runner.os == 'Windows' - run: | - cmake -B ${{ steps.strings.outputs.build-output-dir }} ` - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} ` - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ` - -S ${{ github.workspace }} - - - name: Build - run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} - - - name: Test - working-directory: ${{ steps.strings.outputs.build-output-dir }} - run: ctest --build-config ${{ matrix.build_type }} diff --git a/.github/workflows/desktop_releases.yml b/.github/workflows/desktop_releases.yml new file mode 100644 index 0000000..6e5c8dd --- /dev/null +++ b/.github/workflows/desktop_releases.yml @@ -0,0 +1,246 @@ +# xrlib + +name: desktop-releases + +on: + push: + tags: + - 'v*.*.*.*' + +jobs: + build-shared: + uses: ./.github/workflows/_src_desktop_builds.yml + with: + matrix-json: > + { + "os": ["ubuntu-latest", "windows-latest"], + "build_type": ["release"], + "cpp_compiler": ["g++", "clang++", "cl"], + "enable_xrvk": ["ON", "OFF"], + "include": [ + { + "os": "windows-latest", + "cpp_compiler": "cl" + }, + { + "os": "ubuntu-latest", + "cpp_compiler": "g++" + }, + { + "os": "ubuntu-latest", + "cpp_compiler": "clang++" + } + ], + "exclude": [ + { + "os": "windows-latest", + "cpp_compiler": "g++" + }, + { + "os": "windows-latest", + "cpp_compiler": "clang++" + }, + { + "os": "ubuntu-latest", + "cpp_compiler": "cl" + } + ] + } + build-as-static : "OFF" + export-artifacts: "ON" + + build-static: + uses: ./.github/workflows/_src_desktop_builds.yml + with: + matrix-json: > + { + "os": ["ubuntu-latest", "windows-latest"], + "build_type": ["release"], + "cpp_compiler": ["g++", "clang++", "cl"], + "enable_xrvk": ["ON", "OFF"], + "include": [ + { + "os": "windows-latest", + "cpp_compiler": "cl" + }, + { + "os": "ubuntu-latest", + "cpp_compiler": "g++" + }, + { + "os": "ubuntu-latest", + "cpp_compiler": "clang++" + } + ], + "exclude": [ + { + "os": "windows-latest", + "cpp_compiler": "g++" + }, + { + "os": "windows-latest", + "cpp_compiler": "clang++" + }, + { + "os": "ubuntu-latest", + "cpp_compiler": "cl" + } + ] + } + build-as-static : "ON" + export-artifacts: "ON" + + package-includes: + runs-on: ubuntu-latest + needs: [build-shared, build-static] + steps: + - run: | + mkdir ${{ github.ref_name }}_xrlib_source + mkdir ${{ github.ref_name }}_xrlib_include + + - uses: actions/download-artifact@v4 + with: + name: xrlib-source + path: ${{ github.ref_name }}_xrlib_source + + - run: | + rm -f ./${{ github.ref_name }}_xrlib_source/include/project_config.h + cp -r ./${{ github.ref_name }}_xrlib_source/include ./${{ github.ref_name }}_xrlib_include + cp ./${{ github.ref_name }}_xrlib_source/LICENSE ./${{ github.ref_name }}_xrlib_include/include + cp -r ./${{ github.ref_name }}_xrlib_source/third_party/openxr/include/openxr ./${{ github.ref_name }}_xrlib_include + cp ./${{ github.ref_name }}_xrlib_source/third_party/openxr/LICENSE ./${{ github.ref_name }}_xrlib_include/openxr + + - uses: actions/upload-artifact@v4 + with: + name: xrlib-${{ github.ref_name }}-INCLUDE + path: ./${{ github.ref_name }}_xrlib_include + + - uses: geekyeggo/delete-artifact@v5 + with: + name: xrlib-source + failOnError: false + + package-windows: + runs-on: windows-latest + needs: [build-shared, build-static] + steps: + - run: | + mkdir ${{ github.ref_name }}_xrlib_binaries_windows-shared + mkdir ${{ github.ref_name }}_xrlib_binaries_windows-shared/with_renderer + mkdir ${{ github.ref_name }}_xrlib_binaries_windows-shared/no_renderer + mkdir ${{ github.ref_name }}_xrlib_binaries_windows-static + mkdir ${{ github.ref_name }}_xrlib_binaries_windows-static/with_renderer + mkdir ${{ github.ref_name }}_xrlib_binaries_windows-static/no_renderer + + - uses: actions/download-artifact@v4 + with: + name: xrlib-windows-latest_compiler_cl_static_OFF-xrvk_ON + path: ${{ github.ref_name }}_xrlib_binaries_windows-shared/with_renderer + + - uses: actions/download-artifact@v4 + with: + name: xrlib-windows-latest_compiler_cl_static_OFF-xrvk_OFF + path: ${{ github.ref_name }}_xrlib_binaries_windows-shared/no_renderer + + - uses: actions/download-artifact@v4 + with: + name: xrlib-windows-latest_compiler_cl_static_ON-xrvk_ON + path: ${{ github.ref_name }}_xrlib_binaries_windows-static/with_renderer + + - uses: actions/download-artifact@v4 + with: + name: xrlib-windows-latest_compiler_cl_static_ON-xrvk_OFF + path: ${{ github.ref_name }}_xrlib_binaries_windows-static/no_renderer + + - uses: actions/upload-artifact@v4 + with: + name: xrlib_${{ github.ref_name }}-windows-shared-libs + path: ./${{ github.ref_name }}_xrlib_binaries_windows-shared + + - uses: actions/upload-artifact@v4 + with: + name: xrlib_${{ github.ref_name }}-windows-static-libs + path: ./${{ github.ref_name }}_xrlib_binaries_windows-static + + - uses: geekyeggo/delete-artifact@v5 + with: + name: xrlib-windows-latest_* + failOnError: false + + package-linux: + runs-on: ubuntu-latest + needs: [build-shared, build-static] + steps: + - run: | + mkdir ${{ github.ref_name }}_xrlib_binaries_ubuntu-shared + mkdir ${{ github.ref_name }}_xrlib_binaries_ubuntu-shared/gnu + mkdir ${{ github.ref_name }}_xrlib_binaries_ubuntu-shared/gnu/with_renderer + mkdir ${{ github.ref_name }}_xrlib_binaries_ubuntu-shared/gnu/no_renderer + mkdir ${{ github.ref_name }}_xrlib_binaries_ubuntu-shared/clang + mkdir ${{ github.ref_name }}_xrlib_binaries_ubuntu-shared/clang/with_renderer + mkdir ${{ github.ref_name }}_xrlib_binaries_ubuntu-shared/clang/no_renderer + mkdir ${{ github.ref_name }}_xrlib_binaries_ubuntu-static + mkdir ${{ github.ref_name }}_xrlib_binaries_ubuntu-static/gnu + mkdir ${{ github.ref_name }}_xrlib_binaries_ubuntu-static/gnu/with_renderer + mkdir ${{ github.ref_name }}_xrlib_binaries_ubuntu-static/gnu/no_renderer + mkdir ${{ github.ref_name }}_xrlib_binaries_ubuntu-static/clang + mkdir ${{ github.ref_name }}_xrlib_binaries_ubuntu-static/clang/with_renderer + mkdir ${{ github.ref_name }}_xrlib_binaries_ubuntu-static/clang/no_renderer + + # Assemble all shared libraries + - uses: actions/download-artifact@v4 + with: + name: xrlib-ubuntu-latest_compiler_g++_static_OFF-xrvk_ON + path: ${{ github.ref_name }}_xrlib_binaries_ubuntu-shared/gnu/with_renderer + + - uses: actions/download-artifact@v4 + with: + name: xrlib-ubuntu-latest_compiler_g++_static_OFF-xrvk_OFF + path: ${{ github.ref_name }}_xrlib_binaries_ubuntu-shared/gnu/no_renderer + + - uses: actions/download-artifact@v4 + with: + name: xrlib-ubuntu-latest_compiler_clang++_static_OFF-xrvk_ON + path: ${{ github.ref_name }}_xrlib_binaries_ubuntu-shared/clang/with_renderer + + - uses: actions/download-artifact@v4 + with: + name: xrlib-ubuntu-latest_compiler_clang++_static_OFF-xrvk_OFF + path: ${{ github.ref_name }}_xrlib_binaries_ubuntu-shared/clang/no_renderer + + # Assemble all static libraries + - uses: actions/download-artifact@v4 + with: + name: xrlib-ubuntu-latest_compiler_g++_static_ON-xrvk_ON + path: ${{ github.ref_name }}_xrlib_binaries_ubuntu-static/gnu/with_renderer + + - uses: actions/download-artifact@v4 + with: + name: xrlib-ubuntu-latest_compiler_g++_static_ON-xrvk_OFF + path: ${{ github.ref_name }}_xrlib_binaries_ubuntu-static/gnu/no_renderer + + - uses: actions/download-artifact@v4 + with: + name: xrlib-ubuntu-latest_compiler_clang++_static_ON-xrvk_ON + path: ${{ github.ref_name }}_xrlib_binaries_ubuntu-static/clang/with_renderer + + - uses: actions/download-artifact@v4 + with: + name: xrlib-ubuntu-latest_compiler_clang++_static_ON-xrvk_OFF + path: ${{ github.ref_name }}_xrlib_binaries_ubuntu-static/clang/no_renderer + + # Upload finalized library compilations + - uses: actions/upload-artifact@v4 + with: + name: xrlib_${{ github.ref_name }}-ubuntu-shared-libs + path: ./${{ github.ref_name }}_xrlib_binaries_ubuntu-shared + + - uses: actions/upload-artifact@v4 + with: + name: xrlib_${{ github.ref_name }}-ubuntu-static-libs + path: ./${{ github.ref_name }}_xrlib_binaries_ubuntu-static + + - uses: geekyeggo/delete-artifact@v5 + with: + name: xrlib-ubuntu-latest_* + failOnError: false diff --git a/.github/workflows/no_xrvk.yml b/.github/workflows/no_xrvk.yml deleted file mode 100644 index ed70d5e..0000000 --- a/.github/workflows/no_xrvk.yml +++ /dev/null @@ -1,115 +0,0 @@ -# xrlib -# Vulkan is installed on the runner prior to compilation - -name: Exclude optional module [ xrvk - pbr renderer ] - -on: - push: - branches: [ "**" ] - pull_request: - branches: [ "**" ] - -jobs: - desktop-builds: - name: Desktop builds [ Linux|Windows, g++|clang++|cl ] - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest] - build_type: [Release] - cpp_compiler: [g++, cl] - include: - - os: windows-latest - cpp_compiler: cl - - os: ubuntu-latest - cpp_compiler: g++ - exclude: - - os: windows-latest - cpp_compiler: g++ - - os: ubuntu-latest - cpp_compiler: cl - - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - fetch-depth: 1 - - - name: Set reusable strings - id: strings - shell: bash - run: | - echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" - - - name: Prepare Vulkan SDK - uses: humbletim/setup-vulkan-sdk@v1.2.0 - with: - vulkan-query-version: 1.3.204.0 - vulkan-components: Vulkan-Headers, Vulkan-Loader - vulkan-use-cache: true - - - name: Configure CMake on Linux - if: runner.os == 'Linux' - run: | - cmake -B ${{ steps.strings.outputs.build-output-dir }} \ - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -DENABLE_XRVK=OFF \ - -S ${{ github.workspace }} - - - name: Configure CMake on Windows - if: runner.os == 'Windows' - run: | - cmake -B ${{ steps.strings.outputs.build-output-dir }} ` - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} ` - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ` - -DENABLE_XRVK=OFF ` - -S ${{ github.workspace }} - - - name: Build - run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} - - - name: Test - working-directory: ${{ steps.strings.outputs.build-output-dir }} - run: ctest --build-config ${{ matrix.build_type }} - - android-builds: - name: Android builds [ arm64-v8a, Debug|Release ] - - runs-on: ubuntu-latest - - strategy: - matrix: - build_type: [Debug, Release] - - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - - uses: lukka/get-cmake@latest - - - name: Setup ccache - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: android-arm64-v8a-${{ matrix.build_type }}-c++_shared - - - name: Configure CMake on Android - run: | - cmake -S . -B build/ --toolchain $ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \ - -D ANDROID_PLATFORM=26 \ - -D CMAKE_ANDROID_ARCH_ABI=arm64-v8a \ - -D CMAKE_ANDROID_STL_TYPE=c++_shared \ - -D ANDROID_NDK=$ANDROID_NDK_ROOT \ - -D ANDROID_USE_LEGACY_TOOLCHAIN_FILE=NO \ - -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -D BUILD_TESTS=OFF \ - -D UPDATE_DEPS=ON \ - -D BUILD_WERROR=ON - env: - CMAKE_C_COMPILER_LAUNCHER: ccache - CMAKE_CXX_COMPILER_LAUNCHER: ccache - - - run: cmake --build build/ diff --git a/.github/workflows/ubuntu_builds.yml b/.github/workflows/ubuntu_builds.yml new file mode 100644 index 0000000..45449cf --- /dev/null +++ b/.github/workflows/ubuntu_builds.yml @@ -0,0 +1,24 @@ +# xrlib + +name: ubuntu-latest + +on: + push: + branches: ['**'] + pull_request: + branches: ['main'] + + +jobs: + build: + uses: ./.github/workflows/_src_desktop_builds.yml + with: + matrix-json: > + { + "os": ["ubuntu-latest"], + "build_type": ["debug", "release"], + "enable_xrvk": ["ON", "OFF"], + "cpp_compiler": ["g++", "clang++"] + } + build-as-static : "OFF" + export-artifacts: "OFF" diff --git a/.github/workflows/windows_builds.yml b/.github/workflows/windows_builds.yml new file mode 100644 index 0000000..6565b49 --- /dev/null +++ b/.github/workflows/windows_builds.yml @@ -0,0 +1,24 @@ +# xrlib + +name: windows-latest + +on: + push: + branches: ['**'] + pull_request: + branches: ['main'] + + +jobs: + build: + uses: ./.github/workflows/_src_desktop_builds.yml + with: + matrix-json: > + { + "os": ["windows-latest"], + "build_type": ["debug", "release"], + "enable_xrvk": ["ON", "OFF"], + "cpp_compiler": ["cl"] + } + build-as-static : "OFF" + export-artifacts: "OFF" \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index bd7e201..332a1d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,6 @@ set(XRLIB_INCLUDE "${XRLIB_ROOT}/include") set(XRLIB_BIN_OUT "${XRLIB_ROOT}/bin") set(XRLIB_LIB_OUT "${XRLIB_ROOT}/lib") set(THIRD_PARTY "${XRLIB_ROOT}/third_party") -set(OPENXR_INCLUDE "${THIRD_PARTY}/openxr/include") set(XRVK_INCLUDE "${XRLIB_INCLUDE}/xrvk") set(XRVK_SRC "${XRLIB_SRC}/xrvk") @@ -84,6 +83,9 @@ set(OPENXR_INCLUDE "${OPENXR_ROOT}/include") # SET COMPILE OPTIONS # ####################### +# static build +option(BUILD_AS_STATIC "Build as static library" OFF) + # xrvk - pbr render module option(ENABLE_XRVK "Compile xrvk - pbr render module" ON) @@ -189,8 +191,23 @@ if(ENABLE_XRVK) endif() # Add project header and source files to project (including statically linking openxr_loader object) -add_library(${XRLIB} SHARED ${ALLSOURCE}) -message(STATUS "[${XRLIB}] Project library defined.") +if(BUILD_AS_STATIC) + add_library(${XRLIB} STATIC ${ALLSOURCE}) + message(STATUS "[${XRLIB}] Project library defined. Will build as: STATIC") +else() + add_library(${XRLIB} SHARED ${ALLSOURCE}) + message(STATUS "[${XRLIB}] Project library defined. Will build as: SHARED") +endif() + +# For shared library builds, set project version +if(NOT BUILD_AS_STATIC) + if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set_target_properties(${XRLIB} PROPERTIES VERSION ${PROJECT_VERSION}) + # else() + # cmake 3.22 builds multiple copies with version and so version for desktops. commenting for now to avoid CI build duplicates. + # set_target_properties(${XRLIB} PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) + endif() +endif() # Set project public include headers target_include_directories(${XRLIB} PUBLIC "${XRLIB_SRC}" @@ -273,4 +290,4 @@ add_custom_command(TARGET ${XRLIB} POST_BUILD # Create output directories COMMAND ${CMAKE_COMMAND} -E make_directory "${XRLIB_LIB_OUT}" COMMAND ${CMAKE_COMMAND} -E make_directory "${XRLIB_BIN_OUT}" - ) + ) \ No newline at end of file diff --git a/README.md b/README.md index 93409ae..31db4c1 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ # xrlib -[![Desktop builds [ Linux|Windows, Debug|Release, g++|clang++|cl ]](https://github.com/1runeberg/xrlib/actions/workflows/desktop_builds.yml/badge.svg)](https://github.com/1runeberg/xrlib/actions/workflows/desktop_builds.yml)   [![Android builds [ arm64-v8a, Debug|Release ]](https://github.com/1runeberg/xrlib/actions/workflows/android_builds.yml/badge.svg)](https://github.com/1runeberg/xrlib/actions/workflows/android_builds.yml) +[![android-latest](https://github.com/1runeberg/xrlib/actions/workflows/android_builds.yml/badge.svg)](https://github.com/1runeberg/xrlib/actions/workflows/android_builds.yml)  [![ubuntu-latest](https://github.com/1runeberg/xrlib/actions/workflows/ubuntu_builds.yml/badge.svg)](https://github.com/1runeberg/xrlib/actions/workflows/ubuntu_builds.yml)  [![windows-latest](https://github.com/1runeberg/xrlib/actions/workflows/windows_builds.yml/badge.svg)](https://github.com/1runeberg/xrlib/actions/workflows/windows_builds.yml) C++20 OpenXR wrapper library designed to abstract the complexities of the OpenXR API while retaining its flexibility, allowing developers to focus on creating immersive experiences without getting bogged down by low-level details. The library is Vulkan-native and includes an optional PBR renderer, designed from the ground up with mixed reality in mind. - **Supports: Android (aarch64), Linux (x86_64, aarch64), Windows (x86_64)** - ## Note This repository currently hosts a simplified version of an internal, comprehensive rewrite of [OpenXRProvider_v2](https://github.com/1runeberg/OpenXRProvider_v2). diff --git a/include/project_config.h b/include/project_config.h index dce0210..3060be4 100644 --- a/include/project_config.h +++ b/include/project_config.h @@ -4,7 +4,6 @@ #define XRLIB_VERSION_MINOR 0 #define XRLIB_VERSION_PATCH 0 #define XRLIB_VERSION_TWEAK 0 -#define XRLIB_VERSION XRLIB_VERSION_MAJOR "." XRLIB_VERSION_MINOR "." XRLIB_VERSION_PATCH "." XRLIB_VERSION_TWEAK #ifdef XR_USE_PLATFORM_ANDROID #define XRLIB_ASSETS_FOLDER ""