Skip to content

Commit

Permalink
Merge pull request #160 from OpenBrickProtocolFoundation/improve-reco…
Browse files Browse the repository at this point in the history
…rding-utility

Improve recording utility
  • Loading branch information
Totto16 authored May 27, 2024
2 parents 08bf553 + ba7b483 commit b2271fa
Show file tree
Hide file tree
Showing 246 changed files with 10,517 additions and 1,946 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cpp-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
tidy-checks: ""
step-summary: true
file-annotations: true
ignore: subprojects|build|android|assets|recordings|docs|toolchains|platforms|src/thirdparty
ignore: subprojects|build|android|assets|recordings|docs|toolchains|platforms|wrapper|src/libs/core/hash-library

- name: Fail CI run if linter checks failed
if: steps.linter.outputs.checks-failed != 0
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/flatpak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ jobs:
with:
bundle: oopetris.flatpak
manifest-path: com.github.mgerhold.OOPetris.yml
verbose: ${{ runner.debug == '1' && 'true' || 'false' }}
22 changes: 3 additions & 19 deletions .github/workflows/meson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,32 +177,16 @@ jobs:
if: matrix.config.os == 'macos'
run: |
brew update
brew install ninja sdl2 sdl2_ttf sdl2_mixer sdl2_image
brew install sdl2 sdl2_ttf sdl2_mixer sdl2_image
- name: Configure
run: meson setup build -Dbuildtype=${{ matrix.config.buildtype }} -Ddefault_library=${{ matrix.config.library_type }} -Dclang_libcpp=${{ ( ( matrix.config.os == 'ubuntu' && matrix.config.use-clang == true && matrix.config.use-clang_stdlib ) || matrix.config.os == 'macos' ) && 'enabled' || 'disabled' }}

- name: Build
run: meson compile -C build

- name: Upload artifacts - Linux
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: matrix.config.os == 'ubuntu'
with:
name: ${{ matrix.config.name }} Executable
path: build/oopetris

- name: Upload artifacts - MacOS
uses: actions/upload-artifact@v4
if: matrix.config.os == 'macos'
with:
name: ${{ matrix.config.name }} Executable
path: build/oopetris
# TODO: create a proper installer: https://mesonbuild.com/Creating-OSX-packages.html

- name: Upload artifacts - Windows
uses: actions/upload-artifact@v4
if: matrix.config.os == 'windows'
with:
name: ${{ matrix.config.name }} Executable
path: build/oopetris.exe
path: build/src/executables/oopetris*
124 changes: 124 additions & 0 deletions .github/workflows/wrapper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Wrapper CI

on:
push:
branches: ["main"]
pull_request:
workflow_dispatch:

jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}-${{ matrix.config.os-version }}

strategy:
fail-fast: false
matrix:
config:
- name: Windows
os: windows
os-version: 2022

- name: Linux
os: ubuntu
os-version: 24.04

- name: MacOS
os: macos
os-version: 13

- name: MacOS (Arm64)
os: macos
os-version: 14


steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"

- name: Setup MSVC (Windows)
if: matrix.config.os == 'windows'
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64
toolset: 14.39

- name: Setup GCC (Linux)
if: matrix.config.os == 'ubuntu'
uses: egor-tensin/setup-gcc@v1
with:
version: 14
platform: x64

- name: Setup Clang (MacOS)
if: matrix.config.os == 'macos'
run: |
brew update
brew install llvm@18
echo "$(brew --prefix)/opt/llvm/bin" >> $GITHUB_PATH
echo "LDFLAGS=-L$(brew --prefix)/opt/llvm/lib -L$(brew --prefix)/opt/llvm/lib/c++ -Wl,-rpath,$(brew --prefix)/opt/llvm/lib/c++" >> "$GITHUB_ENV"
echo "CPPFLAGS=-I$(brew --prefix)/opt/llvm/include" >> "$GITHUB_ENV"
echo "CC=clang" >> "$GITHUB_ENV"
echo "CXX=clang++" >> "$GITHUB_ENV"
echo "OBJC=clang" >> "$GITHUB_ENV"
echo "CC_LD=lld" >> "$GITHUB_ENV"
echo "CXX_LD=lld" >> "$GITHUB_ENV"
echo "OBJC_LD=lld" >> "$GITHUB_ENV"
- name: Setup meson (MacOS)
if: matrix.config.os == 'macos'
run: |
brew update
brew install meson
# NOTE: meson has no dependencies, so --break-system-packages doesn't really break anything!
- name: Setup meson
if: matrix.config.os != 'macos'
run: |
pip install meson --break-system-packages
- name: Install dependencies (Linux)
if: matrix.config.os == 'ubuntu'
run: |
sudo apt-get update
sudo apt-get install ninja-build -y
sudo pip install meson --break-system-packages
- name: Fix pkg-config (Windows)
if: matrix.config.os == 'windows'
run: |
Remove-Item -Path C:\Strawberry\ -Recurse
choco install pkgconfiglite
echo "PKG_CONFIG_PATH=C:/lib/pkgconfig" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Configure
run: meson setup build -Dbuildtype=release -Ddefault_library=static -Dclang_libcpp=${{ matrix.config.os == 'macos' && 'enabled' || 'disabled' }} -Donly_build_libs=true ${{ matrix.config.os == 'windows' && '-Db_vscrt=static_from_buildtype' || '' }}

- name: Build and install Libs
if: matrix.config.os != 'ubuntu'
run: meson install -C build

- name: Build and install Libs (Linux)
if: matrix.config.os == 'ubuntu'
run: sudo meson install -C build

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Build package
run: |
cd wrapper/javascript
npm install -D
npm run build --verbose
npm run test
npm pack
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.config.name }} Node.js Wrapper
path: wrapper/javascript/oopetris*.tgz

85 changes: 1 addition & 84 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ project(
version: '0.5.6',
)

oopetris_author = 'Coder2k'
oopetris_name = 'OOPetris'

subdir('tools/options')

subdir('tools/dependencies')
Expand All @@ -25,87 +22,7 @@ subdir('src')

subdir('tools/install')

if meson.is_cross_build() and host_machine.system() == 'android'

library(
'oopetris',
main_files,
dependencies: [liboopetris_graphics_dep, graphic_application_deps],
override_options: {
'warning_level': '3',
'werror': true,
},
)

elif meson.is_cross_build() and host_machine.system() == 'switch'
switch_options = [
app_name,
main_files,
[liboopetris_graphics_dep, graphic_application_deps],
]
subdir('platforms/switch')
elif meson.is_cross_build() and host_machine.system() == '3ds'
_3ds_options = [
app_name,
main_files,
[liboopetris_graphics_dep, graphic_application_deps],
]
subdir('platforms/3ds')
else

if host_machine.system() == 'windows'
subdir('platforms/windows')
endif

oopetris_exe = executable(
'oopetris',
main_files,
dependencies: [liboopetris_graphics_dep, graphic_application_deps],
override_options: {
'warning_level': '3',
'werror': true,
},
install: true,
win_subsystem: 'windows',
)

oopetris_recordings_utility_exe = executable(
'oopetris_recordings_utility',
recordings_main_files,
dependencies: liboopetris_recordings_dep,
override_options: {
'warning_level': '3',
'werror': true,
},
install: true,
win_subsystem: 'console',
)

if build_installer
if host_machine.system() == 'windows'

makensis = find_program('makensis')

nsis_script = meson.project_source_root() / 'tools' / 'installer' / 'setup.nsi'

run_target(
'windows_installer',
command: [
makensis,
'-DVERSION=' + meson.project_version(),
'-DNAME=' + oopetris_name,
'-DAUTHOR=' + oopetris_author,
'-DPROJECT_SOURCE_DIR=' + meson.project_source_root(),
'-DPROJECT_BUILD_DIR=' + meson.project_build_root(),
nsis_script,
],
depends: [oopetris_exe, oopetris_recordings_utility_exe],
)

endif
endif

endif
subdir('src/executables')

if get_option('tests')
subdir('tests')
Expand Down
8 changes: 8 additions & 0 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ option(
value: false,
description: 'whether or not tests should be built',
)

option(
'only_build_libs',
type: 'boolean',
value: false,
description: 'if you only want to build the libs, enable this',
)

40 changes: 38 additions & 2 deletions platforms/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ static boolean isValidVersion(String version) {
return true;
}

/**
* Internal helper function
*/
static List<String> getSupportedABIs() {
return ["armeabi-v7a", "arm64-v8a", "x86", "x86_64"];
}

/**
* Read the Android ABI from user input.
* supported ANDROID_ABIs are 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
Expand All @@ -80,7 +87,7 @@ static boolean isValidVersion(String version) {
List getAndroidABIs() {
String property = project.findProperty('ANDROID_ABI')

List<String> supportedABIs = ["armeabi-v7a", "arm64-v8a", "x86", "x86_64"];
List<String> supportedABIs = getSupportedABIs()

List<String> AbiFilters = new ArrayList<String>()
if (property == null) {
Expand Down Expand Up @@ -193,8 +200,37 @@ String getVersion() {

}

/**
* Detect if we need to build an universal apk
* this first checks, if this is manually request by the cli args, than it checks, if all supported ABIs are given, if that is the case, enable it too
* @return Boolean
*/
Boolean shouldBuildUniversalApk(List<String> abisToUse) {
String property = project.findProperty('BUILD_UNIVERSAL_APK')


if (property != null) {
return true
}

List<String> supportedABIs = getSupportedABIs()

// return true, if all abis, we support are specified
for (abi in supportedABIs) {
if (!abisToUse.contains(abi)) {
return false;
}
}

return true;


}


List<String> abisToUse = getAndroidABIs()
String versionString = getVersion()
Boolean buildUniversalApk = shouldBuildUniversalApk(abisToUse)

System.out.printf("DEBUG: Using abis: %s%n", abisToUse.join(", "))
System.out.printf("DEBUG: Using version: %s%n", versionString)
Expand Down Expand Up @@ -271,7 +307,7 @@ android {
// Specifies a list of ABIs for Gradle to create APKs for.
include(*abisToUse)
// Specifies that you don't want to also generate a universal APK that includes all ABIs.
universalApk false
universalApk(buildUniversalApk)
}
}

Expand Down
7 changes: 4 additions & 3 deletions platforms/android/app/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := liboopetris_core
LIB_PATH := $(BUILD_PATH)/src
LIB_PATH := $(BUILD_PATH)/src/libs/core
LOCAL_SRC_FILES := $(LIB_PATH)/liboopetris_core.so
include $(PREBUILT_SHARED_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE := liboopetris_recordings
LIB_PATH := $(BUILD_PATH)/src
LIB_PATH := $(BUILD_PATH)/src/libs/recordings
LOCAL_SRC_FILES := $(LIB_PATH)/liboopetris_recordings.so
include $(PREBUILT_SHARED_LIBRARY)

Expand All @@ -105,7 +105,8 @@ include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := liboopetris
LOCAL_SRC_FILES := $(BUILD_PATH)/liboopetris.so
LIB_PATH := $(BUILD_PATH)/src/executables
LOCAL_SRC_FILES := $(LIB_PATH)/liboopetris.so
include $(PREBUILT_SHARED_LIBRARY)


Expand Down
2 changes: 1 addition & 1 deletion platforms/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.4.0'
classpath 'com.android.tools.build:gradle:8.4.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Loading

0 comments on commit b2271fa

Please sign in to comment.