From caea5ec4cb60943659edc373f2bb06492b376669 Mon Sep 17 00:00:00 2001 From: Zerocker Date: Fri, 5 Jun 2020 20:40:08 +0900 Subject: [PATCH 1/3] Nuke old VERSION OPT_FLAGS and add DEBUG flag --- Makefile | 10 ++++------ build.sh | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 49b60620..bfe0f8dc 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,8 @@ default: all # These options can either be changed by modifying the makefile, or # by building with 'make SETTING=value'. 'make clean' may be required. +# Build debug version (default) +DEBUG ?= 1 # Version of the game to build VERSION ?= us # Graphics microcode used @@ -280,15 +282,11 @@ GODDARD_SRC_DIRS := src/goddard src/goddard/dynlists MIPSISET := -mips2 MIPSBIT := -32 -ifeq ($(VERSION),eu) - OPT_FLAGS := -O2 -else -ifeq ($(VERSION),sh) - OPT_FLAGS := -O2 +ifeq ($(DEBUG),1) + OPT_FLAGS := -g else OPT_FLAGS := -O2 endif -endif # Set BITS (32/64) to compile for OPT_FLAGS += $(BITS) diff --git a/build.sh b/build.sh index 87d3597b..040860be 100644 --- a/build.sh +++ b/build.sh @@ -7,8 +7,8 @@ LIBAFLA=libaudiofile.la AUDDIR=./tools/audiofile-0.3.6 # Command line options -OPTIONS=("Analog Camera" "No Draw Distance" "Text-saves" "Smoke Texture Fix" "Clean build") -EXTRA=("BETTERCAMERA=1" "NODRAWINGDISTANCE=1" "TEXTSAVES=1" "TEXTURE_FIX=1" "clean") +OPTIONS=("Analog Camera" "No Draw Distance" "Text-saves" "Smoke Texture Fix" "Release build" "Clean build") +EXTRA=("BETTERCAMERA=1" "NODRAWINGDISTANCE=1" "TEXTSAVES=1" "TEXTURE_FIX=1" "DEBUG=0" "clean") # Colors RED=$(tput setaf 1) From 2ae6e0fac017e7f532ad77eaa2b76ab22b632df2 Mon Sep 17 00:00:00 2001 From: Zerocker Date: Fri, 5 Jun 2020 21:12:44 +0900 Subject: [PATCH 2/3] Remove old -O2 flag --- Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Makefile b/Makefile index bfe0f8dc..b2154dda 100644 --- a/Makefile +++ b/Makefile @@ -295,10 +295,6 @@ ifeq ($(TARGET_WEB),1) OPT_FLAGS := -O2 -g4 --source-map-base http://localhost:8080/ endif -# Use a default opt flag for gcc, then override if RPi - -# OPT_FLAGS := -O2 # "Whole-compile optimization flag" Breaks sound on x86. - ifeq ($(TARGET_RPI),1) machine = $(shell sh -c 'uname -m 2>/dev/null || echo unknown') # Raspberry Pi B+, Zero, etc From e7218f043b1032ef5003c1fce39cf0399f3beb4e Mon Sep 17 00:00:00 2001 From: Zerocker Date: Sun, 7 Jun 2020 21:16:09 +0900 Subject: [PATCH 3/3] Add separate DEBUG flag for tools --- Makefile | 12 +++--------- tools/Makefile | 30 ++++++++++++++++++++++-------- tools/gen_asset_list.cpp | 2 +- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index b2154dda..a111fe56 100644 --- a/Makefile +++ b/Makefile @@ -75,9 +75,9 @@ else endif ifeq ($(TARGET_WEB),0) -ifeq ($(HOST_OS),Windows) -WINDOWS_BUILD := 1 -endif + ifeq ($(HOST_OS),Windows) + WINDOWS_BUILD := 1 + endif endif # MXE overrides @@ -96,8 +96,6 @@ endif ifneq ($(TARGET_BITS),0) BITS := -m$(TARGET_BITS) -else - BITS := endif # Release (version) flag defs @@ -340,10 +338,6 @@ GODDARD_C_FILES := $(foreach dir,$(GODDARD_SRC_DIRS),$(wildcard $(dir)/*.c)) GENERATED_C_FILES := $(BUILD_DIR)/assets/mario_anim_data.c $(BUILD_DIR)/assets/demo_data.c \ $(addprefix $(BUILD_DIR)/bin/,$(addsuffix _skybox.c,$(notdir $(basename $(wildcard textures/skyboxes/*.png))))) -ifeq ($(WINDOWS_BUILD),0) - CXX_FILES := -endif - # We need to keep this for now # If we're not N64 use below diff --git a/tools/Makefile b/tools/Makefile index 28ff49bf..d143bb46 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,17 +1,26 @@ UNAME := $(shell uname) +DEBUG ?= 0 + ifeq ($(UNAME),Darwin) - OSX_BUILD := -DOSX_BUILD + OSX_BUILD := -DOSX_BUILD +endif + +ifeq ($(DEBUG),1) + OPT_FLAG := -g +else + OPT_FLAG := -O2 endif CC := gcc -CFLAGS := -Llib -Iinclude -I../include -I . -Wall -Wextra -Wno-unused-parameter $(OSX_BUILD) -pedantic -std=c99 -O3 -s +CXX := g++ +CFLAGS := -Llib -Iinclude -I../include -I . -Wall -Wextra -Wno-unused-parameter $(OSX_BUILD) -pedantic -std=c99 $(OPT_FLAG) -s PROGRAMS := n64graphics n64graphics_ci mio0 n64cksum textconv patch_libultra_math iplfontutil aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv n64graphics_SOURCES := n64graphics.c utils.c n64graphics_CFLAGS := -DN64GRAPHICS_STANDALONE n64graphics_ci_SOURCES := n64graphics_ci_dir/n64graphics_ci.c n64graphics_ci_dir/exoquant/exoquant.c n64graphics_ci_dir/utils.c -n64graphics_ci_CFLAGS := -O2 # 3s faster compile time +n64graphics_ci_CFLAGS := $(OPT_FLAG) mio0_SOURCES := libmio0.c mio0_CFLAGS := -DMIO0_STANDALONE @@ -22,10 +31,10 @@ textconv_SOURCES := textconv.c utf8.c hashtable.c patch_libultra_math_SOURCES := patch_libultra_math.c iplfontutil_SOURCES := iplfontutil.c -iplfontutil_CFLAGS := -O2 # faster compile time +iplfontutil_CFLAGS := $(OPT_FLAG) aifc_decode_SOURCES := aifc_decode.c -aifc_decode_CFLAGS := -O2 # both runs and compiles faster than -O3 +aifc_decode_CFLAGS := $(OPT_FLAG) aiff_extract_codebook_SOURCES := aiff_extract_codebook.c @@ -36,19 +45,24 @@ vadpcm_enc_SOURCES := sdk-tools/adpcm/vadpcm_enc.c sdk-tools/adpcm/vpredictor.c vadpcm_enc_CFLAGS := -Wno-unused-result -Wno-uninitialized -Wno-sign-compare -Wno-absolute-value extract_data_for_mio_SOURCES := extract_data_for_mio.c -extract_data_for_mio_CFLAGS := -O2 +extract_data_for_mio_CFLAGS := $(OPT_FLAG) skyconv_SOURCES := skyconv.c n64graphics.c utils.c -skyconv_CFLAGS := -O2 -lm +skyconv_CFLAGS := $(OPT_FLAG) -lm all: $(PROGRAMS) clean: $(RM) $(PROGRAMS) + $(RM) gen_asset_list define COMPILE $(1): $($1_SOURCES) $(CC) $(CFLAGS) $(OSX_BUILD) $$^ -lm -o $$@ $($1_CFLAGS) endef -$(foreach p,$(PROGRAMS),$(eval $(call COMPILE,$(p)))) +# Separate build for debugging gen_asset_list.cpp +gen_asset_list: + $(CXX) -std=c++17 gen_asset_list.cpp -lstdc++fs $(OPT_FLAG) -Wall -o gen_asset_list + +$(foreach p,$(PROGRAMS),$(eval $(call COMPILE,$(p)))) \ No newline at end of file diff --git a/tools/gen_asset_list.cpp b/tools/gen_asset_list.cpp index 050bd118..3096293e 100644 --- a/tools/gen_asset_list.cpp +++ b/tools/gen_asset_list.cpp @@ -222,7 +222,7 @@ tuple> compileSoundData(const string& lang) { } int main() { - intentional syntax error; // (see comment at top of file) + //intentional syntax error; // (see comment at top of file) map assets; map>> soundAssets;