Skip to content

Commit 45bef91

Browse files
authored
Feat(CI): Add automated builds (#1)
* Feat(CI): Add automated builds
1 parent c3abdb7 commit 45bef91

File tree

6 files changed

+547
-1
lines changed

6 files changed

+547
-1
lines changed

.github/workflows/cjson.yml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: CJSON-Main
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- 'master'
8+
pull_request:
9+
branches: [ master ]
10+
11+
jobs:
12+
CJSON_MASTER:
13+
strategy:
14+
matrix:
15+
build_type: [Release, RelWithDebInfo, MinSizeRel, Debug]
16+
target_system: [ ubuntu-22.04, windows-2022 ]
17+
runs-on: ${{ matrix.target_system }}
18+
env:
19+
BUILD_EXT: ${{ matrix.target_system == 'windows-2022' && '.dll' || '.so' }}
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Prime ccache
25+
uses: hendrikmuhs/[email protected]
26+
with:
27+
key: ${{ matrix.target_system }}-${{ matrix.build_type }}
28+
max-size: 1000M
29+
30+
- name: Cache LuaJIT
31+
id: cache-Lua
32+
uses: actions/cache@v3
33+
with:
34+
path: |
35+
${{ runner.os == 'Linux' && 'apt-cache' || 'LuaJIT' }}
36+
key: ${{ runner.os }}-Lua
37+
38+
- name: Get Deps (LuaJIT)
39+
shell: bash
40+
if: steps.cache-Lua.outputs.cache-hit != 'true'
41+
run: |
42+
${{ runner.os == 'Linux' && 'sudo' || '' }} CI/get_luajit.${{runner.os}}.sh openmw-deps
43+
44+
- name: Configure
45+
shell: bash
46+
run: |
47+
LUA_DIR=LuaJIT/ cmake .
48+
49+
- name: Build
50+
run: |
51+
cmake --build . --config ${{ matrix.build_type }}
52+
53+
- name: Prep Windows Release
54+
if: runner.os == 'Windows'
55+
run: |
56+
mv ${{ github.workspace }}/${{ matrix.build_type }}/cjson.dll ${{ github.workspace }}/cjson-${{ matrix.build_type }}.dll
57+
58+
- name: Prep Linux Release
59+
if: runner.os != 'Windows'
60+
run: |
61+
mv ${{ github.workspace }}/cjson.so ${{ github.workspace }}/cjson-${{ matrix.build_type }}.so
62+
63+
- name: Upload Release
64+
if: github.event_name != 'pull_request'
65+
uses: softprops/action-gh-release@v1
66+
with:
67+
tag_name: Stable-CI
68+
files: ${{ github.workspace }}/cjson-${{ matrix.build_type }}${{ env.BUILD_EXT }}
69+
body: |
70+
CI Build for Dreamweave IO2 fork
71+
72+
- name: Upload Artifact
73+
if: github.event_name == 'pull_request'
74+
uses: actions/upload-artifact@v3
75+
with:
76+
name: cjson-${{ matrix.build_type }}-${{matrix.target_system}}
77+
path: ${{ github.workspace }}/cjson-${{ matrix.build_type }}${{ env.BUILD_EXT }}

CI/get_luajit.Linux.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
print_help() {
6+
echo "usage: $0 [group]..."
7+
echo
8+
echo " available groups: "${!GROUPED_DEPS[@]}""
9+
}
10+
11+
declare -rA GROUPED_DEPS=(
12+
# Common dependencies for building OpenMW.
13+
[openmw-deps]="
14+
libluajit-5.1-dev
15+
"
16+
)
17+
18+
if [[ $# -eq 0 ]]; then
19+
>&2 print_help
20+
exit 1
21+
fi
22+
23+
deps=()
24+
for group in "$@"; do
25+
if [[ ! -v GROUPED_DEPS[$group] ]]; then
26+
>&2 echo "error: unknown group ${group}"
27+
exit 1
28+
fi
29+
deps+=(${GROUPED_DEPS[$group]})
30+
done
31+
32+
export APT_CACHE_DIR="${PWD}/apt-cache"
33+
set -x
34+
mkdir -pv "$APT_CACHE_DIR"
35+
apt-get update -yq
36+
apt-get -q -o dir::cache::archives="$APT_CACHE_DIR" install -y --no-install-recommends "${deps[@]}"

CI/get_luajit.windows.sh

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
set -e
2+
3+
download() {
4+
if [ $# -lt 3 ]; then
5+
echo "Invalid parameters to download."
6+
return 1
7+
fi
8+
9+
NAME=$1
10+
shift
11+
12+
echo "$NAME..."
13+
14+
while [ $# -gt 1 ]; do
15+
URL=$1
16+
FILE=$2
17+
shift
18+
shift
19+
20+
if ! [ -f $FILE ]; then
21+
printf " Downloading $FILE... "
22+
23+
if [ -z $VERBOSE ]; then
24+
RET=0
25+
curl --silent --fail --retry 10 -Ly 5 -o $FILE $URL || RET=$?
26+
else
27+
RET=0
28+
curl --fail --retry 10 -Ly 5 -o $FILE $URL || RET=$?
29+
fi
30+
31+
if [ $RET -ne 0 ]; then
32+
echo "Failed!"
33+
wrappedExit $RET
34+
else
35+
echo "Done."
36+
fi
37+
else
38+
echo " $FILE exists, skipping."
39+
fi
40+
done
41+
42+
if [ $# -ne 0 ]; then
43+
echo "Missing parameter."
44+
fi
45+
}
46+
47+
download "LuaJIT v2.1.0-beta3-452-g7a0cf5fd" \
48+
"https://gitlab.com/OpenMW/openmw-deps/-/raw/main/windows/LuaJIT-v2.1.0-beta3-452-g7a0cf5fd-msvc2019-win64.7z" \
49+
"LuaJIT-v2.1.0-beta3-452-g7a0cf5fd-msvc2019-win64.7z"
50+
51+
echo "Extracting LuaJIT . . ."
52+
eval 7z x -y LuaJIT-v2.1.0-beta3-452-g7a0cf5fd-msvc2019-win64.7z -o./LuaJIT

CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ if(NOT CMAKE_BUILD_TYPE)
1515
FORCE)
1616
endif()
1717

18-
find_package(Lua51 REQUIRED)
18+
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/)
19+
20+
find_package(LuaJit REQUIRED)
1921
include_directories(${LUA_INCLUDE_DIR})
2022

2123
if(NOT USE_INTERNAL_FPCONV)

cmake/FindLuaJit.cmake

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
include(LibFindMacros)
2+
3+
libfind_pkg_detect(LuaJit luajit
4+
FIND_PATH luajit.h
5+
HINTS $ENV{LUA_DIR}
6+
PATH_SUFFIXES include include/luajit-2.1
7+
FIND_LIBRARY luajit-5.1 luajit lua51
8+
HINTS $ENV{LUA_DIR}
9+
PATH_SUFFIXES lib
10+
)
11+
12+
13+
libfind_process(LuaJit)
14+
15+
set(LUA_LIBRARY ${LuaJit_LIBRARY})
16+
set(LUA_INCLUDE_DIR ${LuaJit_INCLUDE_DIR})

0 commit comments

Comments
 (0)