-
-
Notifications
You must be signed in to change notification settings - Fork 177
Add RGBASM -MC
flag to continue -MG
after missing dependency files
#1687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
a133a01
to
a381021
Compare
Some examples of where DEF MORE = 0
; code.inc should be generated before assembling, and might do `DEF MORE = 1`
INCLUDE "code.inc"
; if code.inc did `DEF MORE = 1`, more-code.inc should be generated too
if MORE == 1
INCLUDE "more-code.inc"
endc Data:
; data.bin should be generated before assembling, but might be empty
INCBIN "data.bin"
; if data.bin was empty, alternate-data.bin should be generated too
if @ - Data == 0
INCBIN "alternate-data.bin"
endc In those cases, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not feeling happy about this, but eh.
If you're not happy about it because this implementation looks incorrect, incomplete, or inadequate for what users are wanting to accomplish, then I want to hear why and fix it before merge. If it's just that you don't think this capability ought to be possible at all, I disagree. Users have repeatedly gotten tripped up and confused by how I understand the point that sometimes continued processing would be incorrect, but the common case is that continued processing would be safe, and the docs do warn about that uncommon case. From the comments in #903, it sounded like you were okay with a solution like this, but it just got lost/forgotten and we didn't implement it at the time:
|
gb-starter-kit provides a simple counter-example of what you call “common behaviour”: INCLUDE "assets/file.pb16.size" ; ⚠️ Defines a constant.
ds NB_PB16_BLOCKS ; Fatal error: referencing non-const symbol in const context. I disagree that this is truly “common behaviour”, and contend that both scenarii are equally as common, if not unbalanced in favour of the current solution. |
Not a counterexample to anything, that's just the uncommon behavior that I noted, which is why Is this not yet pushed? I see its Makefile support for defining
You don't think simple generated |
I don't contend that most uses of generated |
True, projects shouldn't try to apply I did test --- a/Makefile
+++ b/Makefile
@@ -128,15 +128,17 @@ ifeq (,$(filter clean tidy tools,$(MAKECMDGOALS)))
$(info $(shell $(MAKE) -C tools))
endif
-preinclude_deps := includes.asm $(shell tools/scan_includes includes.asm)
-
define DEP
-$1: $2 $$(shell tools/scan_includes $2) $(preinclude_deps) | rgbdscheck.o
+$(subst |,
+,$(shell $(RGBDS)rgbasm $(RGBASM_FLAGS) -M - -MG -MC -MQ $1 $2 | tr '\n' '|'))
+$1: $2 | rgbdscheck.o
$Q$$(RGBDS)rgbasm $$(RGBASM_FLAGS) -o $$@ $$<
endef
define VCDEP
-$1: $2 $$(shell tools/scan_includes $2) $(preinclude_deps) | rgbdscheck.o
+$(subst |,
+,$(shell $(RGBDS)rgbasm $(RGBASM_VC_FLAGS) -M - -MG -MC -MQ $1 $2 | tr '\n' '|'))
+$1: $2 | rgbdscheck.o
$Q$$(RGBDS)rgbasm $$(RGBASM_VC_FLAGS) -o $$@ $$<
endef The ROM builds identically as before, albeit more slowly since |
If pret is the only current use case for this, but they'd decline to switch over due to the performance loss, is there an outlook for this functionality? |
pret is not the only current use case; it's an example of a complex project where all of the dependencies are compatible with Even gb-starter-kit (and the multiple completed games based on it!) are compatible with (I'll admit I gave up on trying to build any of Shock Lobster, Esprit, or Rhythm Land as definite tests, because they're finicky in other ways -- hard-coded .exe extensions, Rust or Python package requirements, etc -- but if it's a blocker to agreeing on if/how Thinking more about it, I'm actually pretty sure it's just plain bad practice, in any language, to make one generated dependency create more of them. In the general case, you end up with the same limitation as RGBASM -- what gets generated could do anything, so you have no choice but to halt the build and generate it before you can continue. But doing so in different build systems varies from "difficult" to "impossible", and usually languages aren't so flexible that they could possibly require such a thing anyway. If there are any non-theoretical examples, then of course the devs can continue to use INCLUDE "generated-debug.inc" ; DEFs DEBUG to either 0 or 1
if DEBUG
INCBIN "staging.bin"
else
INCBIN "production.bin"
endc Of course this would build incorrectly with |
I expect that the gb-asm-tutorial would be another use case for (And if a later, more advanced step of the tutorial demonstrates generated dependencies more complex than |
An idea while reading the NASM docs (it has ; the .size file would contain "DEF NB_PB8_BLOCKS EQU whatever"
INCLUDE "assets/crash_font.1bpp.pb8.size"
ld c, NB_PB8_BLOCKS
PURGE NB_PB8_BLOCKS to this: IF INCLUDE "assets/crash_font.1bpp.pb8.size"
ld c, NB_PB8_BLOCKS
PURGE NB_PB8_BLOCKS
ENDC or even this, if you're worried about size differences: IF INCLUDE "assets/crash_font.1bpp.pb8.size"
ld c, NB_PB8_BLOCKS
PURGE NB_PB8_BLOCKS
ELSE
ld c, 0
ENDC (Of course, projects that use things like .size files could also just stay as-is, without using |
8f0ee80
to
a0ccaa3
Compare
Fixes #903
RGBASM
-M
outputs a list ofmake
dependencies (i.e.INCLUDE
d orINCBIN
ned files) instead of an object file. The-MG
flag allows outputting dependencies for nonexistent files, on the user's implied assumption that any nonexistent files will be generated bymake
. However, RGBASM exits after outputting the first such nonexistent dependency, since its presence could potentially influence how subsequent code is assembled. The user thus needs to runrgbasm -M ... -MG
in a loop until all dependencies are covered, which is a "finicky" process that can require advanced knowledge of your build system (presumablymake
).This PR adds a
-MC
flag to allow continuing processing even after a nonexistent dependency, on the user's implied assumption that they're not doing anything tricky/weird that the dependency would have influenced. The goal is to make a "typical" workflow -- for example, a .asm file that justINCBIN
s a lot of graphics files, but has no weird tricky conditionals about their byte sizes -- easier to handle. And it's still opt-in since in those tricky cases, this behavior would be unreliable.