Add making release build

This commit is contained in:
Jared Schoeny 2025-07-07 10:24:45 -10:00
parent 7ae97ab6e9
commit b18de9d182
5 changed files with 60 additions and 7 deletions

View File

@ -21,6 +21,9 @@ UNUSED_ERROR ?= 0
DEBUG ?= 0
# Adds -flto flag, which increases link time but results in a more efficient binary (especially in audio processing)
LTO ?= 0
# Makes an optimized build for release, also enabling NDEBUG macro and disabling other debugging features
# Enables LTO by default, but can be changed in the config.mk file
RELEASE ?= 0
ifeq (compare,$(MAKECMDGOALS))
COMPARE := 1
@ -31,6 +34,11 @@ endif
ifeq (debug,$(MAKECMDGOALS))
DEBUG := 1
endif
ifneq (,$(filter release tidyrelease,$(MAKECMDGOALS)))
RELEASE := 1
endif
include config.mk
# Default make rule
all: rom
@ -62,10 +70,15 @@ endif
CPP := $(PREFIX)cpp
ifeq ($(RELEASE),1)
FILE_NAME := $(FILE_NAME)-release
endif
ROM_NAME := $(FILE_NAME).gba
OBJ_DIR_NAME := $(BUILD_DIR)/modern
OBJ_DIR_NAME_TEST := $(BUILD_DIR)/modern-test
OBJ_DIR_NAME_DEBUG := $(BUILD_DIR)/modern-debug
OBJ_DIR_NAME_RELEASE := $(BUILD_DIR)/modern-release
ELF_NAME := $(ROM_NAME:.gba=.elf)
MAP_NAME := $(ROM_NAME:.gba=.map)
@ -85,6 +98,9 @@ endif
ifeq ($(DEBUG),1)
OBJ_DIR := $(OBJ_DIR_NAME_DEBUG)
endif
ifeq ($(RELEASE),1)
OBJ_DIR := $(OBJ_DIR_NAME_RELEASE)
endif
ELF := $(ROM:.gba=.elf)
MAP := $(ROM:.gba=.map)
SYM := $(ROM:.gba=.sym)
@ -120,6 +136,12 @@ else
O_LEVEL ?= 2
endif
CPPFLAGS := $(INCLUDE_CPP_ARGS) -Wno-trigraphs -DMODERN=1 -DTESTING=$(TEST) -std=gnu17
ifeq ($(RELEASE),1)
override CPPFLAGS += -DRELEASE
ifeq ($(USE_LTO_ON_RELEASE),1)
LTO := 1
endif
endif
ARMCC := $(PREFIX)gcc
PATH_ARMCC := PATH="$(PATH)" $(ARMCC)
CC1 := $(shell $(PATH_ARMCC) --print-prog-name=cc1) -quiet
@ -212,8 +234,8 @@ MAKEFLAGS += --no-print-directory
# Delete files that weren't built properly
.DELETE_ON_ERROR:
RULES_NO_SCAN += libagbsyscall clean clean-assets tidy tidymodern tidycheck generated clean-generated
.PHONY: all rom agbcc modern compare check debug
RULES_NO_SCAN += libagbsyscall clean clean-assets tidy tidymodern tidycheck tidyrelease generated clean-generated
.PHONY: all rom agbcc modern compare check debug release
.PHONY: $(RULES_NO_SCAN)
infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line))))
@ -284,6 +306,7 @@ $(shell mkdir -p $(SUBDIRS))
modern: all
compare: all
debug: all
release: all
# Uncomment the next line, and then comment the 4 lines after it to reenable agbcc.
#agbcc: all
agbcc:
@ -332,7 +355,7 @@ clean-assets:
find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.smol' -o -iname '*.fastSmol' -o -iname '*.smolTM' -o -iname '*.rl' -o -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} +
find $(DATA_ASM_SUBDIR)/maps \( -iname 'connections.inc' -o -iname 'events.inc' -o -iname 'header.inc' \) -exec rm {} +
tidy: tidymodern tidycheck tidydebug
tidy: tidymodern tidycheck tidydebug tidyrelease
tidymodern:
rm -f $(ROM_NAME) $(ELF_NAME) $(MAP_NAME)
@ -345,6 +368,14 @@ tidycheck:
tidydebug:
rm -rf $(DEBUG_OBJ_DIR_NAME)
tidyrelease:
ifeq ($(RELEASE),1)
rm -f $(ROM_NAME) $(ELF_NAME) $(MAP_NAME)
else # Manually remove the release files on clean/tidy
rm -f $(FILE_NAME)-release.gba $(FILE_NAME)-release.elf $(FILE_NAME)-release.map
endif
rm -rf $(OBJ_DIR_NAME_RELEASE)
# Other rules
include graphics_file_rules.mk
include map_data_rules.mk

2
config.mk Normal file
View File

@ -0,0 +1,2 @@
# Enable LTO when making a release build. Disable by setting to 0.
USE_LTO_ON_RELEASE ?= 1

View File

@ -2,16 +2,16 @@
#define GUARD_CONFIG_DEBUG_H
// Overworld Debug
#define DEBUG_OVERWORLD_MENU TRUE // Enables an overworld debug menu to change flags, variables, giving pokemon and more, accessed by holding R and pressing START while in the overworld by default.
#define DEBUG_OVERWORLD_MENU DISABLED_ON_RELEASE // Enables an overworld debug menu to change flags, variables, giving pokemon and more, accessed by holding R and pressing START while in the overworld by default.
#define DEBUG_OVERWORLD_HELD_KEYS (R_BUTTON) // The keys required to be held to open the debug menu.
#define DEBUG_OVERWORLD_TRIGGER_EVENT pressedStartButton // The event that opens the menu when holding the key(s) defined in DEBUG_OVERWORLD_HELD_KEYS.
#define DEBUG_OVERWORLD_IN_MENU FALSE // Replaces the overworld debug menu button combination with a start menu entry (above Pokédex).
// Battle Debug Menu
#define DEBUG_BATTLE_MENU TRUE // If set to TRUE, enables a debug menu to use in battles by pressing the Select button.
#define DEBUG_BATTLE_MENU DISABLED_ON_RELEASE // If set to TRUE, enables a debug menu to use in battles by pressing the Select button.
#define DEBUG_AI_DELAY_TIMER FALSE // If set to TRUE, displays the number of frames it takes for the AI to choose a move. Replaces the "What will PKMN do" text. Useful for devs or anyone who modifies the AI code and wants to see if it doesn't take too long to run.
// Pokémon Debug
#define DEBUG_POKEMON_SPRITE_VISUALIZER TRUE // Enables a debug menu for Pokémon sprites and icons, accessed by pressing Select in the summary screen.
#define DEBUG_POKEMON_SPRITE_VISUALIZER DISABLED_ON_RELEASE // Enables a debug menu for Pokémon sprites and icons, accessed by pressing Select in the summary screen.
#endif // GUARD_CONFIG_DEBUG_H

View File

@ -6,11 +6,16 @@
// still has them in the ROM. This is because the developers forgot
// to define NDEBUG before release, however this has been changed as
// Ruby's actual debug build does not use the AGBPrint features.
//
// Use `make release` to automatically enable NDEBUG.
#ifdef RELEASE
#define NDEBUG
#endif
// To enable printf debugging, comment out "#define NDEBUG". This allows
// printf debugging is now enabled by default. This allows
// the various AGBPrint functions to be used. (See include/gba/isagbprint.h).
// See below for enabling different pretty printing versions.
// To disable printf debugging, build a release build using `make release`.
#ifndef NDEBUG

View File

@ -1,6 +1,21 @@
#ifndef GUARD_CONSTANTS_GLOBAL_H
#define GUARD_CONSTANTS_GLOBAL_H
// You can use the ENABLED_ON_RELEASE and DISABLED_ON_RELEASE macros to
// control whether a feature is enabled or disabled when making a release build.
//
// For example, the overworld debug menu is enabled by default, but when using
// `make release`, it will be automatically disabled.
//
// #define DEBUG_OVERWORLD_MENU DISABLED_ON_RELEASE
#ifdef RELEASE
#define ENABLED_ON_RELEASE TRUE
#define DISABLED_ON_RELEASE FALSE
#else
#define ENABLED_ON_RELEASE FALSE
#define DISABLED_ON_RELEASE TRUE
#endif
#include "config/general.h"
#include "config/battle.h"
#include "config/debug.h"