Skip to content

Commit

Permalink
TEMP
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneko committed Feb 18, 2024
1 parent 7ed9235 commit 786cd77
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 38 deletions.
94 changes: 86 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
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 on a schedule to keep up with the engine changes.
schedule:
- cron: '0 0 * * 0'

env:
# common settings
# Common settings.
CMAKE_VERSION: 3.21.x
# paths
ci_native_sdk_name: rebelfork-sdk-Linux-clang-rel-dll-x64-latest.zip
ci_target_sdk_name: rebelfork-sdk-Web-rel-lib-latest.zip
# 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
Expand All @@ -31,29 +32,33 @@ jobs:
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
if: github.event.pull_request.draft == false && false
runs-on: ubuntu-20.04
needs: [CheckSkipCI]

strategy:
fail-fast: false
matrix:
ci_emsdk_version:
- latest
ci_build_mode:
- sdk
- subdirectory

env:
ci_platform: web
ci_native_sdk_name: rebelfork-sdk-Linux-clang-rel-dll-x64-latest.zip
ci_target_sdk_name: rebelfork-sdk-Web-rel-lib-latest.zip
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

steps:
- uses: mymindstorm/setup-emsdk@v11
with:
version: ${{ matrix.ci_emsdk_version }}
version: ${{ env.ci_emsdk_version }}

- name: Checkout Sample Project
uses: actions/checkout@v2
Expand Down Expand Up @@ -129,3 +134,76 @@ jobs:
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-rel-dll-x64-latest.zip
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: Download target SDK
if: ${{ matrix.ci_build_mode == 'sdk' }}
uses: robinraju/[email protected]
with:
repository: rbfx/rbfx
tag: latest
fileName: ${{ env.ci_target_sdk_name }}

- name: Unzip target SDK
if: ${{ matrix.ci_build_mode == 'sdk' }}
run: |
cd ${{ github.workspace }}
unzip ${{ env.ci_target_sdk_name }}
mv ./SDK ./SDK-target
- 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
shell: bash
run: ${{ env.ci_build_script }} prepare

- name: Publish
if: ${{ env.ci_publish }}
run: |
butler push "${{ env.ci_build_dir }}/bin/project" "eugeneko/sample-project:windows"
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# In your project, you can choose either option or keep both.
set (REBELFORK_SDK "" CACHE STRING "Path to pre-built SDK")
if ("${REBELFORK_SDK}" STREQUAL "")
# Include common build scripts.
include (${CMAKE_SOURCE_DIR}/../rbfx/CMake/Modules/UrhoCommon.cmake)

# Include the Framework to build.
add_subdirectory (../rbfx ${CMAKE_BINARY_DIR}/3rdParty/rbfx)

# Include common build scripts.
include (${CMAKE_SOURCE_DIR}/../rbfx/CMake/Modules/UrhoCommon.cmake)

# Set path to engine resources.
set (REBELFORK_BIN_DIR "${CMAKE_SOURCE_DIR}/../rbfx/bin")
else ()
Expand Down
111 changes: 92 additions & 19 deletions Script/ci_build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash

# build.sh <action> ...
# ci_platform: web|windows
# ci_action: dependencies|generate|build|install|test
# ci_source_dir: source code directory
# ci_build_dir: cmake cache directory
Expand All @@ -11,44 +12,116 @@
ci_action=$1; shift;
ci_source_dir=${ci_source_dir%/}; # remove trailing slash if any

echo "ci_platform=$ci_platform"
echo "ci_action=$ci_action"
echo "ci_source_dir=$ci_source_dir"
echo "ci_build_dir=$ci_build_dir"
echo "ci_native_sdk_dir=$ci_native_sdk_dir"
echo "ci_target_sdk_dir=$ci_target_sdk_dir"
echo "ci_build_mode=$ci_build_mode"

declare -A build_config=(
[web]='Release'
[windows]='RelWithDebInfo'
)

copy-runtime-libraries-for-executables() {
local dir=$1
local exe_files=($(find "$dir" -type f -executable))
for file in "${exe_files[@]}"; do
echo "Copying dependencies for $file"
copy-runtime-libraries-for-file "$file"
done
}

copy-runtime-libraries-for-file() {
local file=$1
local dependencies=($(ldd "$file" | awk '{print $3}'))
local dir=$(dirname "$file")
local filename=$(basename "$file")
shopt -s nocasematch
for dep in "${dependencies[@]}"; do
echo "Depends on $dep, making a copy to $dir"
if [[ "$dep" =~ (vcruntime.+dll)|(msvcp.+dll)|(D3DCOMPILER.*dll) ]]; then
local depName=$(basename "$dep")
if [ "$dep" != "$dir/$depName" ] && [[ ! -f "$dir/$depName" ]]; then
echo "Depends on $dep, making a copy to $dir"
cp "$dep" "$dir"
fi
fi
done
}

function action-dependencies() {
sudo apt-get install -y --no-install-recommends uuid-dev ninja-build
if [[ "$ci_platform" == "web" ]]; then
sudo apt-get install -y --no-install-recommends uuid-dev ninja-build
elif [[ "$ci_platform" == "windows" ]]; then
: # No dependencies
fi
}

function action-generate() {
local extra_params=""
if [[ $ci_build_mode == "sdk" ]]; then extra_params="-DREBELFORK_SDK=$ci_target_sdk_dir"; fi

cmake \
-G Ninja \
-DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DEMSCRIPTEN_ROOT_PATH=$EMSDK/upstream/emscripten/ \
-DCMAKE_BUILD_TYPE=Release \
-DURHO3D_SDK=$ci_native_sdk_dir \
-DCI_WEB_BUILD=ON \
-DBUILD_SHARED_LIBS=OFF \
-DURHO3D_PROFILING=OFF \
$extra_params \
-B $ci_build_dir -S "$ci_source_dir"
local params=(
"-B"
"$ci_build_dir"
"-S"
"$ci_source_dir"
)
if [[ "$ci_platform" == "web" ]]; then
params+=(
"-G"
"Ninja"
"-DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
"-DEMSCRIPTEN_ROOT_PATH=$EMSDK/upstream/emscripten/"
"-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON"
"-DBUILD_SHARED_LIBS=OFF"
"-DURHO3D_SDK=$ci_native_sdk_dir"
"-DCI_WEB_BUILD=ON"
"-DCMAKE_BUILD_TYPE=Release"
)
elif [[ "$ci_platform" == "windows" ]]; then
params+=(
"-G"
"Visual Studio 17 2022"
"-A"
"x64"
"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
)
fi

if [[ $ci_build_mode == "sdk" ]]; then
params+=("-DREBELFORK_SDK=$ci_target_sdk_dir")
fi

cmake "${params[@]}"
}

function action-build() {
cmake --build $ci_build_dir --parallel $(nproc) --config "Release"
cmake --build $ci_build_dir --parallel $(nproc) --config ${build_config[$ci_platform]}
}

function action-prepare() {
cd $ci_build_dir/bin
mkdir -p project
cp ./SampleProject.js ./SampleProject.wasm ./Resources.js ./Resources.js.data ./project
cp ./SampleProject.html ./project/index.html
if [[ "$ci_platform" == "web" ]]; then
cp ./SampleProject.js ./SampleProject.wasm ./Resources.js ./Resources.js.data ./project
cp ./SampleProject.html ./project/index.html
elif [[ "$ci_platform" == "windows" ]]; then
cp ./RelWithDebInfo/*.exe ./project
cp ./RelWithDebInfo/*.dll ./project
cp ./RelWithDebInfo/*.pdb ./project
cp -r $ci_source_dir/Project/Data ./project
cp -r $ci_target_sdk_dir/bin/CoreData ./project

local dll_files=($(find "$ci_target_sdk_dir/bin/RelWithDebInfo" -type f -name "*.dll"))
for dep in "${dll_files[@]}"; do
local filename=$(basename "$dep")
if [[ "$filename" =~ (.*CSharp.*)|(.*Managed.*)|(Urho3DNet.*)|(Sample\..*)|(.*Player.*)|(.*Editor.*) ]]; then
continue
fi
cp "$dep" ./project
done
fi
}

action-$ci_action
8 changes: 0 additions & 8 deletions Source/Launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,3 @@ if (UWP)
endforeach ()
endforeach ()
endif()

# Pass resource path to Win32 project
if(MSVC AND NOT UWP)
set_target_properties(${TARGET_NAME}
PROPERTIES
VS_DEBUGGER_COMMAND_ARGUMENTS "--pp ${CMAKE_SOURCE_DIR}/Project"
)
endif()

0 comments on commit 786cd77

Please sign in to comment.