diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..9e37a10 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,68 @@ +name: Build (ubuntu, macos) + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. + fail-fast: false + + matrix: + os: [ubuntu-latest, macos-latest] + # build_type: [Release] + c_compiler: [gcc, clang] + include: + - os: macos-latest + c_compiler: clang + cpp_compiler: clang++ + - os: ubuntu-latest + c_compiler: gcc + cpp_compiler: g++ + - os: ubuntu-latest + c_compiler: clang + cpp_compiler: clang++ + exclude: + - os: macos-latest + c_compiler: gcc + + steps: + - uses: actions/checkout@v7 + + - name: Set reusable strings + # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: Install dependencies + run: | + ([[ $OSTYPE == 'darwin'* ]] && brew update && brew install sdl2 boost) || + ([[ $OSTYPE == 'linux'* ]] && sudo apt-get update && sudo apt-get install -y libsdl2-dev libboost-all-dev) + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + # -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -S ${{ github.workspace }} + + - name: Build + # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} + + # - name: Test + # working-directory: ${{ steps.strings.outputs.build-output-dir }} + # # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + # # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + # run: ctest --build-config ${{ matrix.build_type }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3d7875c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -os: - - linux - - osx - -language: c - -compiler: - - gcc - -addons: - homebrew: - packages: - - sdl2 - - boost - update: true - apt: - packages: - - libsdl2-dev - - libboost-all-dev - - -script: - - cmake . - - cmake --build . diff --git a/README.md b/README.md index 31ffa04..cc18269 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # gbc_cpp GameBoy (eventually Color) Emulator in C(++) -[![Build Status](https://travis-ci.com/finagle29/gbc_cpp.svg?branch=master)](https://travis-ci.com/finagle29/gbc_cpp) +[![Build (ubuntu, macos)](https://github.com/finagle29/gbc_cpp/actions/workflows/build.yml/badge.svg)](https://github.com/finagle29/gbc_cpp/actions/workflows/build.yml) Use cmake to build. diff --git a/gpu.c b/gpu.c index dc1578d..08de24d 100644 --- a/gpu.c +++ b/gpu.c @@ -5,6 +5,10 @@ gpu_type gpu; +SDL_Window *window, *vram_w, *bg_w; +SDL_Renderer *renderer, *vram_r, *bg_r; +SDL_Texture *framebuffer, *framebuffer_tileset, *framebuffer_bgmap; + #define RGBA(r, g, b) (((((r << 8) | g) << 8) | b) << 8) | 0xFF bool show_tileset, show_bgmap; diff --git a/gpu.h b/gpu.h index e45183f..ab25f56 100644 --- a/gpu.h +++ b/gpu.h @@ -40,10 +40,8 @@ typedef struct } gpu_type; extern gpu_type gpu; - -SDL_Window *window, *vram_w, *bg_w; -SDL_Renderer *renderer, *vram_r, *bg_r; -SDL_Texture *framebuffer, *framebuffer_tileset, *framebuffer_bgmap; +extern SDL_Window *window, *vram_w, *bg_w; +extern bool show_tileset, show_bgmap; void setup(bool, bool); void cleanup(void); diff --git a/main.c b/main.c index 1321649..234adb1 100644 --- a/main.c +++ b/main.c @@ -12,8 +12,8 @@ #include "keys.h" #include "mmu.h" -extern bool show_tileset, show_bgmap; -extern SDL_Window *window, *vram_w, *bg_w; +// extern bool show_tileset, show_bgmap; +// extern SDL_Window *window, *vram_w, *bg_w; bool frame(void);