aboutsummaryrefslogtreecommitdiff
path: root/scripts/make.sh
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-12-13 16:52:26 -0600
committerRob Landley <rob@landley.net>2015-12-13 16:52:26 -0600
commitf96bb3d8e7ec3882c70b861b998d8573083ffe55 (patch)
treefdf93b80adb5dcbf23ce68202abe5da6ce6c66b7 /scripts/make.sh
parentfc7543b7f63c159d966ca6b71caf17f877eae985 (diff)
downloadtoybox-f96bb3d8e7ec3882c70b861b998d8573083ffe55.tar.gz
Start of TAGGED_ARRAY() infrastructure.
This lets you have struct arrays with a string as the first member, ala: struct {char *name; int x, y} blah thingy[] = TAGGED_ARRAY(BLAH, {"one", 1, 2}, {"two", 3, 4}, {"three", 5, 6} ); And it produces #defines for the array index of each, ala: #define BLAH_one 0 #define BLAH_two 1 #define BLAH_three 2 So you can use thingy[BLAH_two].x and still reorder the elements at will. Note: if you screw up the array initializers, temporarily replace TAGGED_ARRAY(BLAH, with { and the ); with }; and the compiler will give you better error messages. (With the macro the compiler reports errors on the TAGGED_ARRAY line, not where the comma is missing in its contents.) Currently the TAGGED_ARRAY( and ); must be on their own lines, and the { and start of each attached string must be on the same line.
Diffstat (limited to 'scripts/make.sh')
-rwxr-xr-xscripts/make.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/scripts/make.sh b/scripts/make.sh
index 3dd4f90c..e1bc399a 100755
--- a/scripts/make.sh
+++ b/scripts/make.sh
@@ -210,6 +210,19 @@ then
) > generated/globals.h
fi
+if [ generated/mktags -ot scripts/mktags.c ]
+then
+ do_loudly $HOSTCC scripts/mktags.c -o generated/mktags || exit 1
+fi
+
+if isnewer generated/tags.h toys
+then
+ echo -n "generated/tags.h "
+
+ sed -n '/TAGGED_ARRAY(/,/^)/{s/.*TAGGED_ARRAY[(]\([^,]*\),/\1/;p}' \
+ toys/*/*.c | generated/mktags > generated/tags.h
+fi
+
echo "generated/help.h"
if [ generated/config2help -ot scripts/config2help.c ]
then