changeset 261:c79b3c88adbc 2.x

Added --depend option to generate a list of dependencies
author lost
date Sat, 26 Dec 2009 08:24:35 +0000
parents 1bdb4e256fc9
children 6d09310438a4
files ChangeLog configure.ac lwasm/lwasm.h lwasm/main.c lwasm/pseudo.c
diffstat 5 files changed, 35 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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]
--- 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
--- 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
--- 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);
--- 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))