mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Avoid hard-coding a redundant "FATAL:" in RGBLINK
This commit is contained in:
@@ -379,15 +379,15 @@ static void categorizeSection(Section §ion) {
|
|||||||
sections.insert(pos, §ion);
|
sections.insert(pos, §ion);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<Section *> checkOverlayCompat() {
|
static std::vector<Section const *> checkOverlayCompat() {
|
||||||
std::vector<Section *> unfixedSections;
|
std::vector<Section const *> unfixedSections;
|
||||||
|
|
||||||
if (!options.overlayFileName) {
|
if (!options.overlayFileName) {
|
||||||
return unfixedSections;
|
return unfixedSections;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t constraints = std::size(unassignedSections); constraints--;) {
|
for (uint8_t constraints = std::size(unassignedSections); constraints--;) {
|
||||||
if ((constraints & (BANK_CONSTRAINED | ORG_CONSTRAINED))
|
if (((constraints & BANK_CONSTRAINED) && (constraints & ORG_CONSTRAINED))
|
||||||
|| unassignedSections[constraints].empty()) {
|
|| unassignedSections[constraints].empty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -418,17 +418,26 @@ void assign_AssignSections() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Overlaying requires only fully-constrained sections
|
// Overlaying requires only fully-constrained sections
|
||||||
if (std::vector<Section *> unfixedSections = checkOverlayCompat(); !unfixedSections.empty()) {
|
if (std::vector<Section const *> unfixedSections = checkOverlayCompat();
|
||||||
|
!unfixedSections.empty()) {
|
||||||
size_t nbUnfixedSections = unfixedSections.size();
|
size_t nbUnfixedSections = unfixedSections.size();
|
||||||
fputs("FATAL: All sections must be fixed when using an overlay file", stderr);
|
std::string unfixedList;
|
||||||
for (size_t i = 0; i < nbUnfixedSections; ++i) {
|
for (Section const *section : unfixedSections) {
|
||||||
fprintf(stderr, "%c \"%s\"", i == 0 ? ';' : ',', unfixedSections[i]->name.c_str());
|
unfixedList += "\n- \"";
|
||||||
|
unfixedList += section->name;
|
||||||
|
unfixedList += '"';
|
||||||
}
|
}
|
||||||
if (nbSectionsToAssign != nbUnfixedSections) {
|
if (nbSectionsToAssign > nbUnfixedSections) {
|
||||||
fprintf(stderr, " and %" PRIu64 " more", nbSectionsToAssign - nbUnfixedSections);
|
unfixedList += "\n- and ";
|
||||||
|
unfixedList += std::to_string(nbSectionsToAssign - nbUnfixedSections);
|
||||||
|
unfixedList += " more";
|
||||||
}
|
}
|
||||||
fprintf(stderr, " %s not\n", nbSectionsToAssign == 1 ? "is" : "are");
|
fatal(
|
||||||
exit(1);
|
"All sections must be fixed when using an overlay file; %" PRIu64 " %s not:%s",
|
||||||
|
nbSectionsToAssign,
|
||||||
|
nbSectionsToAssign == 1 ? "is" : "are",
|
||||||
|
unfixedList.c_str()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign sections in decreasing constraint order
|
// Assign sections in decreasing constraint order
|
||||||
|
|||||||
4
test/link/overlay/unfixed/a.asm
Normal file
4
test/link/overlay/unfixed/a.asm
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
FOR n, 15
|
||||||
|
SECTION "test {d:n}", ROM0
|
||||||
|
db n
|
||||||
|
ENDR
|
||||||
13
test/link/overlay/unfixed/out.err
Normal file
13
test/link/overlay/unfixed/out.err
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
FATAL: All sections must be fixed when using an overlay file; 15 are not:
|
||||||
|
- "test 14"
|
||||||
|
- "test 13"
|
||||||
|
- "test 12"
|
||||||
|
- "test 11"
|
||||||
|
- "test 10"
|
||||||
|
- "test 9"
|
||||||
|
- "test 8"
|
||||||
|
- "test 7"
|
||||||
|
- "test 6"
|
||||||
|
- "test 5"
|
||||||
|
- and 5 more
|
||||||
|
Linking aborted with 1 error
|
||||||
1
test/link/overlay/unfixed/overlay.gb
Normal file
1
test/link/overlay/unfixed/overlay.gb
Normal file
File diff suppressed because one or more lines are too long
@@ -233,6 +233,14 @@ tryDiff "$test"/out.err "$outtemp"
|
|||||||
tryCmp "$test"/out.gb "$gbtemp"
|
tryCmp "$test"/out.gb "$gbtemp"
|
||||||
evaluateTest
|
evaluateTest
|
||||||
|
|
||||||
|
test="overlay/unfixed"
|
||||||
|
startTest
|
||||||
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
|
continueTest
|
||||||
|
rgblinkQuiet -o "$gbtemp" -O "$test"/overlay.gb "$otemp" 2>"$outtemp"
|
||||||
|
tryDiff "$test"/out.err "$outtemp"
|
||||||
|
evaluateTest
|
||||||
|
|
||||||
test="overlay/tiny"
|
test="overlay/tiny"
|
||||||
startTest
|
startTest
|
||||||
"$RGBASM" -o "$otemp" "$test"/a.asm
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
|
|||||||
Reference in New Issue
Block a user