Some overlays share the same source files. An extreme example of it
are "select2", "select3"... overlays that consist of the same
"Game/select.c" file.
However, if you try to link 2 overlays that have the same symbols
(global variable names) you get "symbol multiply defined" error.
Moreover, when building an overlay source file the resulting object
file has all sections prefixed by the overlay name (we would have to
build those files multiple times with different prefixes).
Solve the issue by running the linker multiple times. Each execution
builds a separate overlay (and unfortunately also a separate main exe).
Show that it works by building "select2", "select3", ... overlays.
Another benefit of it is that we now generate a separate .sym file
per each overlay (not a single one where all the symbols are mixed).
To make it possible to actually build a different executable for VR,
"MAIN_EXE" or "VR_EXE" define is passed to the preprocessor, so that
#ifdefs can be introduced into the code:
#ifdef VR_EXE
... VR exe specific code ...
#endif
Similarly, those defines are also passed to the linker_command_file.txt
templating, where it can be used this way:
{% if MAIN_EXE %}
include "{{OBJ_DIR}}\Equip\jpegcam.obj"
{% endif %}
This commit modifies the build system for it to be able to build the
project to a different directory than "obj/". This will be used to
build the VR exe to "obj_vr/" in the coming commits.
Before this change, linker_command_file.txt was a static file used by
psylink. However, VR executable will require a slightly different
linker_command_file.txt (only a few slight differences).
To avoid duplication (having multiple linker_command_file.txt files),
this commit now treats this file as a template. Jinja2 library is used
as a template engine (it's a bit of an overkill, but cpp preprocessor
tried to be too clever and failed parsing linker_command_file.txt).
This change will allow us to have a single linker_command_file.txt,
which will dynamically build to different variants.