From 8118370f4e47fbef1a4bea3fd4bce45adc25a902 Mon Sep 17 00:00:00 2001 From: cadmic Date: Fri, 10 Jan 2025 04:03:51 -0800 Subject: [PATCH] Only build .o files listed in the spec (#2410) * Only build .o files listed in the spec * Remove useless CPP guards --- Makefile | 28 ++++++---------------------- src/code/db_camera.c | 4 ---- src/code/fault_gc.c | 4 ---- src/code/fault_gc_drawer.c | 4 ---- src/code/fault_n64.c | 4 ---- src/libc64/__osMalloc_gc.c | 4 ---- src/libc64/__osMalloc_n64.c | 4 ---- src/n64dd/n64dd_error_textures.c | 4 ---- 8 files changed, 6 insertions(+), 50 deletions(-) diff --git a/Makefile b/Makefile index 4e3b9affbe..046fc6802a 100644 --- a/Makefile +++ b/Makefile @@ -412,11 +412,8 @@ LDSCRIPT := $(ROM:.z64=.ld) # description of ROM segments SPEC := spec -ifeq ($(COMPILER),ido) -SRC_DIRS := $(shell find src -type d -not -path src/gcc_fix) -else SRC_DIRS := $(shell find src -type d) -endif +UNDECOMPILED_DATA_DIRS := $(shell find data -type d) ifneq ($(wildcard $(EXTRACTED_DIR)/assets/audio),) SAMPLE_EXTRACT_DIRS := $(shell find $(EXTRACTED_DIR)/assets/audio/samples -type d) @@ -495,30 +492,17 @@ ASSET_FILES_OUT := $(foreach f,$(ASSET_FILES_BIN_EXTRACTED:.bin=.bin.inc.c),$(f: $(foreach f,$(ASSET_FILES_BIN_COMMITTED:.bin=.bin.inc.c),$(BUILD_DIR)/$f) \ $(foreach f,$(wildcard assets/text/*.c),$(BUILD_DIR)/$(f:.c=.o)) -UNDECOMPILED_DATA_DIRS := $(shell find data -type d) +# Find all .o files included in the spec +SPEC_O_FILES := $(shell $(CPP) $(CPPFLAGS) $(SPEC) | $(BUILD_DIR_REPLACE) | sed -n -E 's/^[ \t]*include[ \t]*"([a-zA-Z0-9/_.-]+\.o)"/\1/p') -BASEROM_BIN_FILES := $(wildcard $(EXTRACTED_DIR)/baserom/*) - -# source files -ASSET_C_FILES_EXTRACTED := $(filter-out %.inc.c,$(foreach dir,$(ASSET_BIN_DIRS_EXTRACTED),$(wildcard $(dir)/*.c))) -ASSET_C_FILES_COMMITTED := $(filter-out %.inc.c,$(foreach dir,$(ASSET_BIN_DIRS_COMMITTED),$(wildcard $(dir)/*.c))) -SRC_C_FILES := $(filter-out %.inc.c,$(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c))) -S_FILES := $(foreach dir,$(SRC_DIRS) $(UNDECOMPILED_DATA_DIRS),$(wildcard $(dir)/*.s)) -O_FILES := $(foreach f,$(S_FILES:.s=.o),$(BUILD_DIR)/$f) \ - $(foreach f,$(SRC_C_FILES:.c=.o),$(BUILD_DIR)/$f) \ - $(foreach f,$(ASSET_C_FILES_EXTRACTED:.c=.o),$(f:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%)) \ - $(foreach f,$(ASSET_C_FILES_COMMITTED:.c=.o),$(BUILD_DIR)/$f) \ - $(foreach f,$(BASEROM_BIN_FILES),$(BUILD_DIR)/baserom/$(notdir $f).o) \ - $(BUILD_DIR)/src/code/z_message_z_game_over.o \ - $(BUILD_DIR)/src/makerom/ipl3.o - -OVL_RELOC_FILES := $(shell $(CPP) $(CPPFLAGS) $(SPEC) | $(BUILD_DIR_REPLACE) | grep -o '[^"]*_reloc.o' ) +# Split out reloc files +O_FILES := $(filter-out %_reloc.o,$(SPEC_O_FILES)) +OVL_RELOC_FILES := $(filter %_reloc.o,$(SPEC_O_FILES)) # Automatic dependency files # (Only asm_processor dependencies and reloc dependencies are handled for now) DEP_FILES := $(O_FILES:.o=.asmproc.d) $(OVL_RELOC_FILES:.o=.d) - TEXTURE_FILES_PNG_EXTRACTED := $(foreach dir,$(ASSET_BIN_DIRS_EXTRACTED),$(wildcard $(dir)/*.png)) TEXTURE_FILES_PNG_COMMITTED := $(foreach dir,$(ASSET_BIN_DIRS_COMMITTED),$(wildcard $(dir)/*.png)) TEXTURE_FILES_JPG_EXTRACTED := $(foreach dir,$(ASSET_BIN_DIRS_EXTRACTED),$(wildcard $(dir)/*.jpg)) diff --git a/src/code/db_camera.c b/src/code/db_camera.c index 7d81dafc9c..242609295d 100644 --- a/src/code/db_camera.c +++ b/src/code/db_camera.c @@ -1,7 +1,5 @@ #include "global.h" -#if DEBUG_FEATURES - #define DEBUG_CAM_CONTROLLER_PORT 2 static PlayState* sPlay; @@ -2368,5 +2366,3 @@ void func_800BB060(void) { int func_800BB06C(void) { return sDebugCamPtr->unk_00 == 2 && sDebugCamAnim.unk_0A != 0; } - -#endif diff --git a/src/code/fault_gc.c b/src/code/fault_gc.c index 9c0c35c78e..5e0ce4c905 100644 --- a/src/code/fault_gc.c +++ b/src/code/fault_gc.c @@ -40,8 +40,6 @@ * DPad-Up may be pressed to enable sending fault pages over osSyncPrintf as well as displaying them on-screen. * DPad-Down disables sending fault pages over osSyncPrintf. */ -#if !PLATFORM_N64 - #pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-eu-mq-dbg:160 gc-jp:176 gc-jp-ce:176 gc-jp-mq:176 gc-us:176" \ "gc-us-mq:176" @@ -1340,5 +1338,3 @@ NORETURN void Fault_AddHungupAndCrash(const char* file, int line) { sprintf(msg, "HungUp %s:%d", file, line); Fault_AddHungupAndCrashImpl(msg, NULL); } - -#endif diff --git a/src/code/fault_gc_drawer.c b/src/code/fault_gc_drawer.c index ba294f52d9..9d3478a48f 100644 --- a/src/code/fault_gc_drawer.c +++ b/src/code/fault_gc_drawer.c @@ -9,8 +9,6 @@ #include "terminal.h" #pragma increment_block_number "gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" -#if !PLATFORM_N64 - typedef struct FaultDrawer { /* 0x00 */ u16* fb; /* 0x04 */ u16 w; @@ -344,5 +342,3 @@ void Fault_InitDrawer(void) { bcopy(&sFaultDrawerDefault, &sFaultDrawer, sizeof(FaultDrawer)); sFaultDrawer.fb = (u16*)(PHYS_TO_K0(osMemSize) - sizeof(u16[SCREEN_HEIGHT][SCREEN_WIDTH])); } - -#endif diff --git a/src/code/fault_n64.c b/src/code/fault_n64.c index 7ea68abeb8..720307c0a1 100644 --- a/src/code/fault_n64.c +++ b/src/code/fault_n64.c @@ -1,5 +1,3 @@ -#if PLATFORM_N64 - #pragma increment_block_number "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" #include "global.h" @@ -849,5 +847,3 @@ NORETURN void Fault_AddHungupAndCrash(const char* file, int line) { sprintf(msg, "HungUp %s:%d", file, line); Fault_AddHungupAndCrashImpl(msg, NULL); } - -#endif diff --git a/src/libc64/__osMalloc_gc.c b/src/libc64/__osMalloc_gc.c index 0338ecf3f8..025c21bff9 100644 --- a/src/libc64/__osMalloc_gc.c +++ b/src/libc64/__osMalloc_gc.c @@ -3,8 +3,6 @@ #include "libc64/os_malloc.h" #include "terminal.h" -#if !PLATFORM_N64 - #define FILL_ALLOC_BLOCK_FLAG (1 << 0) #define FILL_FREE_BLOCK_FLAG (1 << 1) #define CHECK_FREE_BLOCK_FLAG (1 << 2) @@ -891,5 +889,3 @@ u8 ArenaImpl_GetAllocFailures(Arena* arena) { return arena->allocFailures; } #endif - -#endif diff --git a/src/libc64/__osMalloc_n64.c b/src/libc64/__osMalloc_n64.c index 8efb4ec6c8..56996feac9 100644 --- a/src/libc64/__osMalloc_n64.c +++ b/src/libc64/__osMalloc_n64.c @@ -2,8 +2,6 @@ #include "fault.h" #include "libc64/os_malloc.h" -#if PLATFORM_N64 - #define NODE_MAGIC 0x7373 #define NODE_IS_VALID(node) ((node)->magic == NODE_MAGIC) @@ -470,5 +468,3 @@ s32 __osCheckArena(Arena* arena) { u8 ArenaImpl_GetAllocFailures(Arena* arena) { return arena->allocFailures; } - -#endif diff --git a/src/n64dd/n64dd_error_textures.c b/src/n64dd/n64dd_error_textures.c index 037ed7835b..d115fdd6ef 100644 --- a/src/n64dd/n64dd_error_textures.c +++ b/src/n64dd/n64dd_error_textures.c @@ -1,7 +1,5 @@ #include "ultra64.h" -#if PLATFORM_N64 - u64 gN64DDError41Texs[2][0x600 / sizeof(u64)] = { { #include "assets/n64dd/error_textures/n64dd_error_41_jpn.i4.inc.c" @@ -19,5 +17,3 @@ u64 gN64DDPleaseReadManualTexs[2][0x2800 / sizeof(u64)] = { #include "assets/n64dd/error_textures/n64dd_please_read_manual_eng.i4.inc.c" }, }; - -#endif