[git commit master 1/1] build system: do not rebuild ash and hush on any change to any .c file

Denys Vlasenko vda.linux at googlemail.com
Sat Jun 26 00:40:08 UTC 2010


commit: http://git.busybox.net/busybox/commit/?id=1fcbff2fac490f5665fc1ed13ddad766a8879f3b
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 applets/Kbuild.src      |    2 +-
 applets/applet_tables.c |   24 ++++++++++++++++++++++--
 libbb/appletlib.c       |    2 +-
 shell/ash.c             |    4 +---
 shell/hush.c            |    4 +---
 5 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/applets/Kbuild.src b/applets/Kbuild.src
index e3bac96..31fee8d 100644
--- a/applets/Kbuild.src
+++ b/applets/Kbuild.src
@@ -38,7 +38,7 @@ include/usage_compressed.h: applets/usage $(srctree_slash)applets/usage_compress
 	$(call cmd,gen_usage_compressed)
 
 quiet_cmd_gen_applet_tables = GEN     include/applet_tables.h
-      cmd_gen_applet_tables = applets/applet_tables include/applet_tables.h
+      cmd_gen_applet_tables = applets/applet_tables include/applet_tables.h include/NUM_APPLETS.h
 
 include/applet_tables.h: applets/applet_tables
 	$(call cmd,gen_applet_tables)
diff --git a/applets/applet_tables.c b/applets/applet_tables.c
index e48be46..338dc20 100644
--- a/applets/applet_tables.c
+++ b/applets/applet_tables.c
@@ -79,7 +79,7 @@ int main(int argc, char **argv)
 	}
 	printf("\n");
 
-	printf("#ifndef SKIP_definitions\n");
+	//printf("#ifndef SKIP_definitions\n");
 	printf("const char applet_names[] ALIGN1 = \"\"\n");
 	for (i = 0; i < NUM_APPLETS; i++) {
 		printf("\"%s\" \"\\0\"\n", applets[i].name);
@@ -123,9 +123,29 @@ int main(int argc, char **argv)
 	}
 	printf("};\n");
 #endif
-	printf("#endif /* SKIP_definitions */\n");
+	//printf("#endif /* SKIP_definitions */\n");
 	printf("\n");
 	printf("#define MAX_APPLET_NAME_LEN %u\n", MAX_APPLET_NAME_LEN);
 
+	if (argv[2]) {
+		char line_old[80];
+		char line_new[80];
+		FILE *fp;
+
+		line_old[0] = 0;
+		fp = fopen(argv[2], "r");
+		if (fp) {
+			fgets(line_old, sizeof(line_old), fp);
+			fclose(fp);
+		}
+		sprintf(line_new, "#define NUM_APPLETS %u\n", NUM_APPLETS);
+		if (strcmp(line_old, line_new) != 0) {
+			fp = fopen(argv[2], "w");
+			if (!fp)
+				return 1;
+			fputs(line_new, fp);
+		}
+	}
+
 	return 0;
 }
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index f3d5301..58f1a94 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -61,7 +61,7 @@
 static const char usage_messages[] ALIGN1 = UNPACKED_USAGE;
 #else
 # define usage_messages 0
-#endif /* SHOW_USAGE */
+#endif
 
 #if ENABLE_FEATURE_COMPRESS_USAGE
 
diff --git a/shell/ash.c b/shell/ash.c
index 1f8f90a..cfd8154 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -50,9 +50,7 @@
 # define CLEAR_RANDOM_T(rnd) ((void)0)
 #endif
 
-#define SKIP_definitions 1
-#include "applet_tables.h"
-#undef SKIP_definitions
+#include "NUM_APPLETS.h"
 #if NUM_APPLETS == 1
 /* STANDALONE does not make sense, and won't compile */
 # undef CONFIG_FEATURE_SH_STANDALONE
diff --git a/shell/hush.c b/shell/hush.c
index e64c923..29ff3c4 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -128,9 +128,7 @@
 # define USE_FOR_MMU(...)
 #endif
 
-#define SKIP_definitions 1
-#include "applet_tables.h"
-#undef SKIP_definitions
+#include "NUM_APPLETS.h"
 #if NUM_APPLETS == 1
 /* STANDALONE does not make sense, and won't compile */
 # undef CONFIG_FEATURE_SH_STANDALONE
-- 
1.7.1



More information about the busybox-cvs mailing list