Skip to content

Commit

Permalink
Merge pull request #3 from Totto16/improve_ci
Browse files Browse the repository at this point in the history
improve all ci's
  • Loading branch information
Totto16 authored Oct 3, 2024
2 parents eb08165 + e1e3c1a commit f033ae4
Show file tree
Hide file tree
Showing 18 changed files with 180 additions and 113 deletions.
35 changes: 12 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,53 +15,53 @@ jobs:
fail-fast: false
matrix:
config:
- name: Windows MSVC Release
- name: Windows MSVC
os: windows
os-version: 2022
environment: msvc
shell: pwsh

- name: Windows MingGW Release
- name: Windows MingGW
os: windows
os-version: 2022
environment: mingw
architecture: x86_64
shell: 'msys2 {0}'

- name: Windows UCRT Release
- name: Windows UCRT
os: windows
os-version: 2022
environment: ucrt
architecture: ucrt-x86_64
shell: 'msys2 {0}'

- name: Linux Release
- name: Linux
os: ubuntu
os-version: 24.04
use-clang: false
shell: bash

- name: Linux Clang Release (libstdc++)
- name: Linux Clang (libstdc++)
os: ubuntu
os-version: 24.04
use-clang: true
use-clang_stdlib: false
shell: bash

- name: Linux Clang Release (libc++)
- name: Linux Clang (libc++)
os: ubuntu
os-version: 24.04
use-clang: true
use-clang_stdlib: true
shell: bash

- name: MacOS Release
- name: MacOS
os: macos
os-version: 13
arm: false
shell: bash

- name: MacOS Release (Arm64)
- name: MacOS (Arm64)
os: macos
os-version: 14
arm: true
Expand Down Expand Up @@ -183,24 +183,13 @@ jobs:
choco install pkgconfiglite
echo "PKG_CONFIG_PATH=C:/lib/pkgconfig" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Configure OOPetris
- name: Build and Install OOPetris
run: |
cd oopetris
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}/' || ''}}
- name: Build and install Libs
if: matrix.config.os != 'ubuntu'
run: |
cd oopetris
meson install -C build
- name: Build and install Libs (Linux)
if: matrix.config.os == 'ubuntu'
run: |
cd oopetris
sudo meson install -C build
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}/' || ''}}
${{ matrix.config.os == 'ubuntu' && 'sudo' || '' }} meson install -C build
- name: Build Wrapper
run: |
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' || '' }}
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' || '' }}
meson compile -C build
13 changes: 5 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,17 @@ jobs:
sudo apt-get update
sudo apt-get install ninja-build valgrind gcovr libcriterion-dev libreadline-dev -y --no-install-recommends
- name: Configure OOPetris
run: |
cd oopetris
meson setup build -Db_coverage=true -Dbuildtype=debugoptimized -Ddefault_library=shared -Dclang_libcpp=enabled -Donly_build_libs=true -Dprefix=/usr
- name: Build and install Libs
- name: Build and Install OOPetris
run: |
cd oopetris
meson setup build -Db_coverage=true -Dbuildtype=debugoptimized -Ddefault_library=shared -Dclang_libcpp=enabled -Donly_build_libs=true
sudo meson install -C build
- name: Build Wrapper
run: |
meson setup build -Db_coverage=true -Dbuildtype=debugoptimized -Ddefault_library=shared -Dclang_libcpp=enabled -Dtests=true -Dexample=true -Dprefix=/usr
meson setup build -Db_coverage=true -Dbuildtype=debugoptimized -Ddefault_library=shared -Dclang_libcpp=enabled -Dtests=true -Dexample=true
meson compile -C build
sudo ldconfig
- name: Test Wrapper
run: |
Expand All @@ -81,7 +78,7 @@ jobs:
./build/meson-logs/coverage.xml
./build/meson-logs/coveragereport/
- name: Test for leaks with valgrind (Linux)
- name: Test for leaks with valgrind
run: |
valgrind --tool=memcheck --leak-check=full --error-exitcode=1 ./build/example/example r ./tests/files/correct.rec
valgrind --tool=memcheck --leak-check=full --error-exitcode=1 cat ./tests/files/example.rec_text | ./build/example/example w ./test.rec
Expand Down
2 changes: 1 addition & 1 deletion example/main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include "oopetris_wrapper.h"
#include <c_wrapper/wrapper.h>

#include <assert.h>
#include <inttypes.h>
Expand Down
10 changes: 10 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ liboopetris_c_wrapper = library(
'oopetris_c_wrapper',
src_files,
dependencies: deps,
cpp_shared_args: ['-DOOPETRIS_LIBRARY_C_WRAPPER_EXPORT'],
override_options: {
'warning_level': '3',
'werror': true,
Expand All @@ -43,6 +44,14 @@ liboopetris_c_wrapper_dep = declare_dependency(
)
meson.override_dependency('liboopetris-c-wrapper', liboopetris_c_wrapper_dep)

cpp = meson.get_compiler('cpp')

pkg_cpp_compiler = cpp.get_id()
pkg_cpp_stdlib = 'unknown'
if cpp.get_id() == 'clang'
pkg_cpp_stdlib = build_with_libcpp ? 'libc++' : 'libstdc++'
endif

# generate pkgconfig files
pkg = import('pkgconfig')
pkg.generate(
Expand All @@ -51,6 +60,7 @@ pkg.generate(
name: 'oopetris-c-wrapper',
filebase: 'oopetris-c-wrapper',
subdirs: 'oopetris',
variables: ['compiler=' + pkg_cpp_compiler, 'cpp_stdlib=' + pkg_cpp_stdlib],
)

if get_option('tests')
Expand Down
19 changes: 19 additions & 0 deletions src/c_wrapper/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
_header_files = files(
'windows.h',
'wrapper.h',
)

src_files += files(
'opaque_types.h', # not needed to be installed
'wrapper.cpp',
)

install_headers(
_header_files,
install_dir: c_wrapper_include_dir,
preserve_path: true,
)

src_files += _header_files

subdir('thirdparty')
2 changes: 1 addition & 1 deletion src/opaque_types.h → src/c_wrapper/opaque_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#pragma once

#include "oopetris_wrapper.h"
#include "./wrapper.h"

#ifdef __cplusplus
extern "C" {
Expand Down
11 changes: 11 additions & 0 deletions src/c_wrapper/thirdparty/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
_header_files = files(
'stb_ds.h',
)

install_headers(
_header_files,
install_dir: c_wrapper_include_dir / 'thirdparty',
preserve_path: true,
)

src_files += _header_files
File renamed without changes.
21 changes: 21 additions & 0 deletions src/c_wrapper/windows.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif


#if defined(_MSC_VER)
#if defined(OOPETRIS_LIBRARY_C_WRAPPER_EXPORT)
#define OOPETRIS_C_WRAPPER_EXPORTED __declspec(dllexport)
#else
#define OOPETRIS_C_WRAPPER_EXPORTED __declspec(dllimport)
#endif
#else
#define OOPETRIS_C_WRAPPER_EXPORTED
#endif


#ifdef __cplusplus
}
#endif
18 changes: 10 additions & 8 deletions src/wrapper.cpp → src/c_wrapper/wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@


#include "core/game/mino_stack.hpp"
#include "core/game/tetromino_type.hpp"
#include "core/helper/input_event.hpp"
#include "oopetris_wrapper.h"
#include "opaque_types.h"
#include "recordings/utility/additional_information.hpp"
#include "recordings/utility/recording_writer.hpp"
#include <core/game/mino_stack.hpp>
#include <core/game/tetromino_type.hpp>
#include <core/helper/input_event.hpp>
#include <recordings/recordings.hpp>
#include <recordings/utility/additional_information.hpp>
#include <recordings/utility/recording_writer.hpp>

#include "./opaque_types.h"
#include "./wrapper.h"

#include <filesystem>
#include <memory>
#include <utility>
Expand All @@ -32,7 +35,6 @@
#include <core/core.hpp>
#include <cstring>
#include <ctime>
#include <recordings/recordings.hpp>


bool oopetris_is_recording_file(const char* file_path) {
Expand Down
Loading

0 comments on commit f033ae4

Please sign in to comment.