Skip to content

Commit c091bca

Browse files
author
Luke
authored
Upgraded build system, better platform support and dependency management (#60)
1 parent d9c2034 commit c091bca

File tree

10,541 files changed

+516313
-365625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

10,541 files changed

+516313
-365625
lines changed

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/build
2+
/out
3+
/cmake/vcpkg/buildtrees/
4+
/cmake/vcpkg/build*/
5+
/cmake/vcpkg/downloads/
6+
/cmake/vcpkg/installed*/
7+
/cmake/vcpkg/packages/
8+
/cmake/vcpkg/scripts/buildsystems/tmp/

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ensure shell script uses LF.
2+
Dockerfile eol=lf
3+
*.sh eol=lf
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: 'Android build for libnakama'
2+
description: 'Not generic, tailored for libnakama.'
3+
inputs:
4+
GITHUB_TOKEN:
5+
description: 'Github token for Github Package Registry'
6+
required: true
7+
8+
9+
outputs:
10+
artifact_name:
11+
description: 'Artifact name'
12+
value: ${{ steps.artifact_name.outputs.name }}
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
# gradle invokes cmake to build native code, so our usual vcpkg config is still necessary
18+
# NOTE: 'Source' here is the name of NuGet registry created by actions/setup-dotnet@v2
19+
- run: echo "VCPKG_BINARY_SOURCES=clear;nuget,Source,readwrite" >> $GITHUB_ENV
20+
shell: bash
21+
22+
- uses: actions/setup-dotnet@v2
23+
with:
24+
source-url: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
25+
env:
26+
NUGET_AUTH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
27+
28+
- name: Installing prerequisites
29+
shell: bash
30+
run: |
31+
if [[ "${{ runner.os }}" == "Linux" ]]; then
32+
sudo ./ci/setup-ubuntu.sh install_ninja setup_vcpkg
33+
elif [[ "${{ runner.os }}" == "macOS" ]]; then
34+
./ci/setup-osx.sh
35+
fi
36+
37+
# looks like setup done by actions/setup-dotnet is not enough, and
38+
# without 'setapikey' vcpkg can't upload build cache to NuGet registry
39+
- name: Setup NuGet API key
40+
shell: bash
41+
run: >
42+
mono `vcpkg fetch nuget | tail -n 1`
43+
setapikey "${{ inputs.GITHUB_TOKEN }}"
44+
-source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
45+
46+
- run: rm -rf out
47+
shell: bash
48+
49+
- uses: gradle/gradle-build-action@v2
50+
with:
51+
arguments: assembleMinSizeRel --info --no-parallel --no-daemon
52+
build-root-directory: ./android
53+
- id: artifact_name
54+
shell: bash
55+
run: |
56+
sha=${{ github.sha }}
57+
name="libnakama-android-MinSizeRel-git.${sha:0:8}"
58+
echo "::set-output name=artifact::${name}"
59+
- uses: actions/upload-artifact@v3
60+
with:
61+
name: ${{ steps.artifact_name.outputs.artifact }}
62+
path: ./android/build/outputs/aar/nakama-minsizerel.aar
63+
retention-days: ${{ inputs.artifact_retention_days }}
64+
- if: failure()
65+
uses: actions/upload-artifact@v3
66+
with:
67+
name: ${{ steps.artifact_name.outputs.artifact }}-workdir-debug
68+
path: |
69+
./android/build
70+
./android/.cxx
71+
./cmake/vcpkg/buildtrees
72+
!./android/**/.git
73+
retention-days: 1
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: 'CMake build for libnakama'
2+
description: 'Configures build environment and invokes CMake. Not generic, tailored for libnakama.'
3+
inputs:
4+
preset:
5+
description: 'Configure preset name'
6+
required: true
7+
build_type:
8+
description: 'Build config: MinSizeRel or Debug'
9+
required: true
10+
default: 'MinSizeRel'
11+
flavour:
12+
description: 'Possible values: Unreal, libcxx'
13+
required: false
14+
artifact_retention_days:
15+
description: 'Artifact retention days'
16+
default: 2
17+
GITHUB_TOKEN:
18+
description: 'Github token for Github Package Registry'
19+
required: true
20+
21+
22+
outputs:
23+
artifact_name:
24+
description: 'Artifact name'
25+
value: ${{ steps.artifact_name.outputs.name }}
26+
runs:
27+
using: "composite"
28+
steps:
29+
- run: echo "VCPKG_BINARY_SOURCES=clear;nuget,GitHub,readwrite" >> $GITHUB_ENV
30+
shell: bash
31+
32+
- name: 'Setup NuGet Credentials'
33+
shell: bash
34+
run: >
35+
mono=$( type -p mono || :);
36+
nuget="$mono $(vcpkg fetch nuget | tail -n 1)";
37+
$nuget sources list | grep -q ${{ github.repository_owner }} || $nuget sources add
38+
-source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
39+
-storepasswordincleartext
40+
-name "GitHub"
41+
-username "heroiclabs"
42+
-password "${{ inputs.GITHUB_TOKEN }}"
43+
- name: Setup NuGet API key
44+
shell: bash
45+
run: >
46+
$( type -p mono || :) `vcpkg fetch nuget | tail -n 1`
47+
setapikey "${{ inputs.GITHUB_TOKEN }}"
48+
-source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
49+
50+
- id: cmake_args
51+
shell: bash
52+
if: ${{ inputs.flavour }}
53+
run: |
54+
if [[ "${{inputs.flavour}}" == "Unreal" ]]; then
55+
echo "::set-output name=args::-DUNREAL=ON"
56+
elif [[ "${{inputs.flavour}}" == "libcxx" ]]; then
57+
echo "::set-output name=args::-DWITH_LIBCXX=ON"
58+
else
59+
echo "::error::Unexpected 'input' flavour value: ${{ inputs.flavour }}"
60+
fi
61+
62+
- name: Installing prerequisites
63+
run: |
64+
if [[ "${{ runner.os }}" == "Linux" ]]; then
65+
sudo ./ci/setup-ubuntu.sh
66+
elif [[ "${{ runner.os }}" == "macOS" ]]; then
67+
./ci/setup-osx.sh
68+
fi
69+
70+
if [[ "${{ runner.os }}" == "Linux" ]]; then
71+
echo 'CC=/usr/bin/gcc-11' >> "$GITHUB_ENV"
72+
echo 'CXX=/usr/bin/g++-11' >> "$GITHUB_ENV"
73+
fi
74+
shell: bash
75+
- run: rm -rf out
76+
shell: bash
77+
- run: cmake --preset ${{ inputs.preset }} ${{ steps.cmake_args.outputs.args }}
78+
shell: bash
79+
- run: cmake --build ./build/${{ inputs.preset }} --config ${{ inputs.build_type }} --verbose
80+
shell: bash
81+
- run: cmake --install ./build/${{ inputs.preset }} --config ${{ inputs.build_type }}
82+
shell: bash
83+
- id: artifact_name
84+
shell: bash
85+
run: |
86+
sha=${{ github.sha }}
87+
preset="${{ inputs.preset }}"
88+
# strip -host_{arm64,x64} from the preset, because it is not relevant for users
89+
preset=${preset%-host_*}
90+
if [[ -n "${{ inputs.flavour }}" ]]; then
91+
name="libnakama-${{ inputs.flavour }}-${preset}-${{ inputs.build_type }}-git.${sha:0:8}"
92+
else
93+
name="libnakama-${preset}-${{ inputs.build_type }}-git.${sha:0:8}"
94+
fi
95+
echo "::set-output name=artifact::${name}"
96+
#
97+
- run: >
98+
rm -rf ./out/*/*libHttpClient*.{lib,a};
99+
rm -rf ./out/Nakama/libnakama/*/*libHttpClient*.{lib,a};
100+
101+
shell: bash
102+
103+
- name: Prepare artifact archive
104+
run: |
105+
bin7z=$(type -p 7z || type -p 7zr) # windows and linux/osx has different 7z binaries names
106+
cd out
107+
${bin7z} a ../${{ steps.artifact_name.outputs.artifact }}.7z '*'
108+
shell: bash
109+
110+
- uses: actions/upload-artifact@v3
111+
with:
112+
name: ${{ steps.artifact_name.outputs.artifact }}
113+
path: ./${{ steps.artifact_name.outputs.artifact }}.7z
114+
retention-days: ${{ inputs.artifact_retention_days }}
115+
- if: failure()
116+
uses: actions/upload-artifact@v3
117+
with:
118+
name: ${{ steps.artifact_name.outputs.artifact }}-workdir-debug
119+
path: |
120+
./build
121+
./cmake/vcpkg/buildtrees
122+
retention-days: 1
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: 'Builds and runs nakama'
2+
description: 'Builds and runs Nakama'
3+
inputs:
4+
ref:
5+
description: 'Nakama git ref to run'
6+
required: false
7+
default: v3.13.1
8+
postgres_uri:
9+
description: 'PostgreSQL connection URI'
10+
required: true
11+
runs:
12+
using: "composite"
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
repository: heroiclabs/nakama
17+
path: nakama.git
18+
ref: "${{ inputs.ref }}"
19+
fetch-depth: 1
20+
- uses: actions/setup-go@v3
21+
with:
22+
go-version: '1.18'
23+
cache: true
24+
cache-dependency-path: nakama.git/go.sum
25+
- run: go build -v .
26+
shell: bash
27+
working-directory: nakama.git
28+
- run: ./nakama migrate up -database.address "${{ inputs.postgres_uri }}"
29+
shell: bash
30+
working-directory: nakama.git
31+
- run: nohup ./nakama &>/tmp/nakama.log &
32+
shell: bash
33+
working-directory: nakama.git

.github/workflows/buildall.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Build All
2+
on: [workflow_call, workflow_dispatch]
3+
jobs:
4+
windows_matrix:
5+
timeout-minutes: 30
6+
strategy:
7+
matrix:
8+
build_type: [MinSizeRel, Debug]
9+
runs-on: windows-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: ./.github/actions/cmake-build
13+
with:
14+
preset: win-x64
15+
build_type: ${{ matrix.build_type }}
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
18+
# Unreal Engine doesn't officially support debug (/MDd flag) builds,
19+
# so we build Unreal flavour in release config only
20+
- if: ${{ matrix.build_type == 'MinSizeRel' }}
21+
uses: ./.github/actions/cmake-build
22+
with:
23+
preset: win-x64
24+
build_type: ${{ matrix.build_type }}
25+
flavour: Unreal
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
28+
linux_matrix:
29+
timeout-minutes: 30
30+
strategy:
31+
matrix:
32+
flavour: [ "", "libcxx" ]
33+
runs-on: ubuntu-18.04
34+
steps:
35+
- uses: actions/checkout@v3
36+
- uses: ./.github/actions/cmake-build
37+
with:
38+
preset: linux-amd64
39+
flavour: ${{ matrix.flavour }}
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
42+
# Once libc++ version is built, same build tree can be reused for Unreal
43+
- if: matrix.flavour == 'libcxx'
44+
uses: ./.github/actions/cmake-build
45+
with:
46+
preset: linux-amd64
47+
flavour: Unreal
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
50+
android:
51+
timeout-minutes: 60
52+
runs-on: ubuntu-20.04
53+
steps:
54+
- uses: actions/checkout@v3
55+
- uses: ./.github/actions/android-build
56+
with:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
59+
apple_matrix:
60+
timeout-minutes: 30
61+
strategy:
62+
matrix:
63+
preset: ["ios-arm64-host_x64", "iphonesimulator-x64-host_x64", "macosx-x64-host_x64", "macosx-arm64-host_x64"]
64+
runs-on: macos-12
65+
steps:
66+
- uses: actions/checkout@v3
67+
- uses: ./.github/actions/cmake-build
68+
with:
69+
preset: ${{ matrix.preset }}
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
- name: Build Unreal module
72+
uses: ./.github/actions/cmake-build
73+
with:
74+
preset: ${{ matrix.preset }}
75+
flavour: Unreal
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
78+
combine:
79+
needs: [windows_matrix, linux_matrix, apple_matrix]
80+
runs-on: ubuntu-22.04
81+
steps:
82+
- uses: actions/checkout@v3
83+
- name: restore apple's lipo from cache
84+
id: lipo_cache
85+
uses: actions/cache@v3
86+
with:
87+
path: cctools/cctools/misc/lipo
88+
key: lipo-${{ hashFiles('ci/build-lipo.sh') }}
89+
- name: build apple's lipo
90+
if: steps.lipo_cache.outputs.cache-hit != 'true'
91+
run: ./ci/build-lipo.sh
92+
- name: make lipo available on system path
93+
run: echo "$PWD/cctools/cctools/misc" >> $GITHUB_PATH
94+
- uses: actions/download-artifact@v3
95+
with:
96+
path: artifacts7z
97+
98+
- name: Unpack artifacts as if they were plain dir uploads
99+
run: |
100+
for f in artifacts7z/*/*.7z; do
101+
destdir=artifacts/$(basename $(dirname $f))
102+
echo "Unpacking $f to $destdir"
103+
7zr x -o$destdir $f
104+
done
105+
- id: combine
106+
run: /bin/bash -x ./ci/combine-artifacts.sh artifacts
107+
108+
- name: Prepare artifacts archives
109+
run: |
110+
(
111+
cd ./${{ steps.combine.outputs.unreal-artifact-dir }}
112+
7zr a ../${{ steps.combine.outputs.unreal-artifact-name }}.7z '*'
113+
)
114+
(
115+
cd ./${{ steps.combine.outputs.generic-artifact-dir }}
116+
7zr a ../${{ steps.combine.outputs.generic-artifact-name }}.7z '*'
117+
)
118+
119+
- uses: actions/upload-artifact@v3
120+
with:
121+
name: ${{ steps.combine.outputs.unreal-artifact-name }}
122+
path: ./${{ steps.combine.outputs.unreal-artifact-dir }}.7z
123+
- uses: actions/upload-artifact@v3
124+
with:
125+
name: ${{ steps.combine.outputs.generic-artifact-name }}
126+
path: ./${{ steps.combine.outputs.generic-artifact-dir }}.7z
127+
retention-days: 2
128+

0 commit comments

Comments
 (0)