Tweaks to build process for embedded scripts
authorRon Yorston <rmy@pobox.com>
Wed, 21 Nov 2018 10:11:01 +0000 (10:11 +0000)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 27 Nov 2018 09:38:10 +0000 (10:38 +0100)
- Force a rebuild if a script in applets_sh is changed.

- Move the dummy usage messages for custom applets to usage.h and
  change the name from 'dummy' to 'scripted'.

- Hide an error from gen_build_files.sh if an embed directory exists
  but is empty.

- Tidy up embedded_scripts script.

v2: Remove a couple of unnecessary tests in embedded_scripts, as
    pointed out by Xabier Oneca.
    Drop the stripping of comments.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Makefile
include/applets.src.h
include/usage.src.h
scripts/embedded_scripts
scripts/gen_build_files.sh

index 4b5a01df92ca7103ba74a95f064289d35758e3f1..f0b4da234d74239de32b8c67412c57d5ec5ba235 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -853,7 +853,7 @@ quiet_cmd_split_autoconf   = SPLIT   include/autoconf.h -> include/config/*
 quiet_cmd_gen_embedded_scripts = GEN     include/embedded_scripts.h
       cmd_gen_embedded_scripts = $(srctree)/scripts/embedded_scripts include/embedded_scripts.h $(srctree)/embed $(srctree)/applets_sh
 #bbox# piggybacked generation of few .h files
-include/config/MARKER: scripts/basic/split-include include/autoconf.h $(wildcard $(srctree)/embed/*) $(srctree)/scripts/embedded_scripts
+include/config/MARKER: scripts/basic/split-include include/autoconf.h $(wildcard $(srctree)/embed/*) $(wildcard $(srctree)/applets_sh/*) $(srctree)/scripts/embedded_scripts
        $(call cmd,split_autoconf)
        $(call cmd,gen_bbconfigopts)
        $(call cmd,gen_common_bufsiz)
index a9db5d1607f49ade1207e457d4d4adad89daf9d6..60968cec76680760bd29b539524940b8da8d582b 100644 (file)
@@ -22,12 +22,6 @@ s     - suid type:
         BB_SUID_REQUIRE or BB_SUID_MAYBE applet.
 */
 
-#define NOUSAGE_STR "\b"
-
-#define dummy_trivial_usage NOUSAGE_STR \
-
-#define dummy_full_usage "" \
-
 #if defined(PROTOTYPES)
 # define APPLET(name,l,s)                    int name##_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 # define APPLET_ODDNAME(name,main,l,s,help)  int main##_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
index 00369dfb3e0d1993fa46e969e43252f2ddb75069..d22efd3baeb632df03693fe7c53c31a1c48cdf59 100644 (file)
@@ -14,6 +14,9 @@
 
 #define NOUSAGE_STR "\b"
 
+#define scripted_trivial_usage NOUSAGE_STR
+#define scripted_full_usage ""
+
 #if !ENABLE_USE_BB_CRYPT || ENABLE_USE_BB_CRYPT_SHA
 # define CRYPT_METHODS_HELP_STR "des,md5,sha256/512" \
        " (default "CONFIG_FEATURE_DEFAULT_PASSWD_ALGO")"
index c2e7c6961968b363af608c09fbb27531fc02635c..86ad44d1d68d451547edc567114cc0ccbf6ad00b 100755 (executable)
@@ -81,21 +81,15 @@ exec >"$target.$$"
 if [ $n -ne 0 ]
 then
        printf '#ifdef DEFINE_SCRIPT_DATA\n'
-       if [ $n -ne 0 ]
-       then
-               printf 'const uint16_t applet_numbers[] = {\n'
-               for i in $custom_scripts $applet_scripts
-               do
-                       # TODO support applets with names including invalid characters
-                       printf '\tAPPLET_NO_%s,\n' $i
-               done
-               printf '};\n'
-       fi
+       printf 'const uint16_t applet_numbers[] = {\n'
+       for i in $custom_scripts $applet_scripts
+       do
+               # TODO support applets with names including invalid characters
+               printf '\tAPPLET_NO_%s,\n' $i
+       done
+       printf '};\n'
        printf '#else\n'
-       if [ $n -ne 0 ]
-       then
-               printf 'extern const uint16_t applet_numbers[];\n'
-       fi
+       printf 'extern const uint16_t applet_numbers[];\n'
        printf '#endif\n'
 fi
 
index 64e4bffa941c1acd57f5c57bb8ef225e3170c947..362632df3c1ae0e0f920b4b25ef4b2129d8a3291 100755 (executable)
@@ -23,9 +23,9 @@ custom_scripts()
        custom_loc="$1"
        if [ -d "$custom_loc" ]
        then
-               for i in $(cd "$custom_loc"; ls *)
+               for i in $(cd "$custom_loc"; ls * 2>/dev/null)
                do
-                       printf "APPLET_SCRIPTED(%s, scripted, BB_DIR_USR_BIN, BB_SUID_DROP, dummy)\n" $i;
+                       printf "APPLET_SCRIPTED(%s, scripted, BB_DIR_USR_BIN, BB_SUID_DROP, scripted)\n" $i;
                done
        fi
 }