Skip to content

Commit

Permalink
Update libretro build
Browse files Browse the repository at this point in the history
  • Loading branch information
LIJI32 committed Mar 9, 2024
2 parents 17f0ff2 + 2d29ece commit 17c962e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ $(BIN)/BootROMs/%.bin: BootROMs/%.asm $(OBJ)/BootROMs/SameBoyLogo.pb12

# Libretro Core (uses its own build system)
libretro:
CFLAGS="$(WARNINGS)" $(MAKE) -C libretro BOOTROMS_DIR=$(abspath $(BOOTROMS_DIR))
CFLAGS="$(WARNINGS)" $(MAKE) -C libretro BOOTROMS_DIR=$(BOOTROMS_DIR) BIN=$(BIN)

# install for Linux/FreeDesktop/etc.
# Does not install mimetype icons because FreeDesktop is cursed abomination with no right to exist.
Expand Down
16 changes: 13 additions & 3 deletions libretro/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ endif

DEFINES := -DIOS
ifeq ($(platform),ios-arm64)
CC = cc -arch armv64 -isysroot $(IOSSDK)
CC = cc -arch arm64 -isysroot $(IOSSDK)
else
CC = cc -arch armv7 -isysroot $(IOSSDK)
endif
Expand All @@ -211,7 +211,7 @@ endif
CC = cc -arch arm64 -isysroot $(IOSSDK)

else ifneq (,$(findstring qnx,$(platform)))
TARGET := $(TARGET_NAME)_libretro_qnx.so
TARGET := $(TARGET_NAME)_libretro_qnx.so
fpic := -fPIC
SHARED := -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined
else ifeq ($(platform), emscripten)
Expand Down Expand Up @@ -326,7 +326,15 @@ else
SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined
endif

TARGET := $(CORE_DIR)/build/bin/$(TARGET)
ifeq ($(STATIC_LINKING), 1)
# For some reason libretro's buildbot expects the output to be at ./libretro/ for static targets
BIN ?= $(realpath -m $(CORE_DIR)/libretro)
else
BIN ?= $(realpath -m $(CORE_DIR))
endif
override BIN := $(shell cd .. && realpath -m $(BIN))
TARGET := $(BIN)/$(TARGET)


# To force use of the Unix version instead of the Windows version
MKDIR := $(shell which mkdir)
Expand Down Expand Up @@ -365,6 +373,8 @@ CFLAGS += -D__LIBRETRO__ $(fpic) $(INCFLAGS) -std=gnu11 -D_GNU_SOURCE -D_USE_M

all: $(TARGET)

override BOOTROMS_DIR := $(shell cd .. && realpath -m $(BOOTROMS_DIR))

$(CORE_DIR)/libretro/%_boot.c: $(BOOTROMS_DIR)/%_boot.bin
echo "/* AUTO-GENERATED */" > $@
echo "const unsigned char $(notdir $(@:%.c=%))[] = {" >> $@
Expand Down
17 changes: 6 additions & 11 deletions libretro/gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@
# Core definitions
.core-defs:
variables:
JNI_PATH: libretro
MAKEFILE_PATH: libretro
CORENAME: sameboy
BOOTROMS_DIR: ../BootROMs/prebuilt

.core-defs-android:
extends: .core-defs
variables:
JNI_PATH: libretro
BOOTROMS_DIR: ../../BootROMs/prebuilt
BOOTROMS_DIR: BootROMs/prebuilt

# Inclusion templates, required for the build to work
include:
Expand Down Expand Up @@ -128,25 +123,25 @@ libretro-build-osx-arm64:
android-armeabi-v7a:
extends:
- .libretro-android-jni-armeabi-v7a
- .core-defs-android
- .core-defs

# Android ARMv8a
android-arm64-v8a:
extends:
- .libretro-android-jni-arm64-v8a
- .core-defs-android
- .core-defs

# Android 64-bit x86
android-x86_64:
extends:
- .libretro-android-jni-x86_64
- .core-defs-android
- .core-defs

# Android 32-bit x86
android-x86:
extends:
- .libretro-android-jni-x86
- .core-defs-android
- .core-defs

# iOS
libretro-build-ios-arm64:
Expand Down
4 changes: 3 additions & 1 deletion libretro/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ LOCAL_CFLAGS := -std=c99 $(COREFLAGS) $(CFLAGS)
LOCAL_LDFLAGS := -Wl,-version-script=$(CORE_DIR)/libretro/link.T
include $(BUILD_SHARED_LIBRARY)

$(CORE_DIR)/libretro/%_boot.c: $(CORE_DIR)/build/bin/BootROMs/%_boot.bin
override BOOTROMS_DIR := $(shell cd ../.. && realpath -m $(BOOTROMS_DIR))

$(CORE_DIR)/libretro/%_boot.c: $(BOOTROMS_DIR)/%_boot.bin
echo "/* AUTO-GENERATED */" > $@
echo "const unsigned char $(notdir $(@:%.c=%))[] = {" >> $@
hexdump -v -e '/1 "0x%02x, "' $< >> $@
Expand Down

0 comments on commit 17c962e

Please sign in to comment.