# HG changeset patch # User lost@l-w.ca # Date 1302652611 21600 # Node ID 1f77ae5c35908c9b7e2d745ffb16368b11d24ff2 # Parent 84eb3525184988a6da1ee36d3d72217d1059ac41 Added --dependnoerr flag to list dependencies on non-existent files without bailing out; also suppress error reports during dependency generation diff -r 84eb35251849 -r 1f77ae5c3590 lwasm/input.c --- a/lwasm/input.c Tue Apr 12 14:16:36 2011 -0600 +++ b/lwasm/input.c Tue Apr 12 17:56:51 2011 -0600 @@ -40,6 +40,8 @@ Data type for storing input buffers */ +#define IGNOREERROR (errno == ENOENT && (as -> flags & FLAG_DEPENDNOERR)) + enum input_types_e { input_type_file, // regular file, no search path @@ -179,7 +181,7 @@ /* absolute path */ IS -> data = fopen(s, "rb"); debug_message(as, 1, "Opening (abs) %s", s); - if (!IS -> data) + if (!IS -> data && !IGNOREERROR) { lw_error("Cannot open file '%s': %s", s, strerror(errno)); } @@ -218,6 +220,11 @@ lw_free(p2); lw_stringlist_next(as -> include_list); } + if (IGNOREERROR) + { + input_pushpath(as, s); + return; + } lw_error("Cannot open include file '%s': %s", s, strerror(errno)); break; @@ -312,13 +319,16 @@ for (;;) { int c, c2; - c = fgetc(IS -> data); + c = EOF; + if (IS -> data) + c = fgetc(IS -> data); if (c == EOF) { if (lbloc == 0) { struct input_stack *t; - fclose(IS -> data); + if (IS -> data) + fclose(IS -> data); lw_free(lw_stack_pop(as -> file_dir)); lw_free(IS -> filespec); t = IS -> next; diff -r 84eb35251849 -r 1f77ae5c3590 lwasm/lwasm.h --- a/lwasm/lwasm.h Tue Apr 12 14:16:36 2011 -0600 +++ b/lwasm/lwasm.h Tue Apr 12 17:56:51 2011 -0600 @@ -65,6 +65,7 @@ FLAG_LIST = 0x0001, FLAG_DEPEND = 0x0002, FLAG_SYMBOLS = 0x004, + FLAG_DEPENDNOERR = 0x0008, FLAG_NONE = 0 }; diff -r 84eb35251849 -r 1f77ae5c3590 lwasm/main.c --- a/lwasm/main.c Tue Apr 12 14:16:36 2011 -0600 +++ b/lwasm/main.c Tue Apr 12 17:56:51 2011 -0600 @@ -49,6 +49,7 @@ { "raw", 'r', 0, 0, "Generate raw binary format output, equivalent of --format=raw"}, { "obj", 0x100, 0, 0, "Generate proprietary object file format for later linking, equivalent of --format=obj" }, { "depend", 0x101, 0, 0, "Output a dependency list to stdout; do not do any actual output though assembly is completed as usual" }, + { "dependnoerr", 0x102, 0, 0, "Output a dependency list to stdout; do not do any actual output though assembly is completed as usual; don't bail on missing include files" }, { "pragma", 'p', "PRAGMA", 0, "Set an assembler pragma to any value understood by the \"pragma\" pseudo op"}, { "6809", '9', 0, 0, "Set assembler to 6809 only mode" }, { "6309", '3', 0, 0, "Set assembler to 6309 mode (default)" }, @@ -110,6 +111,10 @@ as -> flags |= FLAG_DEPEND; break; + case 0x102: + as -> flags |= FLAG_DEPEND | FLAG_DEPENDNOERR; + break; + case 'f': if (!strcasecmp(arg, "decb")) as -> output_format = OUTPUT_DECB; @@ -240,6 +245,12 @@ if (asmstate.errorcount > 0) { + if (asmstate.flags & FLAG_DEPEND) + { + // don't show errors during dependency scanning but + // stop processing immediately + break; + } lwasm_show_errors(&asmstate); exit(1); }