diff lwasm/main.c @ 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 e27279180a73
children
line wrap: on
line diff
--- 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);