From 4bab1e30fc17b1d7f84d8a487c639970bcdb528b Mon Sep 17 00:00:00 2001 From: jaby Date: Fri, 6 Oct 2023 14:23:15 +0200 Subject: [PATCH] Cherry pick files from the module branch --- .gitignore | 1 + lib/Makefile | 22 +++++++++++++++------- lib/RebuildTarget.mk | 4 +++- src/Library/Makefile | 3 ++- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index ba6fd771..d4db486a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # For now we ignore what is in root **/build **/bin +**/gcm.cache **/iso/Info /iso diff --git a/lib/Makefile b/lib/Makefile index 35f8a14e..7528450b 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,6 +1,9 @@ SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST))) include $(SELF_DIR)ExportPath.mk +substitute = $(subst $(JABY_ENGINE_DIR)/include/modules,!JABYENGINEMODULES,$(subst ..,!super,$1)) +desubstitute = $(subst !JABYENGINEMODULES,$(JABY_ENGINE_DIR)/include/modules,$(subst !super,..,$1)) + #Build architecture/variant string, possible values: x86, armv7le, etc... PLATFORM ?= PSX @@ -48,7 +51,7 @@ CXXFLAGS += -fno-exceptions -fno-rtti CCFLAGS += -mno-gpopt -fomit-frame-pointer -ffunction-sections -fdata-sections CCFLAGS += -fno-builtin -fno-strict-aliasing -Wno-attributes -CCFLAGS += -std=c++20 +CCFLAGS += -std=c++20 -fmodules-ts CCFLAGS += $(CCFLAGS_$(BUILD_PROFILE)) CCFLAGS += $(ARCHFLAGS) CCFLAGS += $(INCLUDES) @@ -66,25 +69,30 @@ LIBS_all += $(LIBS_$(BUILD_PROFILE)) DEPS = -Wp,-MMD,$(@:%.o=%.d),-MT,$@ #Object files list -OBJS = $(addprefix $(OUTPUT_DIR)/,$(addsuffix .o, $(subst ..,!super,$(basename $(SRCS))))) +MODS += $(call rwildcard,$(JABY_ENGINE_DIR)/include/modules, cxx) +SRCS := $(MODS) $(SRCS) +OBJS = $(addprefix $(OUTPUT_DIR)/,$(addsuffix .o, $(call substitute,$(basename $(SRCS))))) #Compiling rule -$(OUTPUT_DIR)/%.o: %.s +.SECONDEXPANSION: +$(OUTPUT_DIR)/%.o: $$(call desubstitute,%.s) @mkdir -p $(dir $@) $(CC) -c $(DEPS) -o $@ $(CCFLAGS) $< -$(OUTPUT_DIR)/%.o: %.c +.SECONDEXPANSION: +$(OUTPUT_DIR)/%.o: $$(call desubstitute,%.c) @mkdir -p $(dir $@) $(CC) -c $(DEPS) -o $@ $(CCFLAGS) $< -$(OUTPUT_DIR)/%.o: %.cpp +.SECONDEXPANSION: +$(OUTPUT_DIR)/%.o: $$(call desubstitute,%.cpp) @mkdir -p $(dir $@) $(CXX) -c $(DEPS) -o $@ $(CCFLAGS) $(CXXFLAGS) $< .SECONDEXPANSION: -$(OUTPUT_DIR)/%.o: $$(subst !super,..,%.s) +$(OUTPUT_DIR)/%.o: $$(call desubstitute,%.cxx) @mkdir -p $(dir $@) - $(CC) $(ARCHFLAGS) -I$(PCSX_REDUX) -g -c -o $@ $< + $(CXX) -c $(DEPS) -o $@ $(CCFLAGS) $(CXXFLAGS) $< #Inclusion of dependencies (object files to source and includes) -include $(OBJS:%.o=%.d) \ No newline at end of file diff --git a/lib/RebuildTarget.mk b/lib/RebuildTarget.mk index 217368e9..c26595ee 100644 --- a/lib/RebuildTarget.mk +++ b/lib/RebuildTarget.mk @@ -1 +1,3 @@ -rebuild: | clean all \ No newline at end of file +rebuild: + $(MAKE) clean + $(MAKE) all \ No newline at end of file diff --git a/src/Library/Makefile b/src/Library/Makefile index 2b77b4c8..3bade11d 100644 --- a/src/Library/Makefile +++ b/src/Library/Makefile @@ -11,7 +11,7 @@ CCFLAGS += -Iinclude -I../../include CCFLAGS += -save-temps=obj include ../../lib/Wildcard.mk -SRCS = $(call rwildcard, src, c cpp s) +SRCS = $(call rwildcard, src, c cpp s) include ../../lib/Makefile LIB_DIR = ../../lib/$(CONFIG_NAME) @@ -46,4 +46,5 @@ clean: rm -fr $(SPLASH_IMAGE) rm -fr $(SPLASH_IMAGE_NTSC) rm -fr $(OUTPUT_DIR) + rm -fr gcm.cache rm -fr $(LIB_DIR)/$(ARTIFACT).a \ No newline at end of file