Make a Release Build for Your Hack - Pawkkie/Team-Aquas-Asset-Repo GitHub Wiki

Creating a Release Build

RavePossum

Most people use several tools for debugging when creating a decomp ROMhack, like the DebugPrintf() function in pokeemerald, or the overworld debug menu in pokeemerald-expansion. Most people will probably also want to make sure those tools are disabled when they release a build of their hack. You could comment and uncomment a bunch of lines every time you build a release, but it's much easier to just create a build target for it.

Here's a straightforward way to create a release build for your hack with a few examples of its usage.

Editing the Makefile

First, you'll want to edit your Makefile like so:

+ # Build with the release flag defined
+ RELEASE     ?= 0
+ # Build a release without cleaning first
+ NOCLEAN     ?= 0

ifeq (compare,$(MAKECMDGOALS))
  COMPARE := 1
endif
+ ifeq (release,$(MAKECMDGOALS))
+   export RELEASE := 1
+ endif

...

- CPPFLAGS := $(INCLUDE_CPP_ARGS) -Wno-trigraphs -DMODERN=$(MODERN)
+ CPPFLAGS := $(INCLUDE_CPP_ARGS) -Wno-trigraphs -DMODERN=$(MODERN) -DRELEASE=$(RELEASE)

...

- .PHONY: all rom modern compare
+ .PHONY: all rom modern compare release

...

modern: all
+ release:
+ ifneq ($(NOCLEAN),1)
+ 	$(MAKE) clean
+ endif
+ 	$(MAKE) all

...

Older Makefiles only:

- ifeq (,$(filter-out all rom compare agbcc modern check libagbsyscall syms $(TESTELF) debug,$(MAKECMDGOALS)))
+ ifeq (,$(filter-out all rom compare agbcc modern check libagbsyscall syms $(TESTELF) debug release,$(MAKECMDGOALS)))

(Your Makefile may vary slightly. If so, try looking for a smaller subset of the information like just .PHONY or CPPFLAGS :=)

Disabling Parts of Code

Next, all you need to do is wrap anything you want to disable for a release build in a preprocessor #if statement, like so:

Example in pokeemerald's include/config.h:

+ #if RELEASE
#define NDEBUG
+ #endif

You can also do more complicated checks using #else statements, like so:

Example in pokeemerald-expansion's include/config/debug.h:

+ #if RELEASE
+ #define DEBUG_ACTIVE FALSE
+ #else
+ #define DEBUG_ACTIVE TRUE
+ #endif

// Overworld Debug
- #define DEBUG_OVERWORLD_MENU            TRUE
+ #define DEBUG_OVERWORLD_MENU            DEBUG_ACTIVE

Building a Release Build

Now that you've added these changes, in order to actually create your release build, you'll just need to build slightly differently. Instead of running make, you'll need to run make release. You can combine with this -j like any other build for increased speed. Note that when you're ready to go back to development, you'll want to run a make clean to ensure your all files your that utilize the release preprocessing get rebuilt and your debug options are available again.

Additional Info

The release target will run a make clean before building the ROM to ensure all files are rebuilt with the release flag defined. However, if you're iterating on the release build (e.g. testing with different changes to make sure the debug functions are actually off), you may find that slows the process down a lot. If you're certain you don't need to do a full rebuild, you can instead run make release NOCLEAN=1 to skip the make clean.