Skip to content

Commit 6cd3581

Browse files
improve build (#7)
* improve build steps * fix syntax and whitespace * fix env var * fix path * exclude unknown flags * fix variable name Co-authored-by: CommonLoon102 <CommonLoon102@users.noreply.github.com>
1 parent 08b59c8 commit 6cd3581

File tree

5 files changed

+156
-169
lines changed

5 files changed

+156
-169
lines changed

.github/workflows/build.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
release:
9+
types: [ published ]
10+
11+
env:
12+
app_name: hode
13+
build_dir: build
14+
package_dir: package
15+
16+
jobs:
17+
build:
18+
name: ${{ matrix.config.name }} | ${{ matrix.config.build_type }}
19+
runs-on: ${{ matrix.config.os }}
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
config:
24+
- {
25+
name: "Windows 64-bit",
26+
os: windows-latest,
27+
extra_options: "-A x64 -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake",
28+
platform: "win-x64",
29+
build_type: "Release"
30+
}
31+
- {
32+
name: "Linux",
33+
os: ubuntu-latest,
34+
deps_cmdline: "sudo apt update && sudo apt install libsdl2-dev",
35+
platform: "linux-x64",
36+
build_type: "Release"
37+
}
38+
- {
39+
name: "macOS",
40+
os: macos-latest,
41+
deps_cmdline: "brew upgrade && brew install sdl2",
42+
platform: "osx-x64",
43+
build_type: "Release"
44+
}
45+
46+
steps:
47+
- uses: actions/checkout@v2
48+
49+
- name: Install Dependencies
50+
shell: bash
51+
run: |
52+
git submodule update --init ./3p/inih
53+
git submodule update --init ./3p/libxbr-standalone
54+
if [[ ! -z "${{ matrix.config.deps_cmdline }}" ]]; then
55+
eval ${{ matrix.config.deps_cmdline }}
56+
fi
57+
mkdir ${{ env.build_dir }}
58+
59+
- name: Configure
60+
shell: bash
61+
run: |
62+
cmake -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} ${{ matrix.config.extra_options }} .
63+
64+
- name: Build
65+
shell: bash
66+
run: |
67+
export MAKEFLAGS=--keep-going
68+
cmake --build ${{ env.build_dir }} --config ${{ matrix.config.build_type }} --parallel 3
69+
70+
- name: Create Package
71+
shell: bash
72+
run: |
73+
cd ${{ env.build_dir }}
74+
mkdir ${{ env.package_dir }}
75+
if [[ "${{ runner.os }}" == 'Windows' ]]; then
76+
cp ${{ matrix.config.build_type }}/${{ env.app_name }}.exe ${{ matrix.config.build_type }}/SDL2.dll ${{ matrix.config.build_type }}/getopt.dll ../${{ env.app_name }}.ini ${{ env.package_dir }}
77+
else
78+
cp ${{ env.app_name }} ../${{ env.app_name }}.ini ${{ env.package_dir }}
79+
fi
80+
81+
- name: Zip Package
82+
shell: bash
83+
run: |
84+
filename=${{ env.app_name }}-${{ matrix.config.platform }}
85+
if [[ "${{ runner.os }}" == 'Windows' ]]; then
86+
7z a $filename.zip ./${{ env.build_dir }}/${{ env.package_dir }}/*
87+
else
88+
zip --junk-paths $filename ./${{ env.build_dir }}/${{ env.package_dir }}/*
89+
fi
90+
91+
- name: Upload Zipped Artifact
92+
uses: actions/upload-artifact@v2
93+
with:
94+
name: ${{ matrix.config.platform }} ${{ matrix.config.build_type }}
95+
path: ${{ env.app_name }}-${{ matrix.config.platform }}.zip
96+
97+
- name: List Build Directory
98+
if: always()
99+
shell: bash
100+
run: |
101+
git status
102+
ls -lR ${{ env.build_dir }}
103+
104+
upload-packages:
105+
needs: build
106+
runs-on: ubuntu-latest
107+
if: (github.event_name == 'release' && github.event.action == 'published' && startsWith(github.ref, 'refs/tags/'))
108+
strategy:
109+
fail-fast: false
110+
matrix:
111+
config:
112+
- {
113+
platform: win-x64,
114+
build_type: "Release"
115+
}
116+
- {
117+
platform: linux-x64,
118+
build_type: "Release"
119+
}
120+
- {
121+
platform: osx-x64,
122+
build_type: "Release"
123+
}
124+
steps:
125+
- name: Get release
126+
id: get_release
127+
uses: bruceadams/get-release@v1.2.0
128+
env:
129+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130+
131+
- name: Download artifacts
132+
uses: actions/download-artifact@v2
133+
with:
134+
name: ${{ matrix.config.platform }} ${{ matrix.config.build_type }}
135+
136+
- name: Upload Release Assets
137+
uses: actions/upload-release-asset@v1
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
with:
141+
upload_url: ${{ steps.get_release.outputs.upload_url }}
142+
asset_path: ${{ env.app_name }}-${{ matrix.config.platform }}.zip
143+
asset_name: ${{ env.app_name }}-${{ matrix.config.platform }}.zip
144+
asset_content_type: application/zip

.github/workflows/continuous_integration.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

.github/workflows/publish_release.yml

Lines changed: 0 additions & 88 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ cmake_minimum_required(VERSION 3.0)
44

55
include(FindPkgConfig)
66

7-
if(NOT MSVC AND CMAKE_BUILD_TYPE MATCHES "Deb")
8-
set (CMAKE_CXX_FLAGS "-g ${CMAKE_CXX_FLAGS}")
7+
if(NOT MSVC)
8+
set(CMAKE_CXX_FLAGS "-pedantic -MMD ${CMAKE_CXX_FLAGS}")
9+
if(CMAKE_BUILD_TYPE MATCHES "Deb")
10+
set (CMAKE_CXX_FLAGS "-g ${CMAKE_CXX_FLAGS}")
11+
endif()
912
endif()
1013

11-
set(CMAKE_CXX_FLAGS "-Wall -pedantic -MMD ${CMAKE_CXX_FLAGS}")
14+
set(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}")
1215
if(VITA)
1316
set(ENV{PKG_CONFIG_PATH} "$ENV{VITASDK}/arm-vita-eabi/lib/pkgconfig")
1417
endif(VITA)

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ Linux
3131
```
3232
sudo apt update
3333
sudo apt install libsdl2-dev git make cmake gcc g++ -y
34-
git clone --recurse-submodules https://github.com/CommonLoon102/hode-vs
34+
git clone https://github.com/CommonLoon102/hode-vs
3535
cd hode-vs
36+
git submodule update --init ./3p/inih
37+
git submodule update --init ./3p/libxbr-standalone
3638
cmake -B build -DCMAKE_BUILD_TYPE=Release
3739
cmake --build build --config Release --parallel 3
3840
```
@@ -42,8 +44,10 @@ macOS
4244
```
4345
brew upgrade
4446
brew install sdl2
45-
git clone --recurse-submodules https://github.com/CommonLoon102/hode-vs
47+
git clone https://github.com/CommonLoon102/hode-vs
4648
cd hode-vs
49+
git submodule update --init ./3p/inih
50+
git submodule update --init ./3p/libxbr-standalone
4751
cmake -B build -DCMAKE_BUILD_TYPE=Release
4852
cmake --build build --config Release --parallel 3
4953
```

0 commit comments

Comments
 (0)