Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 131 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
steps:
- name: Prepare rbfx matrix
id: prepare
uses: rbfx/ci/.github/actions/ci-prepare-matrix@v1
uses: rbfx/ci/.github/actions/ci-prepare-matrix@rk/split-csharp
with:
platforms: all

Expand Down Expand Up @@ -99,7 +99,7 @@ jobs:
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
uses: rbfx/ci/.github/actions/ci-wait-for-build@rk/split-csharp
with:
job_name: ${{ matrix.ci_host_job_name }}
artifact_names: |
Expand All @@ -115,7 +115,7 @@ jobs:
path: host-project

- name: Prepare rbfx environment
uses: rbfx/ci/.github/actions/ci-prepare-platform@v1
uses: rbfx/ci/.github/actions/ci-prepare-platform@rk/split-csharp
with:
profile: downstream
cmake_prefix_path: |
Expand All @@ -126,7 +126,7 @@ jobs:

- name: Build and install sample project
id: build
uses: rbfx/ci/.github/actions/ci-build-project@v1
uses: rbfx/ci/.github/actions/ci-build-project@rk/split-csharp
with:
project_dir: source-code
build_dir: project-build/${{ matrix.ci_platform_tag }}
Expand All @@ -139,3 +139,130 @@ jobs:
name: sample-project-build-${{ matrix.ci_job_name }}
path: ${{ steps.build.outputs.install_dir }}
if-no-files-found: error

# Runnable package for the user. Android uploads the collected apk output.
- name: Package runnable project
if: env.ci_platform == 'windows' || env.ci_platform == 'linux' || env.ci_platform == 'macos'
shell: bash
run: |
install="${GITHUB_WORKSPACE}/${{ steps.build.outputs.install_dir }}"
[[ -d "$install" ]] || install="${{ steps.build.outputs.install_dir }}"
# Prefer the optimized configuration. A Debug package needs the debug CRT, which is not redistributable.
config=""
for c in RelWithDebInfo Release; do [[ -d "$install/bin/$c" ]] && { config=$c; break; }; done
[[ -n "$config" ]] || config="$(basename "$(ls -d "$install"/bin/*/ | head -1)")"
sdk="${GITHUB_WORKSPACE}/framework/target-sdk/rebelfork-sdk-${{ matrix.ci_platform_tag }}-latest"
[[ -d "$sdk" ]] || sdk="${GITHUB_WORKSPACE}/framework/rbfx"
source-code/Script/package_dist.sh "$install/bin/$config" "$sdk" "$config" \
"$install/share/SampleProject/Data" dist

- name: Upload runnable project
if: env.ci_platform == 'windows' || env.ci_platform == 'linux' || env.ci_platform == 'macos'
uses: actions/upload-artifact@v7
with:
name: sample-project-${{ matrix.ci_job_name }}
path: dist
retention-days: 7
if-no-files-found: error

- name: Upload Android package
if: env.ci_platform == 'android'
uses: actions/upload-artifact@v7
with:
name: sample-project-${{ matrix.ci_job_name }}
path: ${{ steps.build.outputs.install_dir }}/android
retention-days: 7
if-no-files-found: error

# Build with the C# bindings SDK and compile the managed assembly of the plugin.
Linux-CSharp:
name: Linux-CSharp
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
runs-on: ubuntu-24.04
env:
CSHARP_REPOSITORY: ${{ vars.CSHARP_REPOSITORY || 'rbfx/csharp-swig' }}
DOTNET_NOLOGO: '1'
DOTNET_CLI_TELEMETRY_OPTOUT: '1'
defaults:
run:
shell: bash

steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
path: source-code
fetch-depth: 1
submodules: recursive

- name: Install system packages
run: |
sudo apt-get update
sudo apt-get install -y \
ninja-build p7zip-full \
libgl1-mesa-dev libxcursor-dev libxi-dev libxinerama-dev \
libxrandr-dev libxrender-dev libxss-dev libasound2-dev \
libpulse-dev libibus-1.0-dev libdbus-1-dev libreadline6-dev \
libudev-dev uuid-dev libtbb-dev libxcb-glx0-dev

- name: Setup dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0'

- name: Download engine and C# SDKs
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir -p sdk-download sdk
gh release download latest \
--repo "${{ vars.RBFX_REPOSITORY || 'rbfx/rbfx' }}" \
--pattern 'rebelfork-sdk-linux-gcc-x64-dll-latest.7z' \
--dir sdk-download
gh release download latest \
--repo "$CSHARP_REPOSITORY" \
--pattern 'rebelfork-csharp-sdk-linux-gcc-x64-dll-latest.7z' \
--dir sdk-download
for f in sdk-download/*.7z; do 7z x -y "$f" -o"sdk" >/dev/null; done

- name: Configure
run: |
engine="${GITHUB_WORKSPACE}/sdk/rebelfork-sdk-linux-gcc-x64-dll-latest"
csharp="${GITHUB_WORKSPACE}/sdk/rebelfork-csharp-sdk-linux-gcc-x64-dll-latest"
cmake \
-S source-code \
-B cmake-build \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DBUILD_SHARED_LIBS=ON \
"-DCMAKE_PREFIX_PATH=${engine}/share;${csharp}/share" \
"-DUrho3DNet_DIR=${csharp}/share/Urho3DNet"

- name: Build
run: cmake --build cmake-build -j

- name: Build managed plugin assembly
run: |
dotnet build source-code/Plugins/Core.SamplePlugin/CSharp/Plugin.csproj \
-c RelWithDebInfo \
-p:CMAKE_BINARY_DIR="${GITHUB_WORKSPACE}/cmake-build/"

- name: Check outputs
run: |
test -f cmake-build/bin/RelWithDebInfo/Plugin.Core.SamplePlugin.Net.dll
count="$(nm -D --defined-only cmake-build/bin/libPlugin.Core.SamplePlugin.so | grep -c CSharp_ || true)"
echo "CSharp_ exports: ${count}"
test "${count}" -gt 0

- name: Package runnable project
run: |
sdk="${GITHUB_WORKSPACE}/sdk/rebelfork-sdk-linux-gcc-x64-dll-latest"
source-code/Script/package_dist.sh cmake-build/bin "$sdk" RelWithDebInfo \
source-code/Project/Data dist

- name: Upload runnable project
uses: actions/upload-artifact@v7
with:
name: sample-project-linux-csharp
path: dist
retention-days: 7
if-no-files-found: error
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ set(URHO3D_SAMPLES OFF)
# - Clone https://github.com/rbfx/rbfx somewhere
# - Configure with `-DCMAKE_PREFIX_PATH=/path/to/rbfx/CMake`
find_package(Urho3D REQUIRED)
# The C# bindings are optional. They are a separate package: https://github.com/rbfx/rbfx-csharp
find_package(Urho3DNet QUIET)

# Check if Core.SamplePlugin exists
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Plugins/Core.SamplePlugin/CMakeLists.txt")
Expand Down Expand Up @@ -73,7 +75,9 @@ if (WEB)
endif ()

# Generate Visual Studio props file for csproj.
rbfx_configure_cmake_props()
if (Urho3DNet_FOUND)
rbfx_configure_cmake_props()
endif ()

# Install the project outputs consumed by CI artifact uploads and host-side
# cross-build steps. The engine/SDK remains a separate caller-provided prefix.
Expand Down
22 changes: 22 additions & 0 deletions Script/package_dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Pack a runnable copy of the project.
# Usage: package_dist.sh <bin_dir> <sdk_dir> <config> <data_dir> <dist_dir>
# bin_dir: directory with the executable, plugin libraries and managed files.
# sdk_dir: engine SDK root. Its bin/<config> runtime libraries and bin/CoreData are copied.
# data_dir: project Data directory.
set -euo pipefail
bin_dir=$1 sdk_dir=$2 config=$3 data_dir=$4 dist=$5

mkdir -p "$dist/bin"
cp -a "$bin_dir"/. "$dist/bin/"
# Shared engine libraries next to the executable (no-op for static builds).
find "$sdk_dir/bin/$config" -maxdepth 1 -type f \
\( -name '*.so' -o -name '*.so.*' -o -name '*.dll' -o -name '*.dylib' \) \
-exec cp -a {} "$dist/bin/" \;
cp -a "$sdk_dir/bin/CoreData" "$dist/CoreData"
cp -a "$data_dir" "$dist/Data"
find "$dist" \( -name '*.pdb' -o -name '*.o' \) -exec unlink {} \;
cat > "$dist/bin/ResourceRoot.ini" <<INI
CoreData=../CoreData
Data=../Data
INI
Loading