You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/05/24 14:27:07 UTC

[incubator-nuttx-apps] branch master updated: build: Remove the duplicated mksymtab.sh

This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new d03ff1b  build: Remove the duplicated mksymtab.sh
d03ff1b is described below

commit d03ff1bde61cb6c2f0e96a5e014077909c700d75
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sat May 23 20:46:57 2020 +0800

    build: Remove the duplicated mksymtab.sh
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 Makefile                                    |  2 +-
 examples/elf/tests/Makefile                 |  2 +-
 examples/elf/tests/mksymtab.sh              | 50 ------------------
 examples/module/drivers/Makefile            |  2 +-
 examples/module/drivers/mksymtab.sh         | 50 ------------------
 examples/nxflat/tests/Makefile              |  2 +-
 examples/nxflat/tests/mksymtab.sh           | 46 ----------------
 examples/posix_spawn/filesystem/Makefile    |  2 +-
 examples/posix_spawn/filesystem/mksymtab.sh | 50 ------------------
 examples/sotest/lib/Makefile                |  2 +-
 examples/sotest/lib/mksymtab.sh             | 56 --------------------
 examples/thttpd/content/Makefile.nxflat     |  2 +-
 examples/thttpd/content/mksymtab.sh         | 45 ----------------
 tools/mksymtab.sh                           | 82 ++++++++++++++---------------
 14 files changed, 47 insertions(+), 346 deletions(-)

diff --git a/Makefile b/Makefile
index dbcc4b6..fdca285 100644
--- a/Makefile
+++ b/Makefile
@@ -94,7 +94,7 @@ else
 
 $(SYMTABSRC): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all)
 	$(Q) $(MAKE) install TOPDIR="$(TOPDIR)"
-	$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(BINDIR) $@.tmp
+	$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(BINDIR) >$@.tmp
 	$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
 
 $(SYMTABOBJ): %$(OBJEXT): %.c
diff --git a/examples/elf/tests/Makefile b/examples/elf/tests/Makefile
index 20230d8..620b83c 100644
--- a/examples/elf/tests/Makefile
+++ b/examples/elf/tests/Makefile
@@ -124,7 +124,7 @@ $(DIRLIST_SRC): install
 # Create the exported symbol table
 
 $(SYMTAB_SRC): install
-	$(Q) $(TESTS_DIR)/mksymtab.sh $(FSIMG_DIR) >$@.tmp
+	$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(FSIMG_DIR) g_elf >$@.tmp
 	$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
 
 # Clean each subdirectory
diff --git a/examples/elf/tests/mksymtab.sh b/examples/elf/tests/mksymtab.sh
deleted file mode 100755
index f422c11..0000000
--- a/examples/elf/tests/mksymtab.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env bash
-
-usage="Usage: $0 <test-dir-path>"
-
-# Check for the required ROMFS directory path
-
-dir=$1
-if [ -z "$dir" ]; then
-	echo "ERROR: Missing <test-dir-path>"
-	echo ""
-	echo $usage
-	exit 1
-fi
-
-if [ ! -d "$dir" ]; then
-	echo "ERROR: Directory $dir does not exist"
-	echo ""
-	echo $usage
-	exit 1
-fi
-
-# Extract all of the undefined symbols from the ELF files and create a
-# list of sorted, unique undefined variable names.
-
-varlist=`find ${dir} -type f -perm -a=x | xargs nm | fgrep ' U ' | sed -e "s/^[ ]*//g" | cut -d' ' -f2 | sort | uniq`
-
-# Now output the symbol table as a structure in a C source file.  All
-# undefined symbols are declared as void* types.  If the toolchain does
-# any kind of checking for function vs. data objects, then this could
-# failed
-
-echo "#include <nuttx/compiler.h>"
-echo "#include <nuttx/symtab.h>"
-echo ""
-
-for var in $varlist; do
-	echo "extern void *${var};"
-done
-
-echo ""
-echo "const struct symtab_s g_elf_exports[] = "
-echo "{"
-
-for var in $varlist; do
-	echo "  {\"${var}\", &${var}},"
-done
-
-echo "};"
-echo ""
-echo "const int g_elf_nexports = sizeof(g_elf_exports) / sizeof(struct symtab_s);"
diff --git a/examples/module/drivers/Makefile b/examples/module/drivers/Makefile
index 5e20eaf..756eaba 100644
--- a/examples/module/drivers/Makefile
+++ b/examples/module/drivers/Makefile
@@ -107,7 +107,7 @@ endif
 # Create the exported symbol table
 
 $(SYMTAB_SRC): install
-	$(Q) $(DRIVER_DIR)/mksymtab.sh $(FSROOT_DIR) >$@.tmp
+	$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(FSROOT_DIR) g_mod >$@.tmp
 	$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
 
 # Copy the symbol table into the kernel pass1/ build directory
diff --git a/examples/module/drivers/mksymtab.sh b/examples/module/drivers/mksymtab.sh
deleted file mode 100755
index 77ef4dd..0000000
--- a/examples/module/drivers/mksymtab.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env bash
-
-usage="Usage: $0 <test-dir-path>"
-
-# Check for the required ROMFS directory path
-
-dir=$1
-if [ -z "$dir" ]; then
-	echo "ERROR: Missing <test-dir-path>"
-	echo ""
-	echo $usage
-	exit 1
-fi
-
-if [ ! -d "$dir" ]; then
-	echo "ERROR: Directory $dir does not exist"
-	echo ""
-	echo $usage
-	exit 1
-fi
-
-# Extract all of the undefined symbols from the MODULE files and create a
-# list of sorted, unique undefined variable names.
-
-varlist=`find ${dir} -type f -perm -a=x | xargs nm | fgrep ' U ' | sed -e "s/^[ ]*//g" | cut -d' ' -f2 | sort | uniq`
-
-# Now output the symbol table as a structure in a C source file.  All
-# undefined symbols are declared as void* types.  If the toolchain does
-# any kind of checking for function vs. data objects, then this could
-# failed
-
-echo "#include <nuttx/compiler.h>"
-echo "#include <nuttx/symtab.h>"
-echo ""
-
-for var in $varlist; do
-	echo "extern void *${var};"
-done
-
-echo ""
-echo "const struct symtab_s g_mod_exports[] = "
-echo "{"
-
-for var in $varlist; do
-	echo "  {\"${var}\", &${var}},"
-done
-
-echo "};"
-echo ""
-echo "const int g_mod_nexports = sizeof(g_mod_exports) / sizeof(struct symtab_s);"
diff --git a/examples/nxflat/tests/Makefile b/examples/nxflat/tests/Makefile
index 2c79cb7..0d125aa 100644
--- a/examples/nxflat/tests/Makefile
+++ b/examples/nxflat/tests/Makefile
@@ -88,7 +88,7 @@ $(DIRLIST_SRC): install
 # Create the exported symbol table list from the derived *-thunk.S files
 
 $(SYMTAB_SRC): install
-	$(Q) $(TESTS_DIR)/mksymtab.sh $(ROMFS_DIR) >$@.tmp
+	$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(ROMFS_DIR) g_nxflat >$@.tmp
 	$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
 
 # Clean each subdirectory
diff --git a/examples/nxflat/tests/mksymtab.sh b/examples/nxflat/tests/mksymtab.sh
deleted file mode 100755
index 0f6ab87..0000000
--- a/examples/nxflat/tests/mksymtab.sh
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/env bash
-
-usage="Usage: $0 <test-dir-path>"
-
-dir=$1
-if [ -z "$dir" ]; then
-	echo "ERROR: Missing <test-dir-path>"
-	echo ""
-	echo $usage
-	exit 1
-fi
-
-if [ ! -d "$dir" ]; then
-	echo "ERROR: Directory $dir does not exist"
-	echo ""
-	echo $usage
-	exit 1
-fi
-
-varlist=`find $dir -name "*-thunk.S"| xargs grep -h asciz | cut -f3 | sort | uniq`
-
-# Now output the symbol table as a structure in a C source file.  All
-# undefined symbols are declared as void* types.  If the toolchain does
-# any kind of checking for function vs. data objects, then this could
-# failed
-
-echo "#include <nuttx/compiler.h>"
-echo "#include <nuttx/symtab.h>"
-echo ""
-
-for var in $varlist; do
-	echo "extern void *${var};"
-done
-
-echo ""
-echo "const struct symtab_s g_nxflat_exports[] = "
-echo "{"
-
-for string in $varlist; do
-	var=`echo $string | sed -e "s/\"//g"`
-	echo "  {$string, $var},"
-done
-
-echo "};"
-echo ""
-echo "const int g_nxflat_nexports = sizeof(g_nxflat_exports) / sizeof(struct symtab_s);"
diff --git a/examples/posix_spawn/filesystem/Makefile b/examples/posix_spawn/filesystem/Makefile
index ae13c96..088b373 100644
--- a/examples/posix_spawn/filesystem/Makefile
+++ b/examples/posix_spawn/filesystem/Makefile
@@ -73,7 +73,7 @@ $(ROMFS_SRC): $(ROMFS_IMG)
 # Create the exported symbol table
 
 $(SYMTAB_SRC): $(ROMFS_IMG)
-	$(Q) $(FILESYSTEM_DIR)$(DELIM)mksymtab.sh $(ROMFS_DIR) >$@.tmp
+	$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(ROMFS_DIR) g_spawn >$@.tmp
 	$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
 
 # Clean each subdirectory
diff --git a/examples/posix_spawn/filesystem/mksymtab.sh b/examples/posix_spawn/filesystem/mksymtab.sh
deleted file mode 100755
index 05384be..0000000
--- a/examples/posix_spawn/filesystem/mksymtab.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env bash
-
-usage="Usage: $0 <test-dir-path>"
-
-# Check for the required ROMFS directory path
-
-dir=$1
-if [ -z "$dir" ]; then
-	echo "ERROR: Missing <test-dir-path>"
-	echo ""
-	echo $usage
-	exit 1
-fi
-
-if [ ! -d "$dir" ]; then
-	echo "ERROR: Directory $dir does not exist"
-	echo ""
-	echo $usage
-	exit 1
-fi
-
-# Extract all of the undefined symbols from the ELF files and create a
-# list of sorted, unique undefined variable names.
-
-varlist=`find ${dir} -type f -perm -a=x | xargs nm | fgrep ' U ' | sed -e "s/^[ ]*//g" | cut -d' ' -f2 | sort | uniq`
-
-# Now output the symbol table as a structure in a C source file.  All
-# undefined symbols are declared as void* types.  If the toolchain does
-# any kind of checking for function vs. data objects, then this could
-# failed
-
-echo "#include <nuttx/compiler.h>"
-echo "#include <nuttx/symtab.h>"
-echo ""
-
-for var in $varlist; do
-	echo "extern void *${var};"
-done
-
-echo ""
-echo "const struct symtab_s g_spawn_exports[] = "
-echo "{"
-
-for var in $varlist; do
-	echo "  {\"${var}\", &${var}},"
-done
-
-echo "};"
-echo ""
-echo "const int g_spawn_nexports = sizeof(g_spawn_exports) / sizeof(struct symtab_s);"
diff --git a/examples/sotest/lib/Makefile b/examples/sotest/lib/Makefile
index 795a95e..8a0117c 100644
--- a/examples/sotest/lib/Makefile
+++ b/examples/sotest/lib/Makefile
@@ -84,7 +84,7 @@ endif
 # Create the exported symbol table
 
 $(SYMTAB_SRC): install
-	$(Q) $(LIB_DIR)/mksymtab.sh $(FSROOT_DIR) >$@.tmp
+	$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(FSROOT_DIR) g_sot | sed "/modprint/d" >$@.tmp
 	$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
 
 # Clean each subdirectory
diff --git a/examples/sotest/lib/mksymtab.sh b/examples/sotest/lib/mksymtab.sh
deleted file mode 100755
index 28db68f..0000000
--- a/examples/sotest/lib/mksymtab.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/env bash
-# set -x
-
-usage="Usage: $0 <test-dir-path>"
-
-# Check for the required ROMFS directory path
-
-dir=$1
-if [ -z "$dir" ]; then
-	echo "ERROR: Missing <test-dir-path>"
-	echo ""
-	echo $usage
-	exit 1
-fi
-
-if [ ! -d "$dir" ]; then
-	echo "ERROR: Directory $dir does not exist"
-	echo ""
-	echo $usage
-	exit 1
-fi
-
-# Extract all of the undefined symbols from the SOTEST files and create a
-# list of sorted, unique undefined variable names.
-
-tmplist=`find ${dir} -type f -perm -a=x | xargs nm | fgrep ' U ' | sed -e "s/^[ ]*//g" | cut -d' ' -f2 | sort | uniq`
-
-# Remove the special symbol 'modprint'.  It it is not exported by the
-# base firmware, but rather in this test from one shared library to another.
-
-varlist=`echo $tmplist | sed -e "s/modprint//g"`
-
-# Now output the symbol table as a structure in a C source file.  All
-# undefined symbols are declared as void* types.  If the toolchain does
-# any kind of checking for function vs. data objects, then this could
-# fail
-
-echo "#include <nuttx/compiler.h>"
-echo "#include <nuttx/symtab.h>"
-echo ""
-
-for var in $varlist; do
-	echo "extern void *${var};"
-done
-
-echo ""
-echo "const struct symtab_s g_sot_exports[] = "
-echo "{"
-
-for var in $varlist; do
-	echo "  {\"${var}\", &${var}},"
-done
-
-echo "};"
-echo ""
-echo "const int g_sot_nexports = sizeof(g_sot_exports) / sizeof(struct symtab_s);"
diff --git a/examples/thttpd/content/Makefile.nxflat b/examples/thttpd/content/Makefile.nxflat
index 9350da7..7384242 100644
--- a/examples/thttpd/content/Makefile.nxflat
+++ b/examples/thttpd/content/Makefile.nxflat
@@ -76,7 +76,7 @@ $(ROMFS_SRC): $(ROMFS_IMG)
 # Create the exported symbol table list from the derived *-thunk.S files
 
 $(SYMTAB_SRC): install
-	$(Q) $(CONTENT_DIR)/mksymtab.sh $(CONTENT_DIR) >$@.tmp
+	$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(CONTENT_DIR) g_thttpd >$@.tmp
 	$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
 
 # Nothing special needs to be done during the context phase
diff --git a/examples/thttpd/content/mksymtab.sh b/examples/thttpd/content/mksymtab.sh
deleted file mode 100755
index f9bb735..0000000
--- a/examples/thttpd/content/mksymtab.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/env bash
-
-usage="Usage: %0 <test-dir-path>"
-
-dir=$1
-if [ -z "$dir" ]; then
-	echo "ERROR: Missing <test-dir-path>"
-	echo ""
-	echo $usage
-	exit 1
-fi
-
-if [ ! -d "$dir" ]; then
-	echo "ERROR: Directory $dir does not exist"
-	echo ""
-	echo $usage
-	exit 1
-fi
-
-varlist=`find $dir -name "*-thunk.S"| xargs grep -h asciz | cut -f3 | sort | uniq`
-
-# Now output the symbol table as a structure in a C source file.  All
-# undefined symbols are declared as void* types.  If the toolchain does
-# any kind of checking for function vs. data objects, then this could
-# failed
-
-echo "#include <nuttx/compiler.h>"
-echo "#include <nuttx/symtab.h>"
-echo ""
-
-for var in $varlist; do
-	echo "extern void *${var};"
-done
-
-echo ""
-echo "const struct symtab_s g_thttpd_exports[] = "
-echo "{"
-
-for string in $varlist; do
-	var=`echo $string | sed -e "s/\"//g"`
-	echo "  {$string, $var},"
-done
-
-echo "};"
-echo "const int g_thttpd_nexports = sizeof(g_thttpd_exports) / sizeof(struct symtab_s);"
diff --git a/tools/mksymtab.sh b/tools/mksymtab.sh
index c78fdea..811a886 100755
--- a/tools/mksymtab.sh
+++ b/tools/mksymtab.sh
@@ -36,7 +36,7 @@
 
 export LC_ALL=C
 
-usage="Usage: $0 <imagedirpath> <outfilepath>"
+usage="Usage: $0 <imagedirpath> [symtabprefix]"
 
 # Check for the required directory path
 
@@ -48,29 +48,19 @@ if [ -z "$dir" ]; then
   exit 1
 fi
 
-# Get the output file name
+# Get the symbol table prefix
 
-outfile=$2
-if [ -z "$outfile" ]; then
-  echo "ERROR: Missing <outfilepath>"
-  echo ""
-  echo $usage
-  exit 1
-fi
-
-rm -f $outfile
+prefix=$2
 
 # Extract all of the undefined symbols from the ELF files and create a
 # list of sorted, unique undefined variable names.
 
-execlist=`find ${dir} -type f 2>/dev/null`
-if [ ! -z "${execlist}" ]; then
-  for exec in ${execlist}; do
-    nm $exec | fgrep ' U ' | sed -e "s/^[ ]*//g" | cut -d' ' -f2  >>_tmplist
-  done
-
-  varlist=`cat _tmplist | sort - | uniq -`
-  rm -f _tmplist
+varlist=`find $dir -name *-thunk.S 2>/dev/null | xargs grep -h asciz | cut -f3 | sort | uniq`
+if [ -z "$varlist" ]; then
+  execlist=`find $dir -type f -perm -a=x 2>/dev/null`
+  if [ ! -z "$execlist" ]; then
+    varlist=`nm $execlist | fgrep ' U ' | sed -e "s/^[ ]*//g" | cut -d' ' -f2 | sort | uniq`
+  fi
 fi
 
 # Now output the symbol table as a structure in a C source file.  All
@@ -78,34 +68,42 @@ fi
 # any kind of checking for function vs. data objects, then this could
 # failed
 
-echo "#include <nuttx/compiler.h>" >$outfile
-echo "#include <nuttx/symtab.h>" >>$outfile
-echo "" >>$outfile
+echo "#include <nuttx/compiler.h>"
+echo "#include <nuttx/symtab.h>"
+echo ""
 
 for var in $varlist; do
-  echo "extern void *${var};" >>$outfile
+  echo "extern void *${var};"
 done
 
-echo "" >>$outfile
-echo "#if defined(CONFIG_EXECFUNCS_HAVE_SYMTAB)" >>$outfile
-echo "const struct symtab_s CONFIG_EXECFUNCS_SYMTAB_ARRAY[] = " >>$outfile
-echo "#elif defined(CONFIG_SYSTEM_NSH_SYMTAB)" >>$outfile
-echo "const struct symtab_s CONFIG_SYSTEM_NSH_SYMTAB_ARRAYNAME[] = " >>$outfile
-echo "#else" >>$outfile
-echo "const struct symtab_s dummy_symtab[] = " >>$outfile
-echo "#endif" >>$outfile
-echo "{" >>$outfile
+echo ""
+if [ -z "$prefix" ]; then
+  echo "#if defined(CONFIG_EXECFUNCS_HAVE_SYMTAB)"
+  echo "const struct symtab_s CONFIG_EXECFUNCS_SYMTAB_ARRAY[] = "
+  echo "#elif defined(CONFIG_SYSTEM_NSH_SYMTAB)"
+  echo "const struct symtab_s CONFIG_SYSTEM_NSH_SYMTAB_ARRAYNAME[] = "
+  echo "#else"
+  echo "const struct symtab_s dummy_symtab[] = "
+  echo "#endif"
+else
+  echo "const struct symtab_s ${prefix}_exports[] = "
+fi
+echo "{"
 
 for var in $varlist; do
-  echo "  {\"${var}\", &${var}}," >>$outfile
+  echo "  {\"${var}\", &${var}},"
 done
 
-echo "};" >>$outfile
-echo "" >>$outfile
-echo "#if defined(CONFIG_EXECFUNCS_HAVE_SYMTAB)" >>$outfile
-echo "const int CONFIG_EXECFUNCS_NSYMBOLS_VAR = sizeof(CONFIG_EXECFUNCS_SYMTAB_ARRAY) / sizeof(struct symtab_s);" >>$outfile
-echo "#elif defined(CONFIG_SYSTEM_NSH_SYMTAB)" >>$outfile
-echo "const int CONFIG_SYSTEM_NSH_SYMTAB_COUNTNAME = sizeof(CONFIG_SYSTEM_NSH_SYMTAB_ARRAYNAME) / sizeof(struct symtab_s);" >>$outfile
-echo "#else" >>$outfile
-echo "const int dummy_nsymtabs = sizeof(dummy_symtab) / sizeof(struct symtab_s);" >>$outfile
-echo "#endif" >>$outfile
+echo "};"
+echo ""
+if [ -z "$prefix" ]; then
+  echo "#if defined(CONFIG_EXECFUNCS_HAVE_SYMTAB)"
+  echo "const int CONFIG_EXECFUNCS_NSYMBOLS_VAR = sizeof(CONFIG_EXECFUNCS_SYMTAB_ARRAY) / sizeof(struct symtab_s);"
+  echo "#elif defined(CONFIG_SYSTEM_NSH_SYMTAB)"
+  echo "const int CONFIG_SYSTEM_NSH_SYMTAB_COUNTNAME = sizeof(CONFIG_SYSTEM_NSH_SYMTAB_ARRAYNAME) / sizeof(struct symtab_s);"
+  echo "#else"
+  echo "const int dummy_nsymtabs = sizeof(dummy_symtab) / sizeof(struct symtab_s);"
+  echo "#endif"
+else
+  echo "const int ${prefix}_nexports = sizeof(${prefix}_exports) / sizeof(struct symtab_s);"
+fi