Skip to content

Commit f033ae4

Browse files
authored
Merge pull request #3 from Totto16/improve_ci
improve all ci's
2 parents eb08165 + e1e3c1a commit f033ae4

File tree

18 files changed

+180
-113
lines changed

18 files changed

+180
-113
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,53 +15,53 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
config:
18-
- name: Windows MSVC Release
18+
- name: Windows MSVC
1919
os: windows
2020
os-version: 2022
2121
environment: msvc
2222
shell: pwsh
2323

24-
- name: Windows MingGW Release
24+
- name: Windows MingGW
2525
os: windows
2626
os-version: 2022
2727
environment: mingw
2828
architecture: x86_64
2929
shell: 'msys2 {0}'
3030

31-
- name: Windows UCRT Release
31+
- name: Windows UCRT
3232
os: windows
3333
os-version: 2022
3434
environment: ucrt
3535
architecture: ucrt-x86_64
3636
shell: 'msys2 {0}'
3737

38-
- name: Linux Release
38+
- name: Linux
3939
os: ubuntu
4040
os-version: 24.04
4141
use-clang: false
4242
shell: bash
4343

44-
- name: Linux Clang Release (libstdc++)
44+
- name: Linux Clang (libstdc++)
4545
os: ubuntu
4646
os-version: 24.04
4747
use-clang: true
4848
use-clang_stdlib: false
4949
shell: bash
5050

51-
- name: Linux Clang Release (libc++)
51+
- name: Linux Clang (libc++)
5252
os: ubuntu
5353
os-version: 24.04
5454
use-clang: true
5555
use-clang_stdlib: true
5656
shell: bash
5757

58-
- name: MacOS Release
58+
- name: MacOS
5959
os: macos
6060
os-version: 13
6161
arm: false
6262
shell: bash
6363

64-
- name: MacOS Release (Arm64)
64+
- name: MacOS (Arm64)
6565
os: macos
6666
os-version: 14
6767
arm: true
@@ -183,24 +183,13 @@ jobs:
183183
choco install pkgconfiglite
184184
echo "PKG_CONFIG_PATH=C:/lib/pkgconfig" | Out-File -FilePath $env:GITHUB_ENV -Append
185185
186-
- name: Configure OOPetris
186+
- name: Build and Install OOPetris
187187
run: |
188188
cd oopetris
189-
meson setup build -Dbuildtype=release -Ddefault_library=static -Dclang_libcpp=${{ ( ( matrix.config.os == 'ubuntu' && matrix.config.use-clang == true && matrix.config.use-clang_stdlib ) || matrix.config.os == 'macos' ) && 'enabled' || 'disabled' }} -Donly_build_libs=true ${{ matrix.config.os == 'windows' && '-Db_vscrt=from_buildtype' || '' }} ${{ (matrix.config.os == 'windows' && ( matrix.config.environment == 'mingw' || matrix.config.environment == 'ucrt' )) && '-Dprefix=$RUNNER_TEMP/msys64${MINGW_PREFIX}/' || ''}}
190-
191-
- name: Build and install Libs
192-
if: matrix.config.os != 'ubuntu'
193-
run: |
194-
cd oopetris
195-
meson install -C build
196-
197-
- name: Build and install Libs (Linux)
198-
if: matrix.config.os == 'ubuntu'
199-
run: |
200-
cd oopetris
201-
sudo meson install -C build
189+
meson setup build -Dbuildtype=release -Ddefault_library=shared -Dclang_libcpp=${{ ( ( matrix.config.os == 'ubuntu' && matrix.config.use-clang == true && matrix.config.use-clang_stdlib ) || matrix.config.os == 'macos' ) && 'enabled' || 'disabled' }} -Donly_build_libs=true ${{ matrix.config.os == 'windows' && '-Db_vscrt=from_buildtype' || '' }} ${{ (matrix.config.os == 'windows' && ( matrix.config.environment == 'mingw' || matrix.config.environment == 'ucrt' )) && '-Dprefix=$RUNNER_TEMP/msys64${MINGW_PREFIX}/' || ''}}
190+
${{ matrix.config.os == 'ubuntu' && 'sudo' || '' }} meson install -C build
202191
203192
- name: Build Wrapper
204193
run: |
205-
meson setup -Dtests=false -Dexample=true build -Dbuildtype=release -Ddefault_library=static -Dclang_libcpp=${{ ( ( matrix.config.os == 'ubuntu' && matrix.config.use-clang == true && matrix.config.use-clang_stdlib ) || matrix.config.os == 'macos' ) && 'enabled' || 'disabled' }} ${{ matrix.config.os == 'windows' && '-Db_vscrt=from_buildtype' || '' }}
194+
meson setup -Dtests=false -Dexample=true build -Dbuildtype=release -Ddefault_library=shared -Dclang_libcpp=${{ ( ( matrix.config.os == 'ubuntu' && matrix.config.use-clang == true && matrix.config.use-clang_stdlib ) || matrix.config.os == 'macos' ) && 'enabled' || 'disabled' }} ${{ matrix.config.os == 'windows' && '-Db_vscrt=from_buildtype' || '' }}
206195
meson compile -C build

.github/workflows/test.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,17 @@ jobs:
4343
sudo apt-get update
4444
sudo apt-get install ninja-build valgrind gcovr libcriterion-dev libreadline-dev -y --no-install-recommends
4545
46-
- name: Configure OOPetris
47-
run: |
48-
cd oopetris
49-
meson setup build -Db_coverage=true -Dbuildtype=debugoptimized -Ddefault_library=shared -Dclang_libcpp=enabled -Donly_build_libs=true -Dprefix=/usr
50-
51-
- name: Build and install Libs
46+
- name: Build and Install OOPetris
5247
run: |
5348
cd oopetris
49+
meson setup build -Db_coverage=true -Dbuildtype=debugoptimized -Ddefault_library=shared -Dclang_libcpp=enabled -Donly_build_libs=true
5450
sudo meson install -C build
5551
5652
- name: Build Wrapper
5753
run: |
58-
meson setup build -Db_coverage=true -Dbuildtype=debugoptimized -Ddefault_library=shared -Dclang_libcpp=enabled -Dtests=true -Dexample=true -Dprefix=/usr
54+
meson setup build -Db_coverage=true -Dbuildtype=debugoptimized -Ddefault_library=shared -Dclang_libcpp=enabled -Dtests=true -Dexample=true
5955
meson compile -C build
56+
sudo ldconfig
6057
6158
- name: Test Wrapper
6259
run: |
@@ -81,7 +78,7 @@ jobs:
8178
./build/meson-logs/coverage.xml
8279
./build/meson-logs/coveragereport/
8380
84-
- name: Test for leaks with valgrind (Linux)
81+
- name: Test for leaks with valgrind
8582
run: |
8683
valgrind --tool=memcheck --leak-check=full --error-exitcode=1 ./build/example/example r ./tests/files/correct.rec
8784
valgrind --tool=memcheck --leak-check=full --error-exitcode=1 cat ./tests/files/example.rec_text | ./build/example/example w ./test.rec

example/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
#include "oopetris_wrapper.h"
2+
#include <c_wrapper/wrapper.h>
33

44
#include <assert.h>
55
#include <inttypes.h>

meson.build

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ liboopetris_c_wrapper = library(
2727
'oopetris_c_wrapper',
2828
src_files,
2929
dependencies: deps,
30+
cpp_shared_args: ['-DOOPETRIS_LIBRARY_C_WRAPPER_EXPORT'],
3031
override_options: {
3132
'warning_level': '3',
3233
'werror': true,
@@ -43,6 +44,14 @@ liboopetris_c_wrapper_dep = declare_dependency(
4344
)
4445
meson.override_dependency('liboopetris-c-wrapper', liboopetris_c_wrapper_dep)
4546

47+
cpp = meson.get_compiler('cpp')
48+
49+
pkg_cpp_compiler = cpp.get_id()
50+
pkg_cpp_stdlib = 'unknown'
51+
if cpp.get_id() == 'clang'
52+
pkg_cpp_stdlib = build_with_libcpp ? 'libc++' : 'libstdc++'
53+
endif
54+
4655
# generate pkgconfig files
4756
pkg = import('pkgconfig')
4857
pkg.generate(
@@ -51,6 +60,7 @@ pkg.generate(
5160
name: 'oopetris-c-wrapper',
5261
filebase: 'oopetris-c-wrapper',
5362
subdirs: 'oopetris',
63+
variables: ['compiler=' + pkg_cpp_compiler, 'cpp_stdlib=' + pkg_cpp_stdlib],
5464
)
5565

5666
if get_option('tests')

src/c_wrapper/meson.build

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
_header_files = files(
2+
'windows.h',
3+
'wrapper.h',
4+
)
5+
6+
src_files += files(
7+
'opaque_types.h', # not needed to be installed
8+
'wrapper.cpp',
9+
)
10+
11+
install_headers(
12+
_header_files,
13+
install_dir: c_wrapper_include_dir,
14+
preserve_path: true,
15+
)
16+
17+
src_files += _header_files
18+
19+
subdir('thirdparty')

src/opaque_types.h renamed to src/c_wrapper/opaque_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#pragma once
44

5-
#include "oopetris_wrapper.h"
5+
#include "./wrapper.h"
66

77
#ifdef __cplusplus
88
extern "C" {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
_header_files = files(
2+
'stb_ds.h',
3+
)
4+
5+
install_headers(
6+
_header_files,
7+
install_dir: c_wrapper_include_dir / 'thirdparty',
8+
preserve_path: true,
9+
)
10+
11+
src_files += _header_files
File renamed without changes.

src/c_wrapper/windows.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma once
2+
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
8+
#if defined(_MSC_VER)
9+
#if defined(OOPETRIS_LIBRARY_C_WRAPPER_EXPORT)
10+
#define OOPETRIS_C_WRAPPER_EXPORTED __declspec(dllexport)
11+
#else
12+
#define OOPETRIS_C_WRAPPER_EXPORTED __declspec(dllimport)
13+
#endif
14+
#else
15+
#define OOPETRIS_C_WRAPPER_EXPORTED
16+
#endif
17+
18+
19+
#ifdef __cplusplus
20+
}
21+
#endif

src/wrapper.cpp renamed to src/c_wrapper/wrapper.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11

22

3-
#include "core/game/mino_stack.hpp"
4-
#include "core/game/tetromino_type.hpp"
5-
#include "core/helper/input_event.hpp"
6-
#include "oopetris_wrapper.h"
7-
#include "opaque_types.h"
8-
#include "recordings/utility/additional_information.hpp"
9-
#include "recordings/utility/recording_writer.hpp"
3+
#include <core/game/mino_stack.hpp>
4+
#include <core/game/tetromino_type.hpp>
5+
#include <core/helper/input_event.hpp>
6+
#include <recordings/recordings.hpp>
7+
#include <recordings/utility/additional_information.hpp>
8+
#include <recordings/utility/recording_writer.hpp>
9+
10+
#include "./opaque_types.h"
11+
#include "./wrapper.h"
12+
1013
#include <filesystem>
1114
#include <memory>
1215
#include <utility>
@@ -32,7 +35,6 @@
3235
#include <core/core.hpp>
3336
#include <cstring>
3437
#include <ctime>
35-
#include <recordings/recordings.hpp>
3638

3739

3840
bool oopetris_is_recording_file(const char* file_path) {

0 commit comments

Comments
 (0)