diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3fdb85c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,141 @@ +name: Build + +on: + push: + branches-ignore: + - 'no-ci-**' + - 'skip-ci-**' + pull_request: + workflow_dispatch: + +env: + # Select `sdk` or `source` with the RBFX_FRAMEWORK_BUILD_TYPE repository variable. + RBFX_FRAMEWORK_BUILD_TYPE: ${{ vars.RBFX_FRAMEWORK_BUILD_TYPE || 'sdk' }} + RBFX_REPOSITORY: ${{ vars.RBFX_REPOSITORY || 'rbfx/rbfx' }} + RBFX_REF: ${{ vars.RBFX_REF || 'master' }} + RBFX_RELEASE: ${{ vars.RBFX_RELEASE || 'latest' }} + +jobs: + PrepareMatrix: + name: Prepare Matrix + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.prepare.outputs.matrix }} + steps: + - name: Prepare rbfx matrix + id: prepare + uses: rbfx/ci/.github/actions/ci-prepare-matrix@v1 + with: + platforms: all + + Build: + name: ${{ matrix.ci_job_name }} + if: github.event_name != 'pull_request' || github.event.pull_request.draft == false + needs: [PrepareMatrix] + runs-on: ${{ matrix.runs_on }} + + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.PrepareMatrix.outputs.matrix) }} + + steps: + - name: Checkout sample project + uses: actions/checkout@v5 + with: + path: source-code + fetch-depth: 1 + submodules: recursive + + - name: Checkout target rbfx engine source + if: env.RBFX_FRAMEWORK_BUILD_TYPE == 'source' + uses: actions/checkout@v5 + with: + repository: ${{ env.RBFX_REPOSITORY }} + ref: ${{ env.RBFX_REF }} + path: framework/rbfx + fetch-depth: 1 + submodules: recursive + + - name: Download target rbfx SDK + if: env.RBFX_FRAMEWORK_BUILD_TYPE == 'sdk' + shell: bash + env: + GH_TOKEN: ${{ github.token }} + SDK_ASSET: rebelfork-sdk-${{ matrix.ci_platform_tag }}-latest.7z + run: | + mkdir -p \ + "${GITHUB_WORKSPACE}/framework" \ + "${GITHUB_WORKSPACE}/framework/target-sdk" + gh release download "$RBFX_RELEASE" \ + --repo "$RBFX_REPOSITORY" \ + --pattern "$SDK_ASSET" \ + --dir "${GITHUB_WORKSPACE}/framework" + 7z x -y \ + "${GITHUB_WORKSPACE}/framework/${SDK_ASSET}" \ + -o"${GITHUB_WORKSPACE}/framework/target-sdk" + + - name: Download native rbfx SDK for cross-build tools + if: >- + env.RBFX_FRAMEWORK_BUILD_TYPE == 'sdk' && + matrix.ci_platform_tag != matrix.ci_host_platform_tag + shell: bash + env: + GH_TOKEN: ${{ github.token }} + SDK_ASSET: rebelfork-sdk-${{ matrix.ci_host_platform_tag }}-latest.7z + run: | + mkdir -p \ + "${GITHUB_WORKSPACE}/framework/host" \ + "${GITHUB_WORKSPACE}/framework/host-sdk" + gh release download "$RBFX_RELEASE" \ + --repo "$RBFX_REPOSITORY" \ + --pattern "$SDK_ASSET" \ + --dir "${GITHUB_WORKSPACE}/framework/host" + 7z x -y \ + "${GITHUB_WORKSPACE}/framework/host/${SDK_ASSET}" \ + -o"${GITHUB_WORKSPACE}/framework/host-sdk" + + - name: Wait for native project build + id: host_project + if: >- + env.RBFX_FRAMEWORK_BUILD_TYPE == 'source' && + matrix.ci_platform_tag != matrix.ci_host_platform_tag + uses: rbfx/ci/.github/actions/ci-wait-for-build@v1 + with: + job_name: ${{ matrix.ci_host_job_name }} + artifact_names: | + sample-project-build-${{ matrix.ci_host_job_name }} + + - name: Download native project install + if: >- + env.RBFX_FRAMEWORK_BUILD_TYPE == 'source' && + matrix.ci_platform_tag != matrix.ci_host_platform_tag + uses: actions/download-artifact@v5 + with: + artifact-ids: ${{ steps.host_project.outputs.artifact_ids }} + path: host-project + + - name: Prepare rbfx environment + uses: rbfx/ci/.github/actions/ci-prepare-platform@v1 + with: + profile: downstream + cmake_prefix_path: | + host-project + framework/rbfx/CMake + framework/target-sdk/rebelfork-sdk-${{ matrix.ci_platform_tag }}-latest + framework/host-sdk/rebelfork-sdk-${{ matrix.ci_host_platform_tag }}-latest + + - name: Build and install sample project + id: build + uses: rbfx/ci/.github/actions/ci-build-project@v1 + with: + project_dir: source-code + build_dir: project-build/${{ matrix.ci_platform_tag }} + install_dir: project-install/${{ matrix.ci_platform_tag }} + android_dir: android + + - name: Upload project install + uses: actions/upload-artifact@v7 + with: + name: sample-project-build-${{ matrix.ci_job_name }} + path: ${{ steps.build.outputs.install_dir }} + if-no-files-found: error diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ef84ca1..10c7ade 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,23 +1,22 @@ name: Deploy on: - # Build on commits pushed, except when explicitly skipped. - push: - branches-ignore: - - 'no-ci-**' - - 'skip-ci-**' - # Build on pull requests, except drafts. - pull_request: - # Build manually - workflow_dispatch: + workflow_run: + workflows: + - Build + types: + - completed + branches: + - master + +permissions: + actions: read + contents: read env: - # Common settings. - CMAKE_VERSION: 3.25.x - # Common paths. ci_source_dir: ${{ github.workspace }}/source-code ci_build_script: ./source-code/Script/ci_build.sh - ci_build_dir: ${{ github.workspace }}/cmake-build - ci_native_sdk_dir: ${{ github.workspace }}/SDK-native + ci_web_build_dir: ${{ github.workspace }}/web-build + ci_windows_build_dir: ${{ github.workspace }}/windows-build ci_target_sdk_dir: ${{ github.workspace }}/SDK-target defaults: @@ -25,199 +24,80 @@ defaults: shell: bash jobs: - CheckSkipCI: + Deploy: runs-on: ubuntu-latest if: | - !contains(github.event.head_commit.message, '[skip ci]') && - !contains(github.event.pull_request.title, '[skip ci]') && - !contains(github.event.head_commit.message, '[skip-ci]') && - !contains(github.event.pull_request.title, '[skip-ci]') - steps: - - run: exit 0 - - # Build the project for Web using both engine SDK and engine in subdirectory. - # SDK build is published to itch.io. - Web: - if: github.event.pull_request.draft == false - runs-on: ubuntu-latest - needs: [CheckSkipCI] - - strategy: - fail-fast: false - matrix: - ci_build_mode: - - sdk - - subdirectory - - env: - ci_platform: web - ci_native_sdk_name: rebelfork-sdk-linux-clang-x64-dll-latest - ci_target_sdk_name: rebelfork-sdk-web-emscripten-wasm-lib-latest - ci_emsdk_version: latest - ci_build_mode: ${{ matrix.ci_build_mode }} - ci_publish: ${{ github.ref == 'refs/heads/master' && github.repository == 'rbfx/sample-project' && matrix.ci_build_mode == 'sdk'}} - BINARYEN_CORES: 1 + github.event.workflow_run.conclusion == 'success' && + github.event.workflow_run.event == 'push' && + github.event.workflow_run.repository.full_name == 'rbfx/sample-project' steps: - - uses: mymindstorm/setup-emsdk@v11 - with: - version: ${{ env.ci_emsdk_version }} - - name: Checkout Sample Project - uses: actions/checkout@v2 + uses: actions/checkout@v5 with: - path: ${{ env.ci_source_dir }} + ref: ${{ github.event.workflow_run.head_sha }} + path: source-code fetch-depth: 1 submodules: true - - name: Checkout the Framework - if: ${{ matrix.ci_build_mode == 'subdirectory' }} - uses: actions/checkout@v2 + - name: Download web build artifact + uses: actions/download-artifact@v8 with: - repository: rbfx/rbfx - path: ${{ env.ci_source_dir }}/../rbfx - fetch-depth: 1 - submodules: true - - - name: Download native SDK - uses: robinraju/release-downloader@v1.8 + github-token: ${{ github.token }} + repository: ${{ github.event.workflow_run.repository.full_name }} + run-id: ${{ github.event.workflow_run.id }} + name: sample-project-build-web-emscripten-wasm-lib + path: ${{ env.ci_web_build_dir }} + + - name: Download Windows build artifact + uses: actions/download-artifact@v8 with: - repository: rbfx/rbfx - tag: latest - fileName: ${{ env.ci_native_sdk_name }}.7z + github-token: ${{ github.token }} + repository: ${{ github.event.workflow_run.repository.full_name }} + run-id: ${{ github.event.workflow_run.id }} + name: sample-project-build-windows-msvc-x64-lib + path: ${{ env.ci_windows_build_dir }} - - name: Unzip native SDK - run: | - cd '${{ github.workspace }}' - 7z x '${{ env.ci_native_sdk_name }}.7z' '-o${{ github.workspace }}' -y - mv './${{ env.ci_native_sdk_name }}' ./SDK-native - - - name: Download target SDK - if: ${{ matrix.ci_build_mode == 'sdk' }} + - name: Download Windows SDK uses: robinraju/release-downloader@v1.8 with: repository: rbfx/rbfx tag: latest - fileName: ${{ env.ci_target_sdk_name }}.7z + fileName: rebelfork-sdk-windows-msvc-x64-lib-latest.7z - - name: Unzip target SDK - if: ${{ matrix.ci_build_mode == 'sdk' }} + - name: Unzip Windows SDK run: | cd '${{ github.workspace }}' - 7z x '${{ env.ci_target_sdk_name }}.7z' '-o${{ github.workspace }}' -y - mv './${{ env.ci_target_sdk_name }}' ./SDK-target - - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v1.8 - with: - cmake-version: '${{ env.CMAKE_VERSION }}' - - - name: Dependencies - shell: bash - run: ${{ env.ci_build_script }} dependencies - - - name: Generate - shell: bash - run: ${{ env.ci_build_script }} generate - - - name: Build - shell: bash - run: ${{ env.ci_build_script }} build - - - name: Prepare - if: ${{ env.ci_publish }} - shell: bash + rm -rf '${{ env.ci_target_sdk_dir }}' + 7z x 'rebelfork-sdk-windows-msvc-x64-lib-latest.7z' '-o${{ github.workspace }}' -y + mv './rebelfork-sdk-windows-msvc-x64-lib-latest' '${{ env.ci_target_sdk_dir }}' + rm 'rebelfork-sdk-windows-msvc-x64-lib-latest.7z' + + - name: Prepare web package + env: + ci_platform: web + ci_build_dir: ${{ env.ci_web_build_dir }} + ci_build_mode: sdk run: ${{ env.ci_build_script }} prepare - - name: Publish - if: ${{ env.ci_publish }} - uses: KikimoraGames/itch-publish@v0.0.3 - with: - butlerApiKey: ${{ secrets.BUTLER_API_KEY }} - gameData: ${{ github.workspace }}/cmake-build/bin/project - itchUsername: eugeneko - itchGameId: sample-project - buildChannel: web - - # Build the project for Windows using both engine SDK and engine in subdirectory. - Windows: - if: github.event.pull_request.draft == false - runs-on: windows-2022 - needs: [CheckSkipCI] - - strategy: - fail-fast: false - matrix: - ci_build_mode: - - sdk - - subdirectory - - env: - ci_platform: windows - ci_target_sdk_name: rebelfork-sdk-windows-msvc-x64-lib-latest - ci_build_mode: ${{ matrix.ci_build_mode }} - ci_publish: ${{ github.ref == 'refs/heads/master' && github.repository == 'rbfx/sample-project' && matrix.ci_build_mode == 'sdk'}} - BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }} - - steps: - - name: Checkout Sample Project - uses: actions/checkout@v3 - with: - path: ${{ env.ci_source_dir }} - fetch-depth: 1 - submodules: true - - - name: Checkout the Framework - if: ${{ matrix.ci_build_mode == 'subdirectory' }} - uses: actions/checkout@v2 - with: - repository: rbfx/rbfx - path: ${{ env.ci_source_dir }}/../rbfx - fetch-depth: 1 - submodules: true - - - name: Download target SDK - if: ${{ matrix.ci_build_mode == 'sdk' }} - uses: robinraju/release-downloader@v1.8 - with: - repository: rbfx/rbfx - tag: latest - fileName: ${{ env.ci_target_sdk_name }}.7z - - - name: Unzip target SDK - if: ${{ matrix.ci_build_mode == 'sdk' }} - run: | - cd '${{ github.workspace }}' - 7z x '${{ env.ci_target_sdk_name }}.7z' '-o${{ github.workspace }}' -y - mv './${{ env.ci_target_sdk_name }}' ./SDK-target + - name: Prepare Windows package + env: + ci_platform: windows + ci_build_dir: ${{ env.ci_windows_build_dir }} + ci_build_mode: sdk + run: ${{ env.ci_build_script }} prepare - name: Set up butler - if: ${{ env.ci_publish }} uses: jdno/setup-butler@v1 - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v1 - with: - cmake-version: '${{ env.CMAKE_VERSION }}' - - - name: Dependencies - shell: bash - run: ${{ env.ci_build_script }} dependencies - - - name: Generate - shell: bash - run: ${{ env.ci_build_script }} generate - - - name: Build - shell: bash - run: ${{ env.ci_build_script }} build - - - name: Prepare - if: ${{ env.ci_publish }} - shell: bash - run: ${{ env.ci_build_script }} prepare + - name: Publish web build + env: + BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }} + run: | + butler push "${{ env.ci_web_build_dir }}/bin/project" "eugeneko/sample-project:web" - - name: Publish - if: ${{ env.ci_publish }} + - name: Publish Windows build + env: + BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }} run: | - butler push "${{ env.ci_build_dir }}/bin/project" "eugeneko/sample-project:windows" + butler push "${{ env.ci_windows_build_dir }}/bin/project" "eugeneko/sample-project:windows" diff --git a/CMakeLists.txt b/CMakeLists.txt index 24d585c..2a655dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,3 +74,20 @@ endif () # Generate Visual Studio props file for csproj. rbfx_configure_cmake_props() + +# Install the project outputs consumed by CI artifact uploads and host-side +# cross-build steps. The engine/SDK remains a separate caller-provided prefix. +foreach (TARGET + ${CMAKE_PROJECT_NAME} + ${CMAKE_PROJECT_NAME}Editor + ${APP_PLUGIN_NAME} + Plugin.Core.SamplePlugin) + if (TARGET ${TARGET}) + install(TARGETS ${TARGET} + RUNTIME DESTINATION bin/$ + LIBRARY DESTINATION bin/$ + ARCHIVE DESTINATION lib/$ + BUNDLE DESTINATION bin/$) + endif () +endforeach () +install(DIRECTORY "${CMAKE_SOURCE_DIR}/Project/" DESTINATION share/${CMAKE_PROJECT_NAME}) diff --git a/README.md b/README.md index 5d9624c..662b004 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Sample project -Simple example project that uses [the Framework](https://github.com/rbfx/rbfx) as submodule. +Simple example project that uses [the Framework](https://github.com/rbfx/rbfx). It is automatically deployed to [itch.io](https://eugeneko.itch.io/sample-project) and it can be played in browser. diff --git a/android/build.gradle b/android/build.gradle index 07b05eb..cd76d41 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -3,9 +3,11 @@ apply plugin: 'com.android.application' // Relative path to engine source code directory. Modify as required. def projectSourceDir = '..' // Relative path to project source code directory. Modify as required. -def rbfxSourceDir = '../3rdParty/rbfx' +def rbfxSourceDir = file('../rbfx').exists() ? '../rbfx' : '../3rdParty/rbfx' +// SDL Android Java glue is exported by rbfx CI for both source and SDK builds. +def rbfxAndroidJavaDir = System.getenv('RBFX_ANDROID_JAVA_DIR') ?: "${rbfxSourceDir}/Source/ThirdParty/SDL/android-project/app/src/main/java" // Minimum required CMake version. This is same as in ../CMakeLists.txt. -def cmakeVersion = '3.22.0.0+' +def cmakeVersion = '3.25.0+' buildscript { repositories { @@ -13,27 +15,51 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.2.1' + classpath 'com.android.tools.build:gradle:8.13.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } android { - compileSdkVersion 32 + namespace 'io.urho3d' + compileSdkVersion 35 defaultConfig { applicationId 'io.urho3d' versionCode 1 versionName '1.0.0' - minSdkVersion 17 - targetSdkVersion 32 + minSdkVersion 24 + targetSdkVersion 35 ndk { - abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64' + def targetArch = System.getenv('ci_arch') + if (targetArch) { + def archMap = [ + 'arm': 'armeabi-v7a', + 'arm64': 'arm64-v8a', + 'x86': 'x86', + 'x64': 'x86_64' + ] + def androidAbi = archMap.get(targetArch, targetArch) + abiFilters androidAbi + } else { + abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64' + } } externalNativeBuild { cmake { + def buildSharedLibs = System.getenv('ci_lib_type') != 'lib' arguments '-DANDROID_STL=c++_static', '-DANDROID_PLATFORM=android-21', '-DANDROID=1', - '-DANDROID_ARM_MODE=arm', '-DBUILD_SHARED_LIBS=OFF' + '-DANDROID_ARM_MODE=arm', "-DBUILD_SHARED_LIBS=${buildSharedLibs ? 'ON' : 'OFF'}" + + def cmakePrefixPath = System.getenv('CMAKE_PREFIX_PATH') + if (cmakePrefixPath) { + arguments "-DCMAKE_PREFIX_PATH=${cmakePrefixPath}" + } + + def urho3dDir = System.getenv('Urho3D_DIR') + if (urho3dDir) { + arguments "-DUrho3D_DIR=${urho3dDir}" + } } } } @@ -46,13 +72,13 @@ android { buildTypes { release { minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt') + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt') } } sourceSets.main { manifest.srcFile 'AndroidManifest.xml' - java.srcDirs = ['src', "${rbfxSourceDir}/Source/ThirdParty/SDL/android-project/app/src/main/java"] + java.srcDirs = ['src', rbfxAndroidJavaDir] res.srcDirs = ['res', "${projectSourceDir}/StoreArt/Android/Icons"] assets.srcDirs = ['assets', "${projectSourceDir}/Project"] }