Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ jobs:
ls .
echo "OO_PS4_TOOLCHAIN=$PWD/OpenOrbis/PS4Toolchain" >> $GITHUB_ENV

- name: Build mxml
working-directory: plugin_game_patch/extern/mxml/ps4
run: |
wget https://raw.githubusercontent.com/bucanero/oosdk_libraries/master/build_rules.mk -O $OO_PS4_TOOLCHAIN/build_rules.mk
make install PRX_BUILD=1

- name: Build all modules
run: bash build.sh

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "extern/libjbc"]
path = extern/libjbc
url = https://github.com/illusion0001/ps4-libjbc.git
[submodule "plugin_game_patch/extern/mxml"]
path = plugin_game_patch/extern/mxml
url = https://github.com/illusion0001/mxml.git
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ bash int3.sh 4096 > common/cave.inc.c
for dr in plugin_*/ ; do
if [ -d "$dr" ]; then
echo "::group::Build $dr"
make -C "$dr" clean all
make -C "$dr" clean all || exit 1
echo "::endgroup::"
fi
done
103 changes: 103 additions & 0 deletions plugin_game_patch/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Library metadata.

DEBUG_FLAGS = -D__FINAL__=1
LOG_TYPE = -D__USE_PRINTF__

ifeq ($(DEBUG),1)
DEBUG_FLAGS = -D__FINAL__=0
endif

TYPE := $(BUILD_TYPE)
FINAL := $(DEBUG_FLAGS)
BUILD_FOLDER := $(shell pwd)/../bin/plugins
OUTPUT_PRX := $(shell basename $(CURDIR))
TARGET := $(BUILD_FOLDER)/prx$(TYPE)/$(OUTPUT_PRX)
TARGET_ELF := $(BUILD_FOLDER)/elf$(TYPE)/$(OUTPUT_PRX)
TARGETSTUB := $(OUTPUT_PRX).so
COMMON_DIR := ../common

# Libraries linked into the ELF.
LIBS := -lSceLibcInternal -lkernel -lc -lmxml

EXTRAFLAGS := -fvisibility=hidden -D__PS4__ $(DEBUG_FLAGS) $(LOG_TYPE) -fcolor-diagnostics -Wall

# You likely won't need to touch anything below this point.
# Root vars
TOOLCHAIN := $(OO_PS4_TOOLCHAIN)
PROJDIR := ../$(shell basename $(CURDIR))/source
INTDIR := ../$(shell basename $(CURDIR))/build
INCLUDEDIR := ../$(shell basename $(CURDIR))/include

# Define objects to build
CFILES := $(wildcard $(PROJDIR)/*.c)
CPPFILES := $(wildcard $(PROJDIR)/*.cpp)
COMMONFILES := $(wildcard $(COMMONDIR)/*.cpp)
OBJS := $(patsubst $(PROJDIR)/%.c, $(INTDIR)/%.o, $(CFILES)) $(patsubst $(PROJDIR)/%.cpp, $(INTDIR)/%.o, $(CPPFILES)) $(patsubst $(COMMONDIR)/%.cpp, $(INTDIR)/%.o, $(COMMONFILES))
STUBOBJS := $(patsubst $(PROJDIR)/%.c, $(INTDIR)/%.o, $(CFILES)) $(patsubst $(PROJDIR)/%.cpp, $(INTDIR)/%.o.stub, $(CPPFILES)) $(patsubst $(COMMONDIR)/%.cpp, $(INTDIR)/%.o.stub, $(COMMONFILES))

# Define final C/C++ flags
CFLAGS := --target=x86_64-pc-freebsd12-elf -fPIC -funwind-tables -c $(EXTRAFLAGS) -isysroot $(TOOLCHAIN) -isystem $(TOOLCHAIN)/include
CXXFLAGS := $(CFLAGS) -isystem $(TOOLCHAIN)/include/c++/v1
LDFLAGS := -m elf_x86_64 -pie --script $(TOOLCHAIN)/link.x -e _init --eh-frame-hdr -L$(TOOLCHAIN)/lib $(LIBS) $(TOOLCHAIN)/lib/crtlib.o

# Check for linux vs macOS and account for clang/ld path
UNAME_S := $(shell uname -s)

ifeq ($(UNAME_S),Linux)
CC := clang
CCX := clang++
LD := ld.lld
CDIR := linux
endif
ifeq ($(UNAME_S),Darwin)
CC := /usr/local/opt/llvm/bin/clang
CCX := /usr/local/opt/llvm/bin/clang++
LD := /usr/local/opt/llvm/bin/ld.lld
CDIR := macos
endif

$(INTDIR):
mkdir -p $(INTDIR)

$(BUILD_FOLDER)/prx$(TYPE):
mkdir -p $(BUILD_FOLDER)/prx$(TYPE)

$(BUILD_FOLDER)/elf$(TYPE):
mkdir -p $(BUILD_FOLDER)/elf$(TYPE)

$(TARGET): $(INTDIR) $(BUILD_FOLDER)/prx$(TYPE) $(BUILD_FOLDER)/elf$(TYPE) $(OBJS)
$(LD) $(INTDIR)/*.o -o $(TARGET_ELF).elf $(LDFLAGS)
$(TOOLCHAIN)/bin/$(CDIR)/create-fself -in=$(TARGET_ELF).elf -out=$(TARGET_ELF).oelf --lib=$(TARGET).prx --paid 0x3800000000000011

$(TARGETSTUB): $(INTDIR) $(STUBOBJS)
$(CC) $(INTDIR)/*.o.stub -o $(TARGETSTUB) -target x86_64-pc-linux-gnu -shared -fuse-ld=lld -ffreestanding -nostdlib -fno-builtin -L$(TOOLCHAIN)/lib $(LIBS)

$(INTDIR)/%.o: $(PROJDIR)/%.c
$(CC) $(CFLAGS) -o $@ $<

$(INTDIR)/%.o: $(PROJDIR)/%.cpp
$(CCX) $(CXXFLAGS) -o $@ $<

$(INTDIR)/%.o.stub: $(PROJDIR)/%.c
$(CC) -target x86_64-pc-linux-gnu -ffreestanding -nostdlib -fno-builtin -fPIC $(O_FLAG) -s -c -o $@ $<

$(INTDIR)/%.o.stub: $(PROJDIR)/%.cpp
$(CCX) -target x86_64-pc-linux-gnu -ffreestanding -nostdlib -fno-builtin -fPIC $(O_FLAG) -s -c -o $@ $<

send: $(TARGET)
curl -T $(TARGET).prx ftp://$(PS4_HOST):2121/data/hen/plugins/$(OUTPUT_PRX).prx

build-info:
$(shell echo "#define GIT_COMMIT \"$(shell git rev-parse HEAD)\"" > $(COMMON_DIR)/git_ver.h)
$(shell echo "#define GIT_VER \"$(shell git branch --show-current)\"" >> $(COMMON_DIR)/git_ver.h)
$(shell echo "#define GIT_NUM $(shell git rev-list HEAD --count)" >> $(COMMON_DIR)/git_ver.h)
$(shell echo "#define GIT_NUM_STR \"$(shell git rev-list HEAD --count)\"" >> $(COMMON_DIR)/git_ver.h)
$(shell echo "#define BUILD_DATE \"$(shell date '+%b %d %Y @ %T')\"" >> $(COMMON_DIR)/git_ver.h)

.PHONY: clean
.DEFAULT_GOAL := all

all: build-info $(TARGET)

clean:
rm -rf $(TARGET) $(TARGETSTUB) $(INTDIR) $(OBJS)
1 change: 1 addition & 0 deletions plugin_game_patch/extern/mxml
Submodule mxml added at b29e02
Loading