Fix compiling in via docker, always recompile if sd_loader has changes

This commit is contained in:
Maschell 2020-11-27 14:50:07 +01:00
parent 1fb7290017
commit 548fab9786
5 changed files with 29 additions and 13 deletions

1
.gitignore vendored
View File

@ -1,6 +1,5 @@
build/
*.elf
src/sd_loader.h
*.cbp
payload.bin
.idea/

View File

@ -26,7 +26,8 @@ export OBJCOPY := $(PREFIX)objcopy
TARGET := payload
BUILD := build
BUILD_DBG := $(TARGET)_dbg
SOURCES := src
SOURCES := src \
sd_loader
DATA :=
INCLUDES :=
@ -71,7 +72,7 @@ export DEPSDIR := $(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) sd_loader.c
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
@ -110,21 +111,20 @@ export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean install
#---------------------------------------------------------------------------------
$(BUILD): src/sd_loader.h
$(BUILD): sd_loader/sd_loader.h
@[ -d $@ ] || mkdir -p $@
@$(MAKE) -j1 --no-print-directory -C $(CURDIR)/sd_loader -f $(CURDIR)/sd_loader/Makefile
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
sd_loader_elf := sd_loader/sd_loader.elf
src/sd_loader.h: $(sd_loader_elf)
xxd -i $< | sed "s/unsigned/static const unsigned/g;s/loader/loader/g;s/build_//g" > $@
sd_loader_elf := sd_loader/sd_loader.h
$(sd_loader_elf):
make -C sd_loader
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@$(MAKE) --no-print-directory -C $(CURDIR)/sd_loader -f $(CURDIR)/sd_loader/Makefile clean
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf
#---------------------------------------------------------------------------------
@ -140,7 +140,7 @@ $(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .jpg extension
#---------------------------------------------------------------------------------
%.elf: link.ld $(OFILES)
%.elf: link.ld $(OFILES)
@echo "linking ... $(TARGET).elf"
$(Q)$(LD) -n -T $^ $(LDFLAGS) -o ../$(BUILD_DBG).elf $(LIBPATHS) $(LIBS)
$(Q)$(OBJCOPY) -S -R .comment -R .gnu.attributes ../$(BUILD_DBG).elf $@

4
sd_loader/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
build/
*.elf
sd_loader.c
sd_loader.h

View File

@ -102,6 +102,12 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
-I$(CURDIR)/$(BUILD) -I$(LIBOGC_INC) \
-I$(PORTLIBS)/include -I$(PORTLIBS)/include/freetype2
#---------------------------------------------------------------------------------
# path to tools
#---------------------------------------------------------------------------------
DEVKITPATH=$(shell echo "$(DEVKITPRO)" | sed -e 's/^\([a-zA-Z]\):/\/\1/')
export PATH := $(DEVKITPATH)/tools/bin:$(DEVKITPATH)/devkitPPC/bin:$(PATH)
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
@ -119,7 +125,7 @@ $(BUILD):
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf $(BUILD_DBG).c $(BUILD_DBG).h
#---------------------------------------------------------------------------------
else
@ -129,7 +135,14 @@ DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).elf: $(OFILES)
$(OUTPUT).h: $(OFILES)
$(OUTPUT).c: $(OUTPUT).elf
@raw2c $<
@cp $(TARGET).c $@
$(OUTPUT).h: $(OUTPUT).c
@cp $(TARGET).h $@
#---------------------------------------------------------------------------------
# This rule links in binary data with the .jpg extension

View File

@ -1,6 +1,6 @@
#include "elf_abi.h"
#include "sd_loader.h"
#include "../sd_loader/src/common.h"
#include "../sd_loader/sd_loader.h"
#include <stdint.h>
#define OSDynLoad_Acquire ((void (*)(char* rpl, unsigned int *handle))0x0102A3B4)
@ -190,7 +190,7 @@ int _start(int argc, char **argv) {
InstallPatches(&private_data);
unsigned char * pElfBuffer = (unsigned char *) sd_loader_sd_loader_elf; // use this address as temporary to load the elf
unsigned char * pElfBuffer = (unsigned char *) sd_loader; // use this address as temporary to load the elf
unsigned int mainEntryPoint = load_elf_image(&private_data, pElfBuffer);