Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMake build support #19

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5e0e250
Make newstate a public header.
FtZPetruska May 27, 2023
0b6e3e9
Add common CMake build directories to gitignore.
FtZPetruska May 27, 2023
327d339
Add CMake build script.
FtZPetruska May 27, 2023
f17fbc3
Replace defines with a generated config.h.
FtZPetruska May 28, 2023
680dfad
CMake: Add support for tests.
FtZPetruska May 28, 2023
01bd891
Update build docs to use CMake.
FtZPetruska May 28, 2023
278edca
CI: Update workflow to use CMake.
FtZPetruska May 28, 2023
53b10f7
Add vcpkg config for compatibility with VS.
FtZPetruska May 28, 2023
d3a7e11
Update documentation to cover Visual Studio.
FtZPetruska May 28, 2023
4ea626a
Properly set symbols' visibility.
FtZPetruska Jun 3, 2023
ac92f8e
Add the libgambatte::libgambatte alias.
FtZPetruska Jun 3, 2023
93d5f8f
Test building with pkg-config more thoroughly.
FtZPetruska Jun 3, 2023
98e01d2
Move misplaced GBEXPORT.
FtZPetruska Jun 4, 2023
1f54590
Also include cinterface.cpp in static builds.
FtZPetruska Jun 4, 2023
93b78c0
Partially revert 4ea626ad66ba8134aef373587ce0ffe5625663a1
FtZPetruska Jun 4, 2023
78791e7
Expose the cinterface functions in gambatte-c.h
FtZPetruska Jun 4, 2023
a1f208b
Make gambatte-c usable in C.
FtZPetruska Jun 4, 2023
d1ae9ec
Use dllexport/import properly.
FtZPetruska Jun 4, 2023
fc605a8
Move FPtrs to a C-compatible header.
FtZPetruska Jun 4, 2023
472e68a
Only define dllexport/import with the shared lib.
FtZPetruska Jun 4, 2023
c75fe83
Add a simple test for the C API.
FtZPetruska Jun 4, 2023
0c8ffed
Typedef FPtrs for when it's used from C.
FtZPetruska Jun 4, 2023
79d9841
Define callback functions with C linkage.
FtZPetruska Jun 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 159 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,164 @@
name: Check GSR testROM accuracy
name: Build and run tests

on: [push, pull_request]

jobs:
Check-TestROMs:
runs-on: ubuntu-20.04
steps:
- name: Install dependencies
run: "sudo apt install scons"
build-and-test:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.runner }}
defaults:
run:
shell: ${{ matrix.config.shell }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "MSYS2 UCRT64",
runner: windows-latest,
shell: "msys2 {0}",
msystem: ucrt64,
msys-env: mingw-w64-ucrt-x86_64,
cmake_flags: "-G Ninja",
}
- {
name: "MSYS2 i686",
runner: windows-latest,
shell: "msys2 {0}",
msystem: mingw32,
msys-env: mingw-w64-i686,
cmake_flags: "-G Ninja",
}
- {
name: "Windows (Clang-cl)",
runner: windows-latest,
shell: bash,
cmake_flags: "-T ClangCL -A x64",
vcpkg_triplet: x64-windows,
}
- {
name: "Windows (Clang GNU)",
runner: windows-latest,
shell: bash,
cmake_flags: "-G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++",
vcpkg_triplet: x64-windows,
}
- {
name: "macOS",
runner: macos-latest,
shell: bash,
cmake_flags: '-G Ninja -DPNG_LIBRARY="$(brew --prefix libpng)/lib/libpng.a" -DPNG_PNG_INCLUDE_DIR="$(brew --prefix libpng)/include"',
}
- {
name: "Linux",
runner: ubuntu-latest,
shell: bash,
cmake_flags: "-G Ninja",
}

- name: Checkout repository code
uses: actions/checkout@v2
steps:
- name: Install dependencies (MSYS)
if: matrix.config.shell == 'msys2 {0}'
uses: msys2/setup-msys2@v2
with:
path: gambatte-speedrun

- name: Assemble TestROMs
run: "cd gambatte-speedrun/test && sh scripts/assemble_tests.sh"
update: true
msystem: ${{ matrix.config.msystem }}
install: >-
${{ matrix.config.msys-env }}-gcc
${{ matrix.config.msys-env }}-cmake
${{ matrix.config.msys-env }}-ninja
${{ matrix.config.msys-env }}-pkgconf
${{ matrix.config.msys-env }}-libpng
${{ matrix.config.msys-env }}-python3
${{ matrix.config.msys-env }}-zlib

- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew update
brew unlink pkg-config
brew install \
cmake \
ninja \
pkgconf \
libpng \
python3 \
zlib

- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y \
build-essential \
cmake \
ninja-build \
pkgconf \
libpng-dev \
libz-dev \
python3

- name: Install dependencies (Windows)
if: runner.os == 'Windows' && matrix.config.shell != 'msys2 {0}'
run: |
vcpkg install --triplet ${{ matrix.config.vcpkg_triplet }} libpng pkgconf zlib
echo "$VCPKG_INSTALLATION_ROOT/installed/${{ matrix.config.vcpkg_triplet }}/tools/pkgconf" >> $GITHUB_PATH
echo "CMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$VCPKG_INSTALLATION_ROOT/installed/${{ matrix.config.vcpkg_triplet }}/lib/pkgconfig" >> $GITHUB_ENV

- uses: actions/checkout@v3

- name: Configure
run: |
cmake -S.\
-Bbuild \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=install-prefix \
-DLIBGAMBATTE_BUILD_SHARED=ON \
-DLIBGAMBATTE_BUILD_STATIC=ON \
-DLIBGAMBATTE_ENABLE_ZIP=ON \
-DLIBGAMBATTE_ENABLE_TESTING=ON \
-DVCPKG_MANIFEST_MODE=OFF \
${{ matrix.config.cmake_flags }}

- name: Build
run: |
cmake --build build --config Release

- name: Run tests
run: |
ctest --extra-verbose --test-dir build -C Release

- name: Install
run: |
cmake --install build --config Release

- name: Test consuming from build directory
run: |
cmake -Scmake/test \
-Bconsumer-from-build \
-DCMAKE_BUILD_TYPE=Release \
-Dlibgambatte_DIR="$(pwd)/build" \
${{ matrix.config.cmake_flags }}
cmake --build consumer-from-build --config Release

- name: Test consuming from installation
run: |
cmake -Scmake/test \
-Bconsumer-from-install \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="$(pwd)/install-prefix" \
${{ matrix.config.cmake_flags }}
cmake --build consumer-from-install --config Release

- name: Build libgambatte and run tests
run: "cd gambatte-speedrun && sh scripts/test.sh"
- name: Test consuming from pkg-config
run: |
pkgconf --with-path="$(pwd)/install-prefix/lib/pkgconfig" --validate libgambatte
cmake -Scmake/test \
-Bconsumer-from-pkg-config \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="$(pwd)/install-prefix" \
-DUSE_PKG_CONFIG=TRUE \
${{ matrix.config.cmake_flags }}
cmake --build consumer-from-pkg-config --config Release
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ gambatte_qt/src/release/
gambatte_qt/src/debug/
gambatte_qt/bin/
test/testrunner
libgambatte/include/config.h

*.cpp~
*.h~
Expand All @@ -39,3 +40,6 @@ gambatte_qt/src/platforms.pri
*.dylib

.DS_Store

build/
out/
Loading