diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..197b689 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,61 @@ +name: CD + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +defaults: + run: + shell: bash + +# required for upload +permissions: + contents: write + +jobs: + + Linux: + runs-on: ${{ matrix.runner }} + strategy: + matrix: + runner: [ ubuntu-24.04, ubuntu-24.04-arm ] + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: sudo apt update -y && sudo apt install -y build-essential libreadline-dev libsdl2-dev + + - name: Build zip + run: make standalone libretro zip + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: | + *.zip + + MacOS: + runs-on: ${{ matrix.runner }} + strategy: + matrix: + runner: [ macos-latest, macos-13 ] + steps: + - uses: actions/checkout@v4 + + - name: Install + run: brew install sdl2 + + - name: Build zip + run: make standalone libretro zip + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: | + *.zip \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..28f9adc --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: CI + +on: + push: + branches: [ main, master ] + pull_request: + workflow_dispatch: + +jobs: + Linux: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install dependencies + run: sudo apt update -y && sudo apt install -y build-essential libreadline-dev libsdl2-dev + + - name: Continuous Integration + run: make standalone libretro + + MacOS: + runs-on: macos-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install dependencies + run: brew install sdl2 + + - name: Continuous Integration + run: make standalone libretro \ No newline at end of file diff --git a/.gitignore b/.gitignore index 88ebca5..b511c30 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ *.so *.d *.gb +*.zip main .vscode diff --git a/Makefile b/Makefile index d34348c..89df448 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,23 @@ OBJS_STANDALONE = main.o sdl.o debugger.o OBJS_LIBRETRO = libretro.o debugger-dummy.o OBJS_STANDALONE := $(patsubst %.o,obj_standalone/%.o,$(OBJS) $(OBJS_STANDALONE)) -OBJS_LIBRETRO := $(patsubst %.o,obj_libretro/%.o,$(OBJS) $(OBJS_LIBRETRO)) +OBJS_LIBRETRO := $(patsubst %.o,obj_libretro/%.o,$(OBJS) $(OBJS_LIBRETRO)) RM = rm -fv +ARCH := $(shell uname -m) +UNAME_S := $(shell uname -s) + +ifeq ($(UNAME_S),Linux) + PLATFORM := linux +else ifeq ($(UNAME_S),Darwin) + PLATFORM := darwin +else ifeq ($(OS),Windows_NT) + PLATFORM := windows +else + PLATFORM := unknown +endif + SDL2_CFLAGS := $(shell pkg-config --cflags sdl2) SDL2_LDFLAGS := $(shell pkg-config --libs sdl2) @@ -48,5 +61,9 @@ clean: $(RM) $(PROGNAME) $(LIBRETRONAME) $(RM) -r obj_standalone obj_libretro +zip: + zip -9 -r gbc-${PLATFORM}-${ARCH}.zip ${PROGNAME} + zip -9 -r koengb_libretro-${PLATFORM}-${ARCH}.zip ${LIBRETRONAME} + -include obj_standalone/*.d -include obj_libretro/*.d diff --git a/README.md b/README.md index d7400fd..78ecbff 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![CI](https://github.com/koenk/gbc/actions/workflows/ci.yml/badge.svg)](https://github.com/koenk/gbc/actions/workflows/ci.yml) +[![CD](https://github.com/koenk/gbc/actions/workflows/cd.yml/badge.svg)](https://github.com/koenk/gbc/actions/workflows/cd.yml) + # GBC A simple GameBoy and GameBoy Color emulator written in C. @@ -32,9 +35,10 @@ core there are no dependencies for building, but using it requires a compatible frontend such as Retroarch. Building and running the standalone frontend can be done as such: - - $ make - $ ./main path/to/romfile +```shell +make +./main path/to/romfile +``` Running `./main -h` shows all available options. Button mappings are as follows: @@ -74,10 +78,10 @@ Linux, which can run Retroarch via hakchi2, we can run our libretro core on there as well simply by cross-compiling the code. This requires an ARM cross-compiler, which can be found on Ubuntu in the `gcc-arm-linux-gnueabihf` package. Then compiling can be done as such: - - $ make clean # To clean up any .o files created for the native architecture - $ make libretro CC=arm-linux-gnueabihf-gcc - +```shell +make clean # To clean up any .o files created for the native architecture +make libretro CC=arm-linux-gnueabihf-gcc +``` Copy `koengb_libretro.so` to the SNES mini with hakchi2's FTP in `/var/lib/hakchi/rootfs/etc/libretro/core`. Create a folder in the games directory (`/var/lib/hakchi/rootfs/usr/share/games/001`), and modify the