diff --git a/build.sh b/build.sh index 440ac591a..b8b8c87ec 100755 --- a/build.sh +++ b/build.sh @@ -18,11 +18,13 @@ export NINJA_STATUS="[%p %f/%t] " export MESON_RSP_THRESHOLD=16387 # Build the project +"${MESON:-meson}" configure build "-Dgdb_debugging=false" if [ "$target" = test ]; then "${MESON:-meson}" test -C build "$@" elif [ "$target" = rom ]; then "${MESON:-meson}" compile -C build "pokeplatinum.us.nds" elif [ "$target" = debug ]; then + "${MESON:-meson}" configure build "-Dgdb_debugging=true" "${MESON:-meson}" compile -C build "pokeplatinum.us.nds" "debug.nef" "overlay.map" else "${MESON:-meson}" compile -C build "$target" "$@" diff --git a/include/game_overlay.h b/include/game_overlay.h index 6939ec0dc..a869c3972 100644 --- a/include/game_overlay.h +++ b/include/game_overlay.h @@ -13,10 +13,6 @@ void Overlay_UnloadByID(const FSOverlayID param0); int Overlay_GetLoadDestination(const FSOverlayID param0); BOOL Overlay_LoadByID(const FSOverlayID param0, int param1); -// TODO: this should integrate into build system instead of a manual define here. -// to turn off overlay debugging and build a matching ROM, undefine this. -// #define GDB_DEBUGGING - #ifdef GDB_DEBUGGING // describes a single overlay entry, which GDB can inspect to determine which overlays are loaded. typedef struct { diff --git a/meson.build b/meson.build index 0b02ad4d4..00b3a4ec4 100644 --- a/meson.build +++ b/meson.build @@ -19,7 +19,6 @@ public_includes = include_directories('include', 'asm', 'res') ### COMPILER FLAGS ### ############################################################ c_args = [ - '-O4,p', '-proc', 'arm946e', '-enum', 'int', '-lang', 'c99', @@ -35,6 +34,15 @@ c_args = [ '-sym', 'on' ] +if get_option('gdb_debugging') + c_args += [ + '-O1,p', + '-inline', 'off' + ] +else + c_args += '-O4,p' +endif + add_global_arguments(c_args, language: 'c', native: false @@ -46,6 +54,10 @@ pokeplatinum_args = [ '-DGAME_LANGUAGE=ENGLISH' ] +if get_option('gdb_debugging') + pokeplatinum_args += '-DGDB_DEBUGGING' +endif + asm_args = [ '-proc', 'arm5TE', '-16', @@ -240,8 +252,7 @@ nef_fixer = custom_target('debug.nef', ], command : [ nef_fixer_py, '@INPUT@', '@OUTPUT@' - ], - build_by_default: true + ] ) ovly_mapper = custom_target('overlay.map', @@ -253,8 +264,7 @@ ovly_mapper = custom_target('overlay.map', ], command : [ overlay_mapper_py, '@INPUT@', '@OUTPUT@' - ], - build_by_default: true + ] ) diff --git a/meson.options b/meson.options new file mode 100644 index 000000000..fd78cd4ee --- /dev/null +++ b/meson.options @@ -0,0 +1 @@ +option('gdb_debugging', type : 'boolean', value : false) \ No newline at end of file