aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2008-01-20 17:25:44 -0600
committerRob Landley <rob@landley.net>2008-01-20 17:25:44 -0600
commitb1aaba1fc8176ac0b7c202a664d2554aa0967116 (patch)
tree7bbd14f5dd2413a6b913ea04b0bdf746a2d5b1fb /scripts
parenteb9b8da0698aacd14f5aa0879d2a8e390c0c6c13 (diff)
downloadtoybox-b1aaba1fc8176ac0b7c202a664d2554aa0967116.tar.gz
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
macros in each C file, and making generated/globals.h from that. Rename "toy" to "this" along the way to avoid toy/toys confusion.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/install.c2
-rwxr-xr-xscripts/make.sh28
2 files changed, 28 insertions, 2 deletions
diff --git a/scripts/install.c b/scripts/install.c
index 5564fa50..317b180c 100644
--- a/scripts/install.c
+++ b/scripts/install.c
@@ -14,7 +14,7 @@
// Populate toy_list[].
struct toy_list toy_list[] = {
-#include "toys/toylist.h"
+#include "generated/newtoys.h"
};
#define TOY_LIST_LEN (sizeof(toy_list)/sizeof(struct toy_list))
diff --git a/scripts/make.sh b/scripts/make.sh
index b5300d38..08333959 100755
--- a/scripts/make.sh
+++ b/scripts/make.sh
@@ -4,9 +4,11 @@
source ./configure
-echo "Extract configuration information from toys/*.c files."
+echo "Extract configuration information from toys/*.c files..."
scripts/genconfig.sh
+echo "Generate headers from toys/*.h..."
+
# Create a list of all the applets toybox can provide. Note that the first
# entry is out of order on purpose (the toybox multiplexer applet must be the
# first element of the array). The rest must be sorted in alphabetical order
@@ -22,6 +24,30 @@ function newtoys()
echo "NEWTOY(toybox, NULL, 0)" > generated/newtoys.h
newtoys | sort >> generated/newtoys.h
+# Extract global structure definitions from toys/*.c
+
+function getglobals()
+{
+ for i in toys/*.c
+ do
+ NAME="$(echo $i | sed 's@toys/\(.*\)\.c@\1@')"
+
+ echo -e "// $i\n"
+ sed -n -e '/^DEFINE_GLOBALS(/,/^)/b got;b;:got' \
+ -e 's/^DEFINE_GLOBALS(/struct '"$NAME"'_data {/' \
+ -e 's/^)/};/' -e 'p' $i
+ done
+}
+
+GLOBSTRUCT="$(getglobals)"
+(
+ echo "$GLOBSTRUCT"
+ echo
+ echo "extern union global_union {"
+ echo "$GLOBSTRUCT" | sed -n 's/struct \(.*\)_data {/ struct \1_data \1;/p'
+ echo "} this;"
+) > generated/globals.h
+
# Only recreate generated/help.h if python is installed
if [ ! -z "$(which python)" ] && [ ! -z "$(grep 'CONFIG_HELP=y' .config)" ]
then