# HG changeset patch # User lost # Date 1261815875 0 # Node ID c79b3c88adbc3e211a2b4fcc0ba86013c1f7a882 # Parent 1bdb4e256fc9b38e564a7f4ea14e5ee40b6a430d Added --depend option to generate a list of dependencies diff -r 1bdb4e256fc9 -r c79b3c88adbc ChangeLog --- a/ChangeLog Sat Dec 26 02:36:43 2009 +0000 +++ b/ChangeLog Sat Dec 26 08:24:35 2009 +0000 @@ -11,6 +11,11 @@ Also, the software affected may follow in []. +Version 2.7 + +[+] Added ability to generate a list of dependencies (any file referenced + using "include" or "includebin", including sub-includes) [LWASM] + Version 2.6.1 [b] Fixed problem with sizeof{} resolution causing segfaults [LWASM] diff -r 1bdb4e256fc9 -r c79b3c88adbc configure.ac --- a/configure.ac Sat Dec 26 02:36:43 2009 +0000 +++ b/configure.ac Sat Dec 26 08:24:35 2009 +0000 @@ -1,4 +1,4 @@ -AC_INIT([LWTOOLS], [2.6-pre], [lost@l-w.ca]) +AC_INIT([LWTOOLS], [2.7-pre], [lost@l-w.ca]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_PROG_CC gl_EARLY diff -r 1bdb4e256fc9 -r c79b3c88adbc lwasm/lwasm.h --- a/lwasm/lwasm.h Sat Dec 26 02:36:43 2009 +0000 +++ b/lwasm/lwasm.h Sat Dec 26 08:24:35 2009 +0000 @@ -202,7 +202,8 @@ int nextcontext; // next context number int skiplines; // number of lines to skip int instruct; // are we currently in a structure def? - + int deptrack; // are we doing dependency tracking? + // items used only for the "object" target sectiontab_t *sections; // pointer to section table sectiontab_t *csect; // current section - NULL if not in one @@ -219,6 +220,9 @@ char **includedirs; // include path int nincludedirs; // number of entries in include path + + int nincfiles; // number of included files + char **incfiles; // included files } asmstate_t; // do not rewrite XXX,r to ,r if XXX evaluates to 0 diff -r 1bdb4e256fc9 -r c79b3c88adbc lwasm/main.c --- a/lwasm/main.c Sat Dec 26 02:36:43 2009 +0000 +++ b/lwasm/main.c Sat Dec 26 08:24:35 2009 +0000 @@ -91,6 +91,11 @@ // proprietary object format as -> outformat = OUTPUT_OBJ; break; + + case 0x101: + // dependency tracking + as -> deptrack = 1; + break; case 'f': // output format @@ -166,6 +171,8 @@ "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" }, { "pragma", 'p', "PRAGMA", 0, "Set an assembler pragma to any value understood by the \"pragma\" pseudo op"}, { "6809", '9', 0, 0, @@ -221,7 +228,19 @@ lwasm_list(&asmstate); // now write the code out to the output file - lwasm_output(&asmstate); + if (asmstate.deptrack) + { + int i; + // list the files read (on includes) + for (i = 0; i < asmstate.nincfiles; i++) + { + printf("%s\n", asmstate.incfiles[i]); + } + } + else + { + lwasm_output(&asmstate); + } if (asmstate.errorcount > 0) exit(1); diff -r 1bdb4e256fc9 -r c79b3c88adbc lwasm/pseudo.c --- a/lwasm/pseudo.c Sat Dec 26 02:36:43 2009 +0000 +++ b/lwasm/pseudo.c Sat Dec 26 08:24:35 2009 +0000 @@ -168,7 +168,8 @@ { register_error(as, l, 1, "File include error (%s)", fn); } - lwasm_free(fn); + as -> incfiles = lwasm_realloc(as -> incfiles, sizeof(char *) * (as -> nincfiles + 1)); + as -> incfiles[as -> nincfiles++] = fn; } /* @@ -226,7 +227,8 @@ } // don't need fn any more - lwasm_free(fn); + as -> incfiles = lwasm_realloc(as -> incfiles, sizeof(char *) * (as -> nincfiles + 1)); + as -> incfiles[as -> nincfiles++] = fn; // read the contents of the file and "emit()" it while (!feof(f) && !ferror(f))