mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Add RGBASM -MC flag to continue -MG after missing dependency files (#1687)
This commit is contained in:
@@ -48,9 +48,10 @@ local args=(
|
|||||||
'*'{-D,--define}'+[Define a string symbol]:name + value (default 1):'
|
'*'{-D,--define}'+[Define a string symbol]:name + value (default 1):'
|
||||||
'(-g --gfx-chars)'{-g,--gfx-chars}'+[Change chars for gfx constants]:chars spec:'
|
'(-g --gfx-chars)'{-g,--gfx-chars}'+[Change chars for gfx constants]:chars spec:'
|
||||||
'(-I --include)'{-I,--include}'+[Add an include directory]:include path:_files -/'
|
'(-I --include)'{-I,--include}'+[Add an include directory]:include path:_files -/'
|
||||||
'(-M --dependfile)'{-M,--dependfile}"+[Write deps in make format]:output file:_files -g '*.{d,mk}'"
|
'(-M --dependfile)'{-M,--dependfile}"+[Write dependencies in Makefile format]:output file:_files -g '*.{d,mk}'"
|
||||||
-MG'[Assume missing files should be generated]'
|
-MC'[Continue after missing dependencies]'
|
||||||
-MP'[Add phony targets to all deps]'
|
-MG'[Assume missing dependencies should be generated]'
|
||||||
|
-MP'[Add phony targets to all dependencies]'
|
||||||
'*'-MT"+[Add a target to the rules]:target:_files -g '*.{d,mk,o}'"
|
'*'-MT"+[Add a target to the rules]:target:_files -g '*.{d,mk,o}'"
|
||||||
'*'-MQ"+[Add a target to the rules]:target:_files -g '*.{d,mk,o}'"
|
'*'-MQ"+[Add a target to the rules]:target:_files -g '*.{d,mk,o}'"
|
||||||
'(-o --output)'{-o,--output}'+[Output file]:output file:_files'
|
'(-o --output)'{-o,--output}'+[Output file]:output file:_files'
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ extern bool verbose;
|
|||||||
|
|
||||||
extern FILE *dependFile;
|
extern FILE *dependFile;
|
||||||
extern std::string targetFileName;
|
extern std::string targetFileName;
|
||||||
|
extern bool continueAfterMissingIncludes;
|
||||||
extern bool generatedMissingIncludes;
|
extern bool generatedMissingIncludes;
|
||||||
extern bool failedOnMissingInclude;
|
extern bool failedOnMissingInclude;
|
||||||
extern bool generatePhonyDeps;
|
extern bool generatePhonyDeps;
|
||||||
|
|||||||
20
man/rgbasm.1
20
man/rgbasm.1
@@ -14,6 +14,7 @@
|
|||||||
.Op Fl g Ar chars
|
.Op Fl g Ar chars
|
||||||
.Op Fl I Ar path
|
.Op Fl I Ar path
|
||||||
.Op Fl M Ar depend_file
|
.Op Fl M Ar depend_file
|
||||||
|
.Op Fl MC
|
||||||
.Op Fl MG
|
.Op Fl MG
|
||||||
.Op Fl MP
|
.Op Fl MP
|
||||||
.Op Fl MT Ar target_file
|
.Op Fl MT Ar target_file
|
||||||
@@ -114,6 +115,17 @@ Write
|
|||||||
.Xr make 1
|
.Xr make 1
|
||||||
dependencies to
|
dependencies to
|
||||||
.Ar depend_file .
|
.Ar depend_file .
|
||||||
|
.It Fl MC
|
||||||
|
To be used in conjunction with
|
||||||
|
.Fl MG .
|
||||||
|
This makes
|
||||||
|
.Nm
|
||||||
|
continue processing after a non-existent dependency file, instead of exiting.
|
||||||
|
Note that this is
|
||||||
|
.Em not
|
||||||
|
recommended if any non-existent dependencies would have influenced subsequent processing, e.g. by causing an
|
||||||
|
.Ic IF
|
||||||
|
condition to take a different branch.
|
||||||
.It Fl MG
|
.It Fl MG
|
||||||
To be used in conjunction with
|
To be used in conjunction with
|
||||||
.Fl M .
|
.Fl M .
|
||||||
@@ -126,8 +138,10 @@ or
|
|||||||
.Ic INCBIN
|
.Ic INCBIN
|
||||||
is attempted on a non-existent file, it is added as a dependency, then
|
is attempted on a non-existent file, it is added as a dependency, then
|
||||||
.Nm
|
.Nm
|
||||||
exits normally instead of erroring out.
|
exits normally or continues processing (depending on whether
|
||||||
This feature is used in automatic updating of makefiles.
|
.Fl MC
|
||||||
|
was enabled) instead of erroring out.
|
||||||
|
This feature is used in automatic updating of Makefiles.
|
||||||
.It Fl MP
|
.It Fl MP
|
||||||
When enabled, this causes a phony target to be added for each dependency other than the main file.
|
When enabled, this causes a phony target to be added for each dependency other than the main file.
|
||||||
This prevents
|
This prevents
|
||||||
@@ -269,7 +283,7 @@ Enables literally every warning.
|
|||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
The following warnings are actual warning flags; with each description, the corresponding warning flag is included.
|
The following warnings are actual warning flags; with each description, the corresponding warning flag is included.
|
||||||
Note that each of these flag also has a negation (for example,
|
Note that each of these flags also has a negation (for example,
|
||||||
.Fl Wcharmap-redef
|
.Fl Wcharmap-redef
|
||||||
enables the warning that
|
enables the warning that
|
||||||
.Fl Wno-charmap-redef
|
.Fl Wno-charmap-redef
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ void fstk_RunInclude(std::string const &path, bool preInclude) {
|
|||||||
if (!fullPath) {
|
if (!fullPath) {
|
||||||
if (generatedMissingIncludes && !preInclude) {
|
if (generatedMissingIncludes && !preInclude) {
|
||||||
// LCOV_EXCL_START
|
// LCOV_EXCL_START
|
||||||
if (verbose) {
|
if (verbose && !continueAfterMissingIncludes) {
|
||||||
printf("Aborting (-MG) on INCLUDE file '%s' (%s)\n", path.c_str(), strerror(errno));
|
printf("Aborting (-MG) on INCLUDE file '%s' (%s)\n", path.c_str(), strerror(errno));
|
||||||
}
|
}
|
||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "asm/warning.hpp"
|
#include "asm/warning.hpp"
|
||||||
|
|
||||||
FILE *dependFile = nullptr; // -M
|
FILE *dependFile = nullptr; // -M
|
||||||
|
bool continueAfterMissingIncludes = false; // -MC
|
||||||
bool generatedMissingIncludes = false; // -MG
|
bool generatedMissingIncludes = false; // -MG
|
||||||
bool generatePhonyDeps = false; // -MP
|
bool generatePhonyDeps = false; // -MP
|
||||||
std::string targetFileName; // -MQ, -MT
|
std::string targetFileName; // -MQ, -MT
|
||||||
@@ -70,6 +71,7 @@ static option const longopts[] = {
|
|||||||
{"help", no_argument, nullptr, 'h'},
|
{"help", no_argument, nullptr, 'h'},
|
||||||
{"include", required_argument, nullptr, 'I'},
|
{"include", required_argument, nullptr, 'I'},
|
||||||
{"dependfile", required_argument, nullptr, 'M'},
|
{"dependfile", required_argument, nullptr, 'M'},
|
||||||
|
{"MC", no_argument, &depType, 'C'},
|
||||||
{"MG", no_argument, &depType, 'G'},
|
{"MG", no_argument, &depType, 'G'},
|
||||||
{"MP", no_argument, &depType, 'P'},
|
{"MP", no_argument, &depType, 'P'},
|
||||||
{"MQ", required_argument, &depType, 'Q'},
|
{"MQ", required_argument, &depType, 'Q'},
|
||||||
@@ -91,7 +93,7 @@ static option const longopts[] = {
|
|||||||
static void printUsage() {
|
static void printUsage() {
|
||||||
fputs(
|
fputs(
|
||||||
"Usage: rgbasm [-EhVvw] [-b chars] [-D name[=value]] [-g chars] [-I path]\n"
|
"Usage: rgbasm [-EhVvw] [-b chars] [-D name[=value]] [-g chars] [-I path]\n"
|
||||||
" [-M depend_file] [-MG] [-MP] [-MT target_file] [-MQ target_file]\n"
|
" [-M depend_file] [-MC] [-MG] [-MP] [-MT target_file] [-MQ target_file]\n"
|
||||||
" [-o out_file] [-P include_file] [-p pad_value] [-Q precision]\n"
|
" [-o out_file] [-P include_file] [-p pad_value] [-Q precision]\n"
|
||||||
" [-r depth] [-s features:state_file] [-W warning] [-X max_errors]\n"
|
" [-r depth] [-s features:state_file] [-W warning] [-X max_errors]\n"
|
||||||
" <file>\n"
|
" <file>\n"
|
||||||
@@ -372,6 +374,10 @@ int main(int argc, char *argv[]) {
|
|||||||
// Long-only options
|
// Long-only options
|
||||||
case 0:
|
case 0:
|
||||||
switch (depType) {
|
switch (depType) {
|
||||||
|
case 'C':
|
||||||
|
continueAfterMissingIncludes = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'G':
|
case 'G':
|
||||||
generatedMissingIncludes = true;
|
generatedMissingIncludes = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1137,7 +1137,7 @@ export_def:
|
|||||||
include:
|
include:
|
||||||
label POP_INCLUDE string endofline {
|
label POP_INCLUDE string endofline {
|
||||||
fstk_RunInclude($3, false);
|
fstk_RunInclude($3, false);
|
||||||
if (failedOnMissingInclude) {
|
if (failedOnMissingInclude && !continueAfterMissingIncludes) {
|
||||||
YYACCEPT;
|
YYACCEPT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1146,19 +1146,19 @@ include:
|
|||||||
incbin:
|
incbin:
|
||||||
POP_INCBIN string {
|
POP_INCBIN string {
|
||||||
sect_BinaryFile($2, 0);
|
sect_BinaryFile($2, 0);
|
||||||
if (failedOnMissingInclude) {
|
if (failedOnMissingInclude && !continueAfterMissingIncludes) {
|
||||||
YYACCEPT;
|
YYACCEPT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| POP_INCBIN string COMMA iconst {
|
| POP_INCBIN string COMMA iconst {
|
||||||
sect_BinaryFile($2, $4);
|
sect_BinaryFile($2, $4);
|
||||||
if (failedOnMissingInclude) {
|
if (failedOnMissingInclude && !continueAfterMissingIncludes) {
|
||||||
YYACCEPT;
|
YYACCEPT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| POP_INCBIN string COMMA iconst COMMA iconst {
|
| POP_INCBIN string COMMA iconst COMMA iconst {
|
||||||
sect_BinaryFileSlice($2, $4, $6);
|
sect_BinaryFileSlice($2, $4, $6);
|
||||||
if (failedOnMissingInclude) {
|
if (failedOnMissingInclude && !continueAfterMissingIncludes) {
|
||||||
YYACCEPT;
|
YYACCEPT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -911,7 +911,7 @@ void sect_BinaryFile(std::string const &name, int32_t startPos) {
|
|||||||
if (!file) {
|
if (!file) {
|
||||||
if (generatedMissingIncludes) {
|
if (generatedMissingIncludes) {
|
||||||
// LCOV_EXCL_START
|
// LCOV_EXCL_START
|
||||||
if (verbose) {
|
if (verbose && !continueAfterMissingIncludes) {
|
||||||
printf("Aborting (-MG) on INCBIN file '%s' (%s)\n", name.c_str(), strerror(errno));
|
printf("Aborting (-MG) on INCBIN file '%s' (%s)\n", name.c_str(), strerror(errno));
|
||||||
}
|
}
|
||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
@@ -976,7 +976,7 @@ void sect_BinaryFileSlice(std::string const &name, int32_t startPos, int32_t len
|
|||||||
if (!file) {
|
if (!file) {
|
||||||
if (generatedMissingIncludes) {
|
if (generatedMissingIncludes) {
|
||||||
// LCOV_EXCL_START
|
// LCOV_EXCL_START
|
||||||
if (verbose) {
|
if (verbose && !continueAfterMissingIncludes) {
|
||||||
printf("Aborting (-MG) on INCBIN file '%s' (%s)\n", name.c_str(), strerror(errno));
|
printf("Aborting (-MG) on INCBIN file '%s' (%s)\n", name.c_str(), strerror(errno));
|
||||||
}
|
}
|
||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
|
|||||||
13
test/asm/continues-after-missing-include/a.asm
Normal file
13
test/asm/continues-after-missing-include/a.asm
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
PUSHC
|
||||||
|
PUSHO
|
||||||
|
PUSHS
|
||||||
|
SECTION "test", WRAM0
|
||||||
|
UNION
|
||||||
|
INCLUDE "nonexistent1.inc"
|
||||||
|
WARN "still going!"
|
||||||
|
INCLUDE "nonexistent2.inc"
|
||||||
|
WARN "and going!"
|
||||||
|
ENDU
|
||||||
|
POPS
|
||||||
|
POPO
|
||||||
|
POPC
|
||||||
4
test/asm/continues-after-missing-include/a.err
Normal file
4
test/asm/continues-after-missing-include/a.err
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
warning: continues-after-missing-include/a.asm(7): [-Wuser]
|
||||||
|
still going!
|
||||||
|
warning: continues-after-missing-include/a.asm(9): [-Wuser]
|
||||||
|
and going!
|
||||||
3
test/asm/continues-after-missing-include/a.out
Normal file
3
test/asm/continues-after-missing-include/a.out
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
a.o: continues-after-missing-include/a.asm
|
||||||
|
a.o: nonexistent1.inc
|
||||||
|
a.o: nonexistent2.inc
|
||||||
@@ -103,7 +103,7 @@ for i in *.asm notexist.asm; do
|
|||||||
desired_errput="$gb"
|
desired_errput="$gb"
|
||||||
# Escape regex metacharacters
|
# Escape regex metacharacters
|
||||||
subst="$(printf '%s\n' "$i" | sed 's:[][\/.^$*]:\\&:g')"
|
subst="$(printf '%s\n' "$i" | sed 's:[][\/.^$*]:\\&:g')"
|
||||||
# Replace the file name with a dash to match changed output
|
# Replace the file name with "<stdin>" to match changed output
|
||||||
sed "s/$subst/<stdin>/g" "$desired_outname" >"$desired_output"
|
sed "s/$subst/<stdin>/g" "$desired_outname" >"$desired_output"
|
||||||
sed "s/$subst/<stdin>/g" "$desired_errname" >"$desired_errput"
|
sed "s/$subst/<stdin>/g" "$desired_errname" >"$desired_errput"
|
||||||
fi
|
fi
|
||||||
@@ -135,6 +135,33 @@ done
|
|||||||
|
|
||||||
# These tests do their own thing
|
# These tests do their own thing
|
||||||
|
|
||||||
|
i="continues-after-missing-include"
|
||||||
|
RGBASMFLAGS="-Weverything -M - -MG -MC"
|
||||||
|
# Piping the .asm file to rgbasm would not make sense for dependency generation,
|
||||||
|
# so just test the normal variant
|
||||||
|
(( tests++ ))
|
||||||
|
echo "${bold}${green}${i%.asm}...${rescolors}${resbold}"
|
||||||
|
"$RGBASM" $RGBASMFLAGS -o "$o" "$i"/a.asm >"$output" 2>"$errput"
|
||||||
|
fixed_output="$input"
|
||||||
|
if which cygpath &>/dev/null; then
|
||||||
|
# MinGW needs the Windows path substituted but with forward slash separators;
|
||||||
|
# Cygwin has `cygpath` but just needs the original path substituted.
|
||||||
|
subst1="$(printf '%s\n' "$o" | sed 's:[][\/.^$*]:\\&:g')"
|
||||||
|
subst2="$(printf '%s\n' "$(cygpath -w "$o")" | sed -e 's:\\:/:g' -e 's:[][\/.^$*]:\\&:g')"
|
||||||
|
sed -e "s/$subst1/a.o/g" -e "s/$subst2/a.o/g" "$output" >"$fixed_output"
|
||||||
|
else
|
||||||
|
subst="$(printf '%s\n' "$o" | sed 's:[][\/.^$*]:\\&:g')"
|
||||||
|
sed "s/$subst/a.o/g" "$output" >"$fixed_output"
|
||||||
|
fi
|
||||||
|
tryDiff "$i"/a.out "$fixed_output" out
|
||||||
|
our_rc=$?
|
||||||
|
tryDiff "$i"/a.err "$errput" err
|
||||||
|
(( our_rc = our_rc || $? ))
|
||||||
|
(( rc = rc || our_rc ))
|
||||||
|
if [[ $our_rc -ne 0 ]]; then
|
||||||
|
(( failed++ ))
|
||||||
|
fi
|
||||||
|
|
||||||
i="state-file"
|
i="state-file"
|
||||||
if which cygpath &>/dev/null; then
|
if which cygpath &>/dev/null; then
|
||||||
# MinGW translates path names before passing them as command-line arguments,
|
# MinGW translates path names before passing them as command-line arguments,
|
||||||
|
|||||||
Reference in New Issue
Block a user