mirror of
https://github.com/wiiu-env/WiiUModuleSystem.git
synced 2024-11-25 11:16:52 +01:00
Add a very basic example module and build it in the CI
This commit is contained in:
parent
fdf9993069
commit
4abbcbf848
23
.github/workflows/pr.yml
vendored
23
.github/workflows/pr.yml
vendored
@ -22,4 +22,25 @@ jobs:
|
|||||||
- uses: actions/upload-artifact@master
|
- uses: actions/upload-artifact@master
|
||||||
with:
|
with:
|
||||||
name: binary
|
name: binary
|
||||||
path: "/lib/*.a"
|
path: "/lib/*.a"
|
||||||
|
clang-format-examples:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: clang-format
|
||||||
|
run: |
|
||||||
|
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./example/example_module/source
|
||||||
|
build-examples:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
needs: clang-format-examples
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: build binary
|
||||||
|
run: |
|
||||||
|
docker build . -f Dockerfile.buildexamples -t builder
|
||||||
|
cd ./example/example_module
|
||||||
|
docker run --rm -v ${PWD}:/project builder make
|
||||||
|
- uses: actions/upload-artifact@master
|
||||||
|
with:
|
||||||
|
name: binary
|
||||||
|
path: "*.wms"
|
19
.github/workflows/push_image.yml
vendored
19
.github/workflows/push_image.yml
vendored
@ -20,9 +20,26 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
docker build . -f Dockerfile.buildlocal -t builder
|
docker build . -f Dockerfile.buildlocal -t builder
|
||||||
docker run --rm -v ${PWD}:/project builder make
|
docker run --rm -v ${PWD}:/project builder make
|
||||||
|
clang-format-examples:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: clang-format
|
||||||
|
run: |
|
||||||
|
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./example/example_module/source
|
||||||
|
build-examples:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
needs: clang-format-examples
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: build binary
|
||||||
|
run: |
|
||||||
|
docker build . -f Dockerfile.buildexamples -t builder
|
||||||
|
cd ./example/example_module
|
||||||
|
docker run --rm -v ${PWD}:/project builder make
|
||||||
push_image:
|
push_image:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build-lib
|
needs: [build-lib, build-examples]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
- name: Get release version
|
- name: Get release version
|
||||||
|
15
Dockerfile.buildexamples
Normal file
15
Dockerfile.buildexamples
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
FROM wiiuenv/devkitppc:20211229
|
||||||
|
|
||||||
|
WORKDIR 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 as libwums
|
||||||
|
COPY --from=0 /artifacts /artifacts
|
||||||
|
|
||||||
|
FROM wiiuenv/devkitppc:20211229
|
||||||
|
|
||||||
|
COPY --from=libwums /artifacts $DEVKITPRO
|
||||||
|
|
||||||
|
WORKDIR project
|
@ -76,5 +76,5 @@ It's highly recommended to pin the version to the **latest date** instead of usi
|
|||||||
|
|
||||||
## Format the code via docker
|
## Format the code via docker
|
||||||
```bash
|
```bash
|
||||||
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./include ./libraries -i
|
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./include ./libraries ./example/example_module/source -i
|
||||||
```
|
```
|
||||||
|
10
example/example_module/.gitignore
vendored
Normal file
10
example/example_module/.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
*.cbp
|
||||||
|
*.elf
|
||||||
|
*.layout
|
||||||
|
*.rpx
|
||||||
|
build/
|
||||||
|
*.save-failed
|
||||||
|
.idea/
|
||||||
|
cmake-build-debug/
|
||||||
|
CMakeLists.txt
|
||||||
|
*.wms
|
146
example/example_module/Makefile
Normal file
146
example/example_module/Makefile
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
.SUFFIXES:
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ifeq ($(strip $(DEVKITPRO)),)
|
||||||
|
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
|
||||||
|
endif
|
||||||
|
|
||||||
|
TOPDIR ?= $(CURDIR)
|
||||||
|
|
||||||
|
include $(DEVKITPRO)/wums/share/wums_rules
|
||||||
|
|
||||||
|
WUMS_ROOT := $(DEVKITPRO)/wums
|
||||||
|
WUT_ROOT := $(DEVKITPRO)/wut
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# 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 := ExampleModule
|
||||||
|
BUILD := build
|
||||||
|
SOURCES := source
|
||||||
|
DATA := data
|
||||||
|
INCLUDES := source
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# options for code generation
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
CFLAGS := -Wall -Wextra -O2 -ffunction-sections\
|
||||||
|
$(MACHDEP)
|
||||||
|
|
||||||
|
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
|
||||||
|
|
||||||
|
CXXFLAGS := $(CFLAGS) -std=c++17
|
||||||
|
|
||||||
|
ASFLAGS := -g $(ARCH)
|
||||||
|
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) $(WUMSSPECS)
|
||||||
|
|
||||||
|
ifeq ($(DEBUG),1)
|
||||||
|
CXXFLAGS += -DDEBUG -g
|
||||||
|
CFLAGS += -DDEBUG -g
|
||||||
|
endif
|
||||||
|
|
||||||
|
LIBS := -lwums -lwut
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# list of directories containing libraries, this must be the top level
|
||||||
|
# containing include and lib
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
LIBDIRS := $(PORTLIBS) $(WUT_ROOT) $(WUMS_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 OUTPUT := $(CURDIR)/$(TARGET)
|
||||||
|
export TOPDIR := $(CURDIR)
|
||||||
|
|
||||||
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||||
|
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||||
|
|
||||||
|
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||||
|
|
||||||
|
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||||
|
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||||
|
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||||
|
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 := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||||
|
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
|
||||||
|
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
||||||
|
|
||||||
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||||
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||||
|
-I$(CURDIR)/$(BUILD)
|
||||||
|
|
||||||
|
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||||
|
|
||||||
|
.PHONY: $(BUILD) clean all
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
all: $(BUILD)
|
||||||
|
|
||||||
|
$(BUILD):
|
||||||
|
@[ -d $@ ] || mkdir -p $@
|
||||||
|
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
clean:
|
||||||
|
@echo clean ...
|
||||||
|
@rm -fr $(BUILD) $(TARGET).wms $(TARGET).elf
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
else
|
||||||
|
.PHONY: all
|
||||||
|
|
||||||
|
DEPENDS := $(OFILES:.o=.d)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# main targets
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
all : $(OUTPUT).wms
|
||||||
|
|
||||||
|
$(OUTPUT).wms : $(OUTPUT).elf
|
||||||
|
$(OUTPUT).elf : $(OFILES)
|
||||||
|
|
||||||
|
$(OFILES_SRC) : $(HFILES_BIN)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# you need a rule like this for each extension you use as binary data
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
%.bin.o %_bin.h : %.bin
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
@echo $(notdir $<)
|
||||||
|
@$(bin2o)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
%.o: %.s
|
||||||
|
@echo $(notdir $<)
|
||||||
|
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER)
|
||||||
|
|
||||||
|
-include $(DEPENDS)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
endif
|
||||||
|
#-------------------------------------------------------------------------------
|
39
example/example_module/source/main.cpp
Normal file
39
example/example_module/source/main.cpp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#include <coreinit/debug.h>
|
||||||
|
#include <wums.h>
|
||||||
|
|
||||||
|
WUMS_MODULE_EXPORT_NAME("homebrew_examplemodule");
|
||||||
|
WUMS_MODULE_AUTHOR("Maschell");
|
||||||
|
WUMS_MODULE_VERSION("0.1");
|
||||||
|
WUMS_MODULE_LICENSE("GPL");
|
||||||
|
WUMS_MODULE_DESCRIPTION("Just an example module");
|
||||||
|
|
||||||
|
WUMS_INITIALIZE(/*wums_app_init_args_t*/ args) {
|
||||||
|
/* Called once when the module has been loaded */
|
||||||
|
|
||||||
|
// Information about the module can be get via the (optional) argument
|
||||||
|
module_information_t *module_information = args.module_information;
|
||||||
|
|
||||||
|
if (module_information == nullptr) {
|
||||||
|
OSFatal("Failed to get module_information pointer.");
|
||||||
|
}
|
||||||
|
// Make sure the module is using a compatible version with the loader
|
||||||
|
if (module_information->version != MODULE_INFORMATION_VERSION) {
|
||||||
|
OSFatal("The module information struct version does not match.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WUMS_APPLICATION_STARTS() {
|
||||||
|
/* Called whenever a new application has been started */
|
||||||
|
}
|
||||||
|
|
||||||
|
WUMS_APPLICATION_REQUESTS_EXIT() {
|
||||||
|
/* Called whenever a application wants to exit */
|
||||||
|
}
|
||||||
|
|
||||||
|
WUMS_APPLICATION_ENDS() {
|
||||||
|
/* Called whenever a application actually ends */
|
||||||
|
}
|
||||||
|
|
||||||
|
WUMS_RELOCATIONS_DONE() {
|
||||||
|
/* Called whenever the relocations have been updated, but before WUMS_APPLICATION_STARTS() */
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user