Commit a7ffee4e authored by Ben Avison's avatar Ben Avison
Browse files

Solution for cross-compiling ResourceFile macros that use LocalRes$Path

Many components' resources are laid out in a nested manner within the
`Resources` directory, with appropriate files selected at build time according
to the `USERIF` and `LOCALE` settings of the build. The shared makefiles
already take care of this for the ROM `resources` phase using the `InstRes`
perl script, and the `CModule` makefile performs a fake `resources` phase
within its `standalone` phase before feeding the result to `ResGen` via the
`InstViaRG` perl script. The remaining case that hasn't been dealt with until
now is the `standalone` phase for `AAsmModule` components, where ResourceFS
objects are embedded in the module object using the `ResourceFile` macro (and
internally the `BIN` directive) which until now have specified the source
filename via a path prefixed with `LocalRes:`

`objasm`'s include search path isn't applied to file specs supplied to `BIN`
(or `:FSIZE:` etc) so the solution presented here is a make function which
searches for the resource file while interpreting the Makefile. The cross
version (only) of the `AAsmModule` shared makefile automatically applies this
function to any resource filenames specified in `INSTRAM_FILES` (which usually
matches `INSTRES_FILES`) and passes the full path to the resource file into
`objasm` using a string variable of the same name (wrapped in vertical bars to
deal with cases like `!Help` which contain otherwise invalid symbol
characters). `amu` doesn't implement make functions, so the assembly source
should drop back to using the `LocalRes:` prefix if the string variable is
parent a49887d4
......@@ -101,8 +101,13 @@ SA_FLAGS ?= -PD "standalone SETL {TRUE}" -PD "MergedMsgs SETS \"${MERGEDMSGS}\
SA_FLAGS ?= -PD "standalone SETL {TRUE}" -PD "MergedMsgs SETS \"${MERGEDMSGS}\""
SA_FLAGS += $(foreach resource,${INSTRAM_FILES},$(call AS_PATH_TO,${resource}))
# A make function that expands to an assembler switch that specifies the canonicalised
# path to a resource file
AS_PATH_TO = -pd "|${1}| SETS \"$(call LOCALRES,${1})\""
......@@ -237,4 +237,12 @@ SEP = /
EXT = .
# A make function which does the equivalent of searching LocalRes$Path on RISC OS
# For example:
# $(call LOCALRES,Templates)
# might expand to "Resources/Ursula/UK/Templates,fec"
LOCALRES = $(shell for path in ${USERIF}/${LOCALE} ${USERIF}/UK ${LOCALE} UK ""; do if [ -f Resources/$$path/${1} ]; then echo Resources/$$path/${1}; break; elif [ -f Resources/$$path/${1},??? ]; then echo Resources/$$path/${1},???; break; fi; done )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment