mirror of
https://github.com/wiiu-env/librpxloader.git
synced 2024-11-24 19:26:53 +01:00
first commit
This commit is contained in:
commit
5f08be3d1f
25
.github/workflows/push_image.yml
vendored
Normal file
25
.github/workflows/push_image.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
name: Publish Docker Image
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@master
|
||||||
|
- name: Get release version
|
||||||
|
id: get_release_tag
|
||||||
|
run: |
|
||||||
|
echo RELEASE_VERSION=$(echo $(date '+%Y%m%d')) >> $GITHUB_ENV
|
||||||
|
echo REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//" | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
|
||||||
|
echo REPOSITORY_OWNER=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $1}' | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
|
||||||
|
- name: Publish to Registry
|
||||||
|
uses: elgohr/Publish-Docker-Github-Action@master
|
||||||
|
with:
|
||||||
|
name: ${{ env.REPOSITORY_OWNER }}/${{ env.REPOSITORY_NAME }}
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
snapshot: true
|
||||||
|
cache: true
|
||||||
|
tags: "latest, ${{ env.RELEASE_VERSION }}"
|
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/*.a
|
||||||
|
/build
|
||||||
|
*.bz2
|
||||||
|
release/
|
||||||
|
lib/
|
||||||
|
CMakeLists.txt
|
||||||
|
.idea/
|
||||||
|
cmake-build-debug/
|
||||||
|
share/
|
9
Dockerfile
Normal file
9
Dockerfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
FROM wiiuenv/devkitppc:20210101
|
||||||
|
|
||||||
|
WORKDIR tmp_build
|
||||||
|
COPY . .
|
||||||
|
RUN make clean && make && mkdir -p /artifacts/wums && cp -r lib /artifacts/wums && cp -r include /artifacts/wums && cp -r share /artifacts/wums
|
||||||
|
WORKDIR /artifacts
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
COPY --from=0 /artifacts /artifacts
|
169
Makefile
Normal file
169
Makefile
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
.SUFFIXES:
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ifeq ($(strip $(DEVKITPRO)),)
|
||||||
|
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
|
||||||
|
endif
|
||||||
|
|
||||||
|
TOPDIR ?= $(CURDIR)
|
||||||
|
|
||||||
|
include $(DEVKITPRO)/wut/share/wut_rules
|
||||||
|
|
||||||
|
export VER_MAJOR := 1
|
||||||
|
export VER_MINOR := 0
|
||||||
|
export VER_PATCH := 0
|
||||||
|
|
||||||
|
VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# TARGET is the name of the output
|
||||||
|
# BUILD is the directory where object files & intermediate files will be placed
|
||||||
|
# SOURCES is a list of directories containing source code
|
||||||
|
# DATA is a list of directories containing data files
|
||||||
|
# INCLUDES is a list of directories containing header files
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
TARGET := $(notdir $(CURDIR))
|
||||||
|
BUILD := build
|
||||||
|
SOURCES := source
|
||||||
|
DATA := data
|
||||||
|
INCLUDES := source \
|
||||||
|
include \
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# options for code generation
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
CFLAGS := -Wall -Werror -save-temps \
|
||||||
|
-ffunction-sections -fdata-sections \
|
||||||
|
$(MACHDEP) \
|
||||||
|
$(BUILD_CFLAGS)
|
||||||
|
|
||||||
|
CFLAGS += $(INCLUDE) -D__WIIU__
|
||||||
|
|
||||||
|
CXXFLAGS := $(CFLAGS) -std=gnu++17
|
||||||
|
|
||||||
|
ASFLAGS := $(MACHDEP)
|
||||||
|
|
||||||
|
LDFLAGS = $(ARCH) -Wl,--gc-sections
|
||||||
|
|
||||||
|
|
||||||
|
LIBS :=
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# list of directories containing libraries, this must be the top level containing
|
||||||
|
# include and lib
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
LIBDIRS := $(PORTLIBS) $(WUT_ROOT)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# no real need to edit anything past this point unless you need to add additional
|
||||||
|
# rules for different file extensions
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export TOPDIR := $(CURDIR)
|
||||||
|
|
||||||
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||||
|
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||||
|
|
||||||
|
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||||
|
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||||
|
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||||
|
DEFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.def)))
|
||||||
|
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# use CXX for linking C++ projects, CC for standard C
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
ifeq ($(strip $(CPPFILES)),)
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
export LD := $(CC)
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
else
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
export LD := $(CXX)
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
endif
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
||||||
|
export OFILES_SRC := $(DEFFILES:.def=.o) $(SFILES:.s=.o) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
|
||||||
|
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
|
||||||
|
export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
||||||
|
|
||||||
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||||
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||||
|
-I.
|
||||||
|
|
||||||
|
.PHONY: all dist-bin dist-src dist install clean
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
all: lib/librpxloader.a share/librpxloader.ld
|
||||||
|
|
||||||
|
dist-bin: all
|
||||||
|
@tar --exclude=*~ -cjf librpxloader-$(VERSION).tar.bz2 include lib share
|
||||||
|
|
||||||
|
dist-src:
|
||||||
|
@tar --exclude=*~ -cjf librpxloader-src-$(VERSION).tar.bz2 include source Makefile
|
||||||
|
|
||||||
|
dist: dist-src dist-bin
|
||||||
|
|
||||||
|
install: dist-bin
|
||||||
|
mkdir -p $(DESTDIR)$(DEVKITPRO)/wums
|
||||||
|
bzip2 -cd librpxloader-$(VERSION).tar.bz2 | tar -xf - -C $(DESTDIR)$(DEVKITPRO)/wums
|
||||||
|
|
||||||
|
lib:
|
||||||
|
@[ -d $@ ] || mkdir -p $@
|
||||||
|
|
||||||
|
share:
|
||||||
|
@[ -d $@ ] || mkdir -p $@
|
||||||
|
|
||||||
|
release:
|
||||||
|
@[ -d $@ ] || mkdir -p $@
|
||||||
|
|
||||||
|
share/librpxloader.ld :$(SOURCES) $(INCLUDES) | share release
|
||||||
|
mv $(CURDIR)/release/*.ld $(CURDIR)/$@
|
||||||
|
|
||||||
|
lib/librpxloader.a :$(SOURCES) $(INCLUDES) | lib release
|
||||||
|
@$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
|
||||||
|
BUILD_CFLAGS="-DNDEBUG=1 -O2 -s" \
|
||||||
|
DEPSDIR=$(CURDIR)/release \
|
||||||
|
--no-print-directory -C release \
|
||||||
|
-f $(CURDIR)/Makefile
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
clean:
|
||||||
|
@echo clean ...
|
||||||
|
@rm -rf release lib
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
else
|
||||||
|
|
||||||
|
DEPENDS := $(OFILES:.o=.d)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# main targets
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
$(OUTPUT) : $(OFILES)
|
||||||
|
|
||||||
|
$(OFILES_SRC) : $(HFILES)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
%.o: %.def
|
||||||
|
$(SILENTMSG) $(notdir $<)
|
||||||
|
$(SILENTCMD)rplimportgen $< $*.s $*.ld $(ERROR_FILTER)
|
||||||
|
$(SILENTCMD)$(CC) -x assembler-with-cpp $(ASFLAGS) -c $*.s -o $@ $(ERROR_FILTER)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
%_bin.h %.bin.o : %.bin
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
@echo $(notdir $<)
|
||||||
|
@$(bin2o)
|
||||||
|
|
||||||
|
|
||||||
|
-include $(DEPENDS)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------------
|
||||||
|
endif
|
||||||
|
#---------------------------------------------------------------------------------------
|
11
README.md
Normal file
11
README.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
Requires the [RPXLoadingModule](https://github.com/wiiu-env/RPXLoadingModule) to be running via [SetupPayload](https://github.com/wiiu-env/SetupPayload).
|
||||||
|
Requires [wut](https://github.com/decaf-emu/wut) for building.
|
||||||
|
Install via `make install`.
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
When linking, make sure to add the librpxloader.ld file to the LDFLAGS.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```
|
||||||
|
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUMS_ROOT)/share/librpxloader.ld
|
||||||
|
```
|
96
include/rpxloader.h
Normal file
96
include/rpxloader.h
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
BundleSource_FileDescriptor,
|
||||||
|
BundleSource_FileDescriptor_CafeOS,
|
||||||
|
} BundleSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setups the given .rpx or .wuhb to be loaded on the next application restart.
|
||||||
|
* Make sure to (re-)launch the H&S app after calling this function.
|
||||||
|
*
|
||||||
|
* Calling this for a .rpx while the .wuhb is running while keep the bundle mounted,
|
||||||
|
* just the .rpx will be replaced.
|
||||||
|
*
|
||||||
|
* @param bundle_path relative path the root of the sd card (e.g. "/apps/test.wuhb")
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool RL_LoadFromSDOnNextLaunch(const char *bundle_path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mounts a given bundle to a given mount path. Use RL_UnmountBundle to unmount it
|
||||||
|
*
|
||||||
|
* Caution: the mounted path is only available via the
|
||||||
|
* RL_FileXXX functions
|
||||||
|
*
|
||||||
|
* @param name path the bundle should be mounted to (e.g. "rom")
|
||||||
|
* @param bundle_path path to the bundle file (e.g. "/vol/external01/apps/test.wuhb")
|
||||||
|
* @param source type of source
|
||||||
|
* @return 0 on success, < 0 on error
|
||||||
|
*/
|
||||||
|
int32_t RL_MountBundle(const char *name, const char *bundle_path, BundleSource source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unmounts a given mount path.
|
||||||
|
*
|
||||||
|
* @param name given mount path that should be unmounted
|
||||||
|
* @return 0 on success, < 0 on error
|
||||||
|
*/
|
||||||
|
int32_t RL_UnmountBundle(const char *name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a file inside a mounted bundle.
|
||||||
|
* (only read only is supported and is default)
|
||||||
|
*
|
||||||
|
* Make sure the bundle is mounted via RL_MountBundle.
|
||||||
|
*
|
||||||
|
* If a given files does not exists, it's checks for a compressed version
|
||||||
|
* (at name + ".gz). If a compressed file was found, all file reads will be
|
||||||
|
* decompressed on the fly.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @param handle handle to be used in other RL_FileXXX functions
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int32_t RL_FileOpen(const char *name, uint32_t *handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads from a given file.
|
||||||
|
*
|
||||||
|
* @param handle File to be read from.
|
||||||
|
* @param buffer buffer where data will be written to.
|
||||||
|
* Align to 0x40 for best performance
|
||||||
|
* @param size maximum bytes this function should read into buffer
|
||||||
|
* @return number of actually read bytes
|
||||||
|
* <0 on error
|
||||||
|
*/
|
||||||
|
int32_t RL_FileRead(uint32_t handle, uint8_t *buffer, uint32_t size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes a given file
|
||||||
|
*
|
||||||
|
* example: if(RL_FileClose("bundle:/meta/meta.ini") < 0) { //error while closing the file }
|
||||||
|
*
|
||||||
|
* @param handle File to be closed
|
||||||
|
* @return 0 on success, <0 on error
|
||||||
|
*/
|
||||||
|
int32_t RL_FileClose(uint32_t handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a given file exists
|
||||||
|
*
|
||||||
|
* example: RL_FileExists("bundle:/meta/meta.ini");
|
||||||
|
*
|
||||||
|
* @param name Paths to be checked
|
||||||
|
* @return true if the files exists, false if the files does not exists
|
||||||
|
*/
|
||||||
|
bool RL_FileExists(const char *name);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
10
source/rpx_loader.def
Normal file
10
source/rpx_loader.def
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
:NAME homebrew_rpx_loader
|
||||||
|
|
||||||
|
:TEXT
|
||||||
|
RL_LoadFromSDOnNextLaunch
|
||||||
|
RL_MountBundle
|
||||||
|
RL_UnmountBundle
|
||||||
|
RL_FileOpen
|
||||||
|
RL_FileRead
|
||||||
|
RL_FileClose
|
||||||
|
RL_FileExists
|
Loading…
Reference in New Issue
Block a user