This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit 0c60624276ecfbe6c08e5a1930d4cde7397b0e17 Author: liuhaitao <[email protected]> AuthorDate: Thu May 14 11:32:35 2020 +0800 Update make dependency for elf/module/nxflat/posix_spawn/sotest/thttpd Update make dependency for elf/module/nxflat/posix_spawn/sotest/thttpd examples which make use of mksymtab.sh. This could avoid them built twice in 'make depend' and 'make all' which would result in file truncated build break. Now only build once by 'make all'. Change-Id: I5d8f1ebbf73e3b12d7d2118f1f51b4233d0ed007 Signed-off-by: liuhaitao <[email protected]> --- Application.mk | 2 +- examples/elf/Makefile | 17 +++++++++++++++-- examples/elf/elf_main.c | 19 +++++++++---------- examples/elf/tests/.gitignore | 6 +++--- examples/elf/tests/Makefile | 20 ++++++++++---------- examples/elf/tests/mkdirlist.sh | 7 ++----- examples/module/Makefile | 20 +++++++++++++------- examples/module/drivers/.gitignore | 4 ++-- examples/module/drivers/Makefile | 18 +++++++++--------- examples/module/module_main.c | 8 +++++--- examples/nxflat/Makefile | 7 ++++++- examples/nxflat/nxflat_main.c | 18 +++++++++++++----- examples/nxflat/tests/.gitignore | 6 +++--- examples/nxflat/tests/Makefile | 20 ++++++++++---------- examples/nxflat/tests/mkdirlist.sh | 5 +---- examples/nxflat/tests/mksymtab.sh | 20 ++++++++++++++------ examples/posix_spawn/Makefile | 5 +++-- examples/posix_spawn/filesystem/.gitignore | 2 +- examples/posix_spawn/filesystem/Makefile | 12 ++++++------ examples/posix_spawn/spawn_main.c | 5 +++-- examples/sotest/Makefile | 9 +++++++-- examples/sotest/lib/.gitignore | 2 +- examples/sotest/lib/Makefile | 12 ++++++------ examples/sotest/sotest_main.c | 6 +++++- examples/thttpd/Makefile | 10 +++++++++- examples/thttpd/content/.gitignore | 4 ++-- examples/thttpd/content/Makefile.binfs | 12 ++++++------ examples/thttpd/content/Makefile.nxflat | 18 +++++++++--------- examples/thttpd/content/mksymtab.sh | 21 ++++++++++++++------- examples/thttpd/thttpd_main.c | 20 +++++++++++++------- 30 files changed, 201 insertions(+), 134 deletions(-) diff --git a/Application.mk b/Application.mk index dafdab0..a7f768e 100644 --- a/Application.mk +++ b/Application.mk @@ -219,7 +219,7 @@ else context:: endif -.depend: Makefile $(SRCS) +.depend: Makefile $(wildcard $(SRCS)) ifeq ($(filter %$(CXXEXT),$(SRCS)),) $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(filter-out Makefile,$^) >Make.dep else diff --git a/examples/elf/Makefile b/examples/elf/Makefile index 4df948a..5bb7a5b 100644 --- a/examples/elf/Makefile +++ b/examples/elf/Makefile @@ -37,7 +37,14 @@ # ELF Example -CSRCS = symtab.c +ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y) +CSRCS = romfs.c +endif +ifeq ($(CONFIG_EXAMPLES_ELF_CROMFS),y) +CSRCS = cromfs.c +endif +CSRCS += dirlist.c +CSRCS += symtab.c MAINSRC = elf_main.c PROGNAME = elf @@ -51,7 +58,13 @@ ROOTDEPPATH := --dep-path tests VPATH += :tests -elf_main.c: build +ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y) +tests/romfs.c: build +endif +ifeq ($(CONFIG_EXAMPLES_ELF_CROMFS),y) +tests/cromfs.c: build +endif +tests/dirlist.c: build tests/symtab.c: build .PHONY: build diff --git a/examples/elf/elf_main.c b/examples/elf/elf_main.c index 5ddf81b..c6872e6 100644 --- a/examples/elf/elf_main.c +++ b/examples/elf/elf_main.c @@ -42,16 +42,6 @@ #include "platform/cxxinitialize.h" -#if defined(CONFIG_EXAMPLES_ELF_ROMFS) -# include "tests/romfs.h" -#elif defined(CONFIG_EXAMPLES_ELF_CROMFS) -# include "tests/cromfs.h" -#elif !defined(CONFIG_EXAMPLES_ELF_EXTERN) -# error "No file system selected" -#endif - -#include "tests/dirlist.h" - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -135,6 +125,15 @@ static char fullpath[128]; * Symbols from Auto-Generated Code ****************************************************************************/ +#if defined(CONFIG_EXAMPLES_ELF_ROMFS) || defined(CONFIG_EXAMPLES_ELF_CROMFS) +extern const unsigned char romfs_img[]; +extern const unsigned int romfs_img_len; +#elif !defined(CONFIG_EXAMPLES_ELF_EXTERN) +# error "No file system selected" +#endif + +extern const char *dirlist[]; + extern const struct symtab_s g_elf_exports[]; extern const int g_elf_nexports; diff --git a/examples/elf/tests/.gitignore b/examples/elf/tests/.gitignore index 43f0d5b..87cace4 100644 --- a/examples/elf/tests/.gitignore +++ b/examples/elf/tests/.gitignore @@ -1,8 +1,8 @@ /romfs -/romfs.h +/romfs.c /romfs.img /cromfs -/cromfs.h -/dirlist.h +/cromfs.c +/dirlist.c /symtab.c /varlist.tmp diff --git a/examples/elf/tests/Makefile b/examples/elf/tests/Makefile index 3bda752..16be29b 100644 --- a/examples/elf/tests/Makefile +++ b/examples/elf/tests/Makefile @@ -56,14 +56,14 @@ endif ELF_DIR = $(APPDIR)/examples/elf TESTS_DIR = $(ELF_DIR)/tests -DIRLIST_HDR = $(TESTS_DIR)/dirlist.h +DIRLIST_SRC = $(TESTS_DIR)/dirlist.c SYMTAB_SRC = $(TESTS_DIR)/symtab.c ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y) FSIMG_SUBDIR = romfs FSIMG_DIR = $(TESTS_DIR)/$(FSIMG_SUBDIR) ROMFS_IMG = $(TESTS_DIR)/romfs.img - FSIMG_HDR = $(TESTS_DIR)/romfs.h + FSIMG_SRC = $(TESTS_DIR)/romfs.c else NXTOOLDIR = $(TOPDIR)/tools GENCROMFSSRC = gencromfs.c @@ -71,7 +71,7 @@ else FSIMG_SUBDIR = cromfs FSIMG_DIR = $(TESTS_DIR)/$(FSIMG_SUBDIR) - FSIMG_HDR = $(TESTS_DIR)/cromfs.h + FSIMG_SRC = $(TESTS_DIR)/cromfs.c endif define DIR_template @@ -79,7 +79,7 @@ $(1)_$(2): +$(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" FSIMG_DIR="$(FSIMG_DIR)" CROSSDEV=$(CROSSDEV) endef -all: $(FSIMG_HDR) $(DIRLIST_HDR) $(SYMTAB_SRC) +all: $(FSIMG_SRC) $(DIRLIST_SRC) $(SYMTAB_SRC) .PHONY: all clean install $(foreach DIR, $(ALL_SUBDIRS), $(eval $(call DIR_template,$(DIR),clean))) @@ -96,10 +96,10 @@ $(ROMFS_IMG): install $(Q) genromfs -f [email protected] -d $(FSIMG_DIR) -V "ELFTEST" $(Q) $(call TESTANDREPLACEFILE, [email protected], $@) -# Create the romfs.h header file from the romfs.img file +# Create the romfs.c file from the romfs.img file -$(FSIMG_HDR): $(ROMFS_IMG) - $(Q) (cd $(TESTS_DIR); xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@) +$(FSIMG_SRC): $(ROMFS_IMG) + $(Q) (cd $(TESTS_DIR); xxd -i romfs.img | sed -e "s/^unsigned/const unsigned/g" >$@) else # Make sure that the NuttX gencromfs tool has been built @@ -109,7 +109,7 @@ $(NXTOOLDIR)/$(GENCROMFSEXE): $(NXTOOLDIR)/$(GENCROMFSSRC) # Create the cromfs.h header file from the populated cromfs directory -$(FSIMG_HDR): install $(NXTOOLDIR)/$(GENCROMFSEXE) +$(FSIMG_SRC): install $(NXTOOLDIR)/$(GENCROMFSEXE) $(Q) $(NXTOOLDIR)/$(GENCROMFSEXE) $(FSIMG_DIR) [email protected] $(Q) $(call TESTANDREPLACEFILE, [email protected], $@) @@ -117,7 +117,7 @@ endif # Create the dirlist.h header file from the file system image directory -$(DIRLIST_HDR): install +$(DIRLIST_SRC): install $(Q) $(TESTS_DIR)/mkdirlist.sh $(FSIMG_DIR) >[email protected] $(Q) $(call TESTANDREPLACEFILE, [email protected], $@) @@ -130,5 +130,5 @@ $(SYMTAB_SRC): install # Clean each subdirectory clean: $(foreach DIR, $(ALL_SUBDIRS), $(DIR)_clean) - $(Q) rm -f $(FSIMG_HDR) $(DIRLIST_HDR) $(ROMFS_IMG) $(SYMTAB_SRC) + $(Q) rm -f $(FSIMG_SRC) $(DIRLIST_SRC) $(ROMFS_IMG) $(SYMTAB_SRC) $(Q) rm -rf $(FSIMG_DIR) diff --git a/examples/elf/tests/mkdirlist.sh b/examples/elf/tests/mkdirlist.sh index f12c576..16a8033 100755 --- a/examples/elf/tests/mkdirlist.sh +++ b/examples/elf/tests/mkdirlist.sh @@ -17,10 +17,9 @@ if [ ! -d "$dir" ]; then exit 1 fi -echo "#ifndef __EXAMPLES_ELF_TESTS_DIRLIST_H" -echo "#define __EXAMPLES_ELF_TESTS_DIRLIST_H" +echo "#include <stddef.h>" echo "" -echo "static const char *dirlist[] =" +echo "const char *dirlist[] =" echo "{" for file in `ls $dir`; do @@ -29,5 +28,3 @@ done echo " NULL" echo "};" -echo "" -echo "#endif /* __EXAMPLES_ELF_TESTS_DIRLIST_H */" diff --git a/examples/module/Makefile b/examples/module/Makefile index 17d2202..e7cb349 100644 --- a/examples/module/Makefile +++ b/examples/module/Makefile @@ -44,21 +44,27 @@ MODULE = $(CONFIG_EXAMPLES_MODULE) # Module Example -MAINSRC = module_main.c - -ifeq ($(CONFIG_BUILD_FLAT),y) -CSRCS += mod_symtab.c +ifeq ($(CONFIG_EXAMPLES_MODULE_ROMFS),y) +CSRCS = romfs.c endif +ifeq ($(CONFIG_EXAMPLES_MODULE_CROMFS),y) +CSRCS = cromfs.c +endif +CSRCS += mod_symtab.c +MAINSRC = module_main.c VPATH += drivers ROOTDEPPATH += --dep-path drivers # Build targets -module_main.c: build -ifeq ($(CONFIG_BUILD_FLAT),y) -drivers/mod_symtab.c: build +ifeq ($(CONFIG_EXAMPLES_MODULE_ROMFS),y) +drivers/romfs.c: build endif +ifeq ($(CONFIG_EXAMPLES_MODULE_CROMFS),y) +drivers/cromfs.c: build +endif +drivers/mod_symtab.c: build .PHONY: build build: diff --git a/examples/module/drivers/.gitignore b/examples/module/drivers/.gitignore index b30ad41..922cf89 100644 --- a/examples/module/drivers/.gitignore +++ b/examples/module/drivers/.gitignore @@ -1,5 +1,5 @@ /fsroot -/romfs.h -/cromfs.h +/romfs.c +/cromfs.c /romfs.img /mod_symtab.c diff --git a/examples/module/drivers/Makefile b/examples/module/drivers/Makefile index bdc7770..0d20549 100644 --- a/examples/module/drivers/Makefile +++ b/examples/module/drivers/Makefile @@ -51,13 +51,13 @@ endif ifeq ($(CONFIG_EXAMPLES_MODULE_BUILTINFS),y) ifeq ($(CONFIG_EXAMPLES_MODULE_ROMFS),y) ROMFS_IMG = $(DRIVER_DIR)/romfs.img - FSIMG_HDR = $(DRIVER_DIR)/romfs.h + FSIMG_SRC = $(DRIVER_DIR)/romfs.c else ifeq ($(CONFIG_EXAMPLES_MODULE_CROMFS),y) NXTOOLDIR = $(TOPDIR)/tools GENCROMFSSRC = gencromfs.c GENCROMFSEXE = gencromfs$(EXEEXT) - FSIMG_HDR = $(DRIVER_DIR)/cromfs.h + FSIMG_SRC = $(DRIVER_DIR)/cromfs.c endif endif @@ -66,7 +66,7 @@ $(1)_$(2): +$(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" FSROOT_DIR="$(FSROOT_DIR)" CROSSDEV=$(CROSSDEV) endef -all: $(FSIMG_HDR) $(SYMTAB_SRC) $(PASS1_SYMTAB) +all: $(FSIMG_SRC) $(SYMTAB_SRC) $(PASS1_SYMTAB) .PHONY: all clean install $(foreach DIR, $(ALL_SUBDIRS), $(eval $(call DIR_template,$(DIR),clean))) @@ -84,10 +84,10 @@ $(ROMFS_IMG): install $(Q) genromfs -f [email protected] -d $(FSROOT_DIR) -V "MODULETEST" $(Q) $(call TESTANDREPLACEFILE, [email protected], $@) -# Create the romfs.h header file from the romfs.img file +# Create the romfs.c file from the romfs.img file -$(FSIMG_HDR): $(ROMFS_IMG) - $(Q) (cd $(DRIVER_DIR); xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@) +$(FSIMG_SRC): $(ROMFS_IMG) + $(Q) (cd $(DRIVER_DIR); xxd -i romfs.img | sed -e "s/^unsigned/const unsigned/g" >$@) else ifeq ($(CONFIG_EXAMPLES_MODULE_CROMFS),y) # Make sure that the NuttX gencromfs tool has been built @@ -95,9 +95,9 @@ else ifeq ($(CONFIG_EXAMPLES_MODULE_CROMFS),y) $(NXTOOLDIR)/$(GENCROMFSEXE): $(NXTOOLDIR)/$(GENCROMFSSRC) $(Q) $(MAKE) -C $(NXTOOLDIR) -f Makefile.host $(GENCROMFSEXE) -# Create the cromfs.h header file from the populated cromfs directory +# Create the cromfs.c file from the populated cromfs directory -$(FSIMG_HDR): install $(NXTOOLDIR)/$(GENCROMFSEXE) +$(FSIMG_SRC): install $(NXTOOLDIR)/$(GENCROMFSEXE) $(Q) $(NXTOOLDIR)/$(GENCROMFSEXE) $(FSIMG_DIR) [email protected] $(Q) $(call TESTANDREPLACEFILE, [email protected], $@) @@ -120,5 +120,5 @@ endif # Clean each subdirectory clean: $(foreach DIR, $(ALL_SUBDIRS), $(DIR)_clean) - $(Q) rm -f $(FSIMG_HDR) $(ROMFS_IMG) $(SYMTAB_SRC) + $(Q) rm -f $(FSIMG_SRC) $(ROMFS_IMG) $(SYMTAB_SRC) $(Q) rm -rf $(FSROOT_DIR) diff --git a/examples/module/module_main.c b/examples/module/module_main.c index 3b65dfb..1b765ac 100644 --- a/examples/module/module_main.c +++ b/examples/module/module_main.c @@ -59,9 +59,6 @@ #if defined(CONFIG_EXAMPLES_MODULE_ROMFS) # include <nuttx/drivers/ramdisk.h> -# include "drivers/romfs.h" -#elif defined(CONFIG_EXAMPLES_MODULE_CROMFS) -# include "drivers/cromfs.h" #endif /**************************************************************************** @@ -131,6 +128,11 @@ static const char g_write_string[] = "Hi there, installed driver\n"; * Symbols from Auto-Generated Code ****************************************************************************/ +#if defined(CONFIG_EXAMPLES_MODULE_ROMFS) || defined(CONFIG_EXAMPLES_MODULE_CROMFS) +extern const unsigned char romfs_img[]; +extern const unsigned int romfs_img_len; +#endif + #ifdef CONFIG_BUILD_FLAT extern const struct symtab_s g_mod_exports[]; extern const int g_mod_nexports; diff --git a/examples/nxflat/Makefile b/examples/nxflat/Makefile index baae744..16fcb55 100644 --- a/examples/nxflat/Makefile +++ b/examples/nxflat/Makefile @@ -37,6 +37,9 @@ # NXFLAT Example +CSRCS = romfs.c +CSRCS += dirlist.c +CSRCS += symtab.c MAINSRC = nxflat_main.c PROGNAME = nxflat @@ -44,7 +47,9 @@ PRIORITY = SCHED_PRIORITY_DEFAULT STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE) MODULE = $(CONFIG_EXAMPLES_NXFLAT) -nxflat_main.c: build +tests/romfs.c: build +tests/dirlist.c: build +tests/symtab.c: build .PHONY: build build: diff --git a/examples/nxflat/nxflat_main.c b/examples/nxflat/nxflat_main.c index 8c68029..a853b6b 100644 --- a/examples/nxflat/nxflat_main.c +++ b/examples/nxflat/nxflat_main.c @@ -53,10 +53,6 @@ #include <nuttx/drivers/ramdisk.h> #include <nuttx/binfmt/binfmt.h> -#include "tests/romfs.h" -#include "tests/dirlist.h" -#include "tests/symtab.h" - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -120,6 +116,18 @@ static char fullpath[128]; #endif /**************************************************************************** + * Symbols from Auto-Generated Code + ****************************************************************************/ + +extern const unsigned char romfs_img[]; +extern const unsigned int romfs_img_len; + +extern const char *dirlist[]; + +extern const struct symtab_s g_nxflat_exports[]; +extern const int g_nxflat_nexports; + +/**************************************************************************** * Private Functions ****************************************************************************/ @@ -213,7 +221,7 @@ int main(int argc, FAR char *argv[]) */ args[0] = NULL; - ret = exec(filename, args, g_nxflat_exports, NEXPORTS); + ret = exec(filename, args, g_nxflat_exports, g_nxflat_nexports); if (ret < 0) { errmsg("ERROR: exec(%s) failed: %d\n", dirlist[i], errno); diff --git a/examples/nxflat/tests/.gitignore b/examples/nxflat/tests/.gitignore index 7f10e37..7be24fe 100644 --- a/examples/nxflat/tests/.gitignore +++ b/examples/nxflat/tests/.gitignore @@ -1,5 +1,5 @@ /romfs -/romfs.h +/romfs.c /romfs.img -/dirlist.h -/symtab.h +/dirlist.c +/symtab.c diff --git a/examples/nxflat/tests/Makefile b/examples/nxflat/tests/Makefile index 327abc1..2c79cb7 100644 --- a/examples/nxflat/tests/Makefile +++ b/examples/nxflat/tests/Makefile @@ -49,16 +49,16 @@ NXFLAT_DIR = $(APPDIR)/examples/nxflat TESTS_DIR = $(NXFLAT_DIR)/tests ROMFS_DIR = $(TESTS_DIR)/romfs ROMFS_IMG = $(TESTS_DIR)/romfs.img -ROMFS_HDR = $(TESTS_DIR)/romfs.h -ROMFS_DIRLIST = $(TESTS_DIR)/dirlist.h -SYMTAB = $(TESTS_DIR)/symtab.h +ROMFS_SRC = $(TESTS_DIR)/romfs.c +DIRLIST_SRC = $(TESTS_DIR)/dirlist.h +SYMTAB_SRC = $(TESTS_DIR)/symtab.c define DIR_template $(1)_$(2): +$(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" CROSSDEV=$(CROSSDEV) endef -all: $(ROMFS_HDR) $(ROMFS_DIRLIST) $(SYMTAB) +all: $(ROMFS_SRC) $(DIRLIST_SRC) $(SYMTAB_SRC) .PHONY: all clean install $(foreach DIR, $(SUBDIRS), $(eval $(call DIR_template,$(DIR),clean))) @@ -74,25 +74,25 @@ $(ROMFS_IMG): install $(Q) genromfs -f [email protected] -d $(ROMFS_DIR) -V "NXFLATTEST" $(Q) $(call TESTANDREPLACEFILE, [email protected], $@) -# Create the romfs.h header file from the romfs.img file +# Create the romfs.c file from the romfs.img file -$(ROMFS_HDR): $(ROMFS_IMG) - $(Q) (cd $(TESTS_DIR); xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@) +$(ROMFS_SRC): $(ROMFS_IMG) + $(Q) (cd $(TESTS_DIR); xxd -i romfs.img | sed -e "s/^unsigned/const unsigned/g" >$@) # Create the dirlist.h header file from the romfs directory -$(ROMFS_DIRLIST): install +$(DIRLIST_SRC): install $(Q) $(TESTS_DIR)/mkdirlist.sh $(ROMFS_DIR) >[email protected] $(Q) $(call TESTANDREPLACEFILE, [email protected], $@) # Create the exported symbol table list from the derived *-thunk.S files -$(SYMTAB): install +$(SYMTAB_SRC): install $(Q) $(TESTS_DIR)/mksymtab.sh $(ROMFS_DIR) >[email protected] $(Q) $(call TESTANDREPLACEFILE, [email protected], $@) # Clean each subdirectory clean: $(foreach DIR, $(SUBDIRS), $(DIR)_clean) - $(Q) rm -f $(ROMFS_HDR) $(ROMFS_DIRLIST) $(ROMFS_IMG) $(SYMTAB) + $(Q) rm -f $(ROMFS_SRC) $(DIRLIST_SRC) $(ROMFS_IMG) $(SYMTAB_SRC) $(Q) rm -rf $(ROMFS_DIR) diff --git a/examples/nxflat/tests/mkdirlist.sh b/examples/nxflat/tests/mkdirlist.sh index 72956f1..94e9f92 100755 --- a/examples/nxflat/tests/mkdirlist.sh +++ b/examples/nxflat/tests/mkdirlist.sh @@ -17,8 +17,7 @@ if [ ! -d "$dir" ]; then exit 1 fi -echo "#ifndef __EXAMPLES_NXFLAT_TESTS_DIRLIST_H" -echo "#define __EXAMPLES_NXFLAT_TESTS_DIRLIST_H" +echo "#include <stddef.h>" echo "" echo "static const char *dirlist[] =" echo "{" @@ -29,5 +28,3 @@ done echo " NULL" echo "};" -echo "" -echo "#endif /* __EXAMPLES_NXFLAT_TESTS_DIRLIST_H */" diff --git a/examples/nxflat/tests/mksymtab.sh b/examples/nxflat/tests/mksymtab.sh index 165e8ef..0f6ab87 100755 --- a/examples/nxflat/tests/mksymtab.sh +++ b/examples/nxflat/tests/mksymtab.sh @@ -19,12 +19,21 @@ fi varlist=`find $dir -name "*-thunk.S"| xargs grep -h asciz | cut -f3 | sort | uniq` -echo "#ifndef __EXAMPLES_NXFLAT_TESTS_SYMTAB_H" -echo "#define __EXAMPLES_NXFLAT_TESTS_SYMTAB_H" -echo "" +# 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 "" -echo "static const struct symtab_s g_nxflat_exports[] = " + +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 @@ -33,6 +42,5 @@ for string in $varlist; do done echo "};" -echo "#define NEXPORTS (sizeof(g_nxflat_exports)/sizeof(struct symtab_s))" echo "" -echo "#endif /* __EXAMPLES_NXFLAT_TESTS_SYMTAB_H */" +echo "const int g_nxflat_nexports = sizeof(g_nxflat_exports) / sizeof(struct symtab_s);" diff --git a/examples/posix_spawn/Makefile b/examples/posix_spawn/Makefile index a00f5e1..18174d8 100644 --- a/examples/posix_spawn/Makefile +++ b/examples/posix_spawn/Makefile @@ -37,7 +37,8 @@ # ELF Example -CSRCS = symtab.c +CSRCS = romfs.c +CSRCS += symtab.c MAINSRC = spawn_main.c PROGNAME = posix_spawn @@ -51,7 +52,7 @@ ROOTDEPPATH += --dep-path filesystem VPATH += filesystem -spawn_main.c: build +filesystem/romfs.c: build filesystem/symtab.c: build .PHONY: build diff --git a/examples/posix_spawn/filesystem/.gitignore b/examples/posix_spawn/filesystem/.gitignore index 29cf8e8..bab7e5f 100644 --- a/examples/posix_spawn/filesystem/.gitignore +++ b/examples/posix_spawn/filesystem/.gitignore @@ -1,4 +1,4 @@ /romfs -/romfs.h +/romfs.c /romfs.img /symtab.c diff --git a/examples/posix_spawn/filesystem/Makefile b/examples/posix_spawn/filesystem/Makefile index 86d033c..24b8e58 100644 --- a/examples/posix_spawn/filesystem/Makefile +++ b/examples/posix_spawn/filesystem/Makefile @@ -39,10 +39,10 @@ SPAWN_DIR = $(APPDIR)$(DELIM)examples$(DELIM)posix_spawn FILESYSTEM_DIR = $(SPAWN_DIR)$(DELIM)filesystem ROMFS_DIR = $(FILESYSTEM_DIR)$(DELIM)romfs ROMFS_IMG = $(FILESYSTEM_DIR)$(DELIM)romfs.img -ROMFS_HDR = $(FILESYSTEM_DIR)$(DELIM)romfs.h +ROMFS_SRC = $(FILESYSTEM_DIR)$(DELIM)romfs.c SYMTAB_SRC = $(FILESYSTEM_DIR)$(DELIM)symtab.c -all: $(ROMFS_HDR) $(SYMTAB_SRC) +all: $(ROMFS_SRC) $(SYMTAB_SRC) .PHONY: all hello/hello redirect/redirect clean # Build the hello test program @@ -65,10 +65,10 @@ $(ROMFS_IMG): hello/hello redirect/redirect testdata.txt $(Q) genromfs -f [email protected] -d $(ROMFS_DIR) -V "POSIXSPAWN" $(Q) $(call TESTANDREPLACEFILE, [email protected], $@) -# Create the romfs.h header file from the romfs.img file +# Create the romfs.c file from the romfs.img file -$(ROMFS_HDR): $(ROMFS_IMG) - $(Q) (cd $(FILESYSTEM_DIR); xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@) +$(ROMFS_SRC): $(ROMFS_IMG) + $(Q) (cd $(FILESYSTEM_DIR); xxd -i romfs.img | sed -e "s/^unsigned/const unsigned/g" >$@) # Create the exported symbol table @@ -81,5 +81,5 @@ $(SYMTAB_SRC): $(ROMFS_IMG) clean: $(Q) $(MAKE) -C hello clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" $(Q) $(MAKE) -C redirect clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" - $(Q) rm -f $(ROMFS_HDR) $(ROMFS_IMG) $(SYMTAB_SRC) + $(Q) rm -f $(ROMFS_SRC) $(ROMFS_IMG) $(SYMTAB_SRC) $(Q) rm -rf $(ROMFS_DIR) diff --git a/examples/posix_spawn/spawn_main.c b/examples/posix_spawn/spawn_main.c index add4d2d..4b45421 100644 --- a/examples/posix_spawn/spawn_main.c +++ b/examples/posix_spawn/spawn_main.c @@ -40,8 +40,6 @@ #include <nuttx/drivers/ramdisk.h> #include <nuttx/symtab.h> -#include "filesystem/romfs.h" - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -133,6 +131,9 @@ static char * const g_argv[4] = * Symbols from Auto-Generated Code ****************************************************************************/ +extern const unsigned char romfs_img[]; +extern const unsigned int romfs_img_len; + extern const struct symtab_s g_spawn_exports[]; extern const int g_spawn_nexports; diff --git a/examples/sotest/Makefile b/examples/sotest/Makefile index dc99479..58d4844 100644 --- a/examples/sotest/Makefile +++ b/examples/sotest/Makefile @@ -47,7 +47,10 @@ MODULE = $(CONFIG_EXAMPLES_SOTEST) # Shared Library Example -CSRCS = sot_symtab.c +ifeq ($(CONFIG_EXAMPLES_SOTEST_BUILTINFS),y) +CSRCS = romfs.c +endif +CSRCS += sot_symtab.c MAINSRC = sotest_main.c ROOTDEPPATH += --dep-path lib @@ -56,7 +59,9 @@ ROOTDEPPATH += --dep-path lib VPATH = lib -sotest_main.c: build +ifeq ($(CONFIG_EXAMPLES_SOTEST_BUILTINFS),y) +lib/romfs.c: build +endif lib/sot_symtab.c: build .PHONY: build diff --git a/examples/sotest/lib/.gitignore b/examples/sotest/lib/.gitignore index 51ad4c7..f41ef92 100644 --- a/examples/sotest/lib/.gitignore +++ b/examples/sotest/lib/.gitignore @@ -1,4 +1,4 @@ /fsroot -/romfs.h +/romfs.c /romfs.img /sot_symtab.c diff --git a/examples/sotest/lib/Makefile b/examples/sotest/lib/Makefile index 66de06f..27adbcf 100644 --- a/examples/sotest/lib/Makefile +++ b/examples/sotest/lib/Makefile @@ -50,7 +50,7 @@ SYMTAB_SRC = $(LIB_DIR)/sot_symtab.c ifeq ($(CONFIG_EXAMPLES_SOTEST_BUILTINFS),y) ROMFS_IMG = $(LIB_DIR)/romfs.img - ROMFS_HDR = $(LIB_DIR)/romfs.h + ROMFS_SRC = $(LIB_DIR)/romfs.c endif define DIR_template @@ -58,7 +58,7 @@ $(1)_$(2): +$(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" FSROOT_DIR="$(FSROOT_DIR)" CROSSDEV=$(CROSSDEV) endef -all: $(ROMFS_HDR) $(SYMTAB_SRC) +all: $(ROMFS_SRC) $(SYMTAB_SRC) .PHONY: all clean install $(foreach DIR, $(ALL_SUBDIRS), $(eval $(call DIR_template,$(DIR),clean))) @@ -75,10 +75,10 @@ $(ROMFS_IMG): install $(Q) genromfs -f [email protected] -d $(FSROOT_DIR) -V "SOTESTTEST" $(Q) $(call TESTANDREPLACEFILE, [email protected], $@) -# Create the romfs.h header file from the romfs.img file +# Create the romfs.c file from the romfs.img file -$(ROMFS_HDR): $(ROMFS_IMG) - $(Q) (cd $(LIB_DIR); xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@) +$(ROMFS_SRC): $(ROMFS_IMG) + $(Q) (cd $(LIB_DIR); xxd -i romfs.img | sed -e "s/^unsigned/const unsigned/g" >$@) endif # Create the exported symbol table @@ -90,5 +90,5 @@ $(SYMTAB_SRC): install # Clean each subdirectory clean: $(foreach DIR, $(ALL_SUBDIRS), $(DIR)_clean) - $(Q) rm -f $(ROMFS_HDR) $(ROMFS_IMG) $(SYMTAB_SRC) + $(Q) rm -f $(ROMFS_SRC) $(ROMFS_IMG) $(SYMTAB_SRC) $(Q) rm -rf $(FSROOT_DIR) diff --git a/examples/sotest/sotest_main.c b/examples/sotest/sotest_main.c index a02cc3c..acf460b 100644 --- a/examples/sotest/sotest_main.c +++ b/examples/sotest/sotest_main.c @@ -55,7 +55,6 @@ #ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS # include <nuttx/drivers/ramdisk.h> -# include "lib/romfs.h" #endif /**************************************************************************** @@ -100,6 +99,11 @@ * Symbols from Auto-Generated Code ****************************************************************************/ +#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS +extern const unsigned char romfs_img[]; +extern const unsigned int romfs_img_len; +#endif + extern const struct symtab_s g_sot_exports[]; extern const int g_sot_nexports; diff --git a/examples/thttpd/Makefile b/examples/thttpd/Makefile index 5609cd1..2b5228c 100644 --- a/examples/thttpd/Makefile +++ b/examples/thttpd/Makefile @@ -37,6 +37,7 @@ # THTTPD Web Server Example +CSRCS = romfs.c MAINSRC = thttpd_main.c CONTENT_MAKE = $(MAKE) -C content @@ -44,6 +45,7 @@ ifeq ($(CONFIG_THTTPD_BINFS),y) CONTENT_MAKE += -f Makefile.binfs else CONTENT_MAKE += -f Makefile.nxflat + CSRCS += symtab.c endif PROGNAME = thttp @@ -51,7 +53,13 @@ PRIORITY = SCHED_PRIORITY_DEFAULT STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE) MODULE = $(CONFIG_EXAMPLES_THTTPD) -thttpd_main.c: build +VPATH += content +ROOTDEPPATH += --dep-path content + +content/romfs.c: build +ifeq ($(CONFIG_THTTPD_NXFLAT),y) +content/symtab.c: build +endif .PHONY: build build: diff --git a/examples/thttpd/content/.gitignore b/examples/thttpd/content/.gitignore index cebf33a..eaaeed6 100644 --- a/examples/thttpd/content/.gitignore +++ b/examples/thttpd/content/.gitignore @@ -10,6 +10,6 @@ /*.lib /*.src /romfs -/romfs.h +/romfs.c /romfs.img -/symtab.h +/symtab.c diff --git a/examples/thttpd/content/Makefile.binfs b/examples/thttpd/content/Makefile.binfs index ade46da..504b824 100644 --- a/examples/thttpd/content/Makefile.binfs +++ b/examples/thttpd/content/Makefile.binfs @@ -50,7 +50,7 @@ THTTPD_DIR = $(APPDIR)/examples/thttpd CONTENT_DIR = $(THTTPD_DIR)/content ROMFS_DIR = $(CONTENT_DIR)/romfs ROMFS_IMG = $(CONTENT_DIR)/romfs.img -ROMFS_HDR = $(CONTENT_DIR)/romfs.h +ROMFS_SRC = $(CONTENT_DIR)/romfs.c # Populate the romfs directory @@ -67,14 +67,14 @@ $(ROMFS_DIR)/style.css : $(CONTENT_DIR)/style.css $(ROMFS_IMG): $(ROMFS_DIR)/index.html $(ROMFS_DIR)/style.css $(Q) genromfs -f $@ -d $(ROMFS_DIR) -V "THTTPDTEST" -# Create the romfs.h header file from the romfs.img file +# Create the romfs.c file from the romfs.img file -$(ROMFS_HDR): $(ROMFS_IMG) - $(Q) (cd $(CONTENT_DIR); xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@) +$(ROMFS_SRC): $(ROMFS_IMG) + $(Q) (cd $(CONTENT_DIR); xxd -i romfs.img | sed -e "s/^unsigned/const unsigned/g" >$@) -all:: $(ROMFS_HDR) +all:: $(ROMFS_SRC) clean:: - $(call DELFILE, $(ROMFS_HDR)) + $(call DELFILE, $(ROMFS_SRC)) $(call DELFILE, $(ROMFS_IMG)) $(Q) rm -rf $(ROMFS_DIR) diff --git a/examples/thttpd/content/Makefile.nxflat b/examples/thttpd/content/Makefile.nxflat index e9ad7d7..9350da7 100644 --- a/examples/thttpd/content/Makefile.nxflat +++ b/examples/thttpd/content/Makefile.nxflat @@ -40,16 +40,16 @@ THTTPD_DIR = $(APPDIR)/examples/thttpd CONTENT_DIR = $(THTTPD_DIR)/content ROMFS_DIR = $(CONTENT_DIR)/romfs ROMFS_IMG = $(CONTENT_DIR)/romfs.img -ROMFS_HDR = $(CONTENT_DIR)/romfs.h +ROMFS_SRC = $(CONTENT_DIR)/romfs.c ROMFSCGI_DIR = $(ROMFS_DIR)/cgi-bin -SYMTAB = $(CONTENT_DIR)/symtab.h +SYMTAB_SRC = $(CONTENT_DIR)/symtab.c define DIR_template $(1)_$(2): +$(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" CROSSDEV=$(CROSSDEV) CGI_DIR="$(ROMFSCGI_DIR)" endef -all: $(ROMFS_HDR) $(SYMTAB) +all: $(ROMFS_SRC) $(SYMTAB_SRC) .PHONY: all clean distclean install context depend $(foreach DIR, $(SUBDIRS), $(eval $(call DIR_template,$(DIR),clean))) @@ -68,14 +68,14 @@ $(ROMFS_IMG): install $(Q) genromfs -f [email protected] -d $(ROMFS_DIR) -V "THTTPDTEST" $(Q) $(call TESTANDREPLACEFILE, [email protected], $@) -# Create the romfs.h header file from the romfs.img file +# Create the romfs.c file from the romfs.img file -$(ROMFS_HDR): $(ROMFS_IMG) - $(Q) (cd $(CONTENT_DIR); xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@) +$(ROMFS_SRC): $(ROMFS_IMG) + $(Q) (cd $(CONTENT_DIR); xxd -i romfs.img | sed -e "s/^unsigned/const unsigned/g" >$@) # Create the exported symbol table list from the derived *-thunk.S files -$(SYMTAB): install +$(SYMTAB_SRC): install $(Q) $(CONTENT_DIR)/mksymtab.sh $(CONTENT_DIR) >[email protected] $(Q) $(call TESTANDREPLACEFILE, [email protected], $@) @@ -86,9 +86,9 @@ context: # Clean each subdirectory clean: $(foreach DIR, $(SUBDIRS), $(DIR)_clean) - $(call DELFILE, $(ROMFS_HDR)) + $(call DELFILE, $(ROMFS_SRC)) $(call DELFILE, $(ROMFS_IMG)) - $(call DELFILE, $(SYMTAB)) + $(call DELFILE, $(SYMTAB_SRC)) $(Q) rm -rf $(ROMFS_DIR) distclean: clean diff --git a/examples/thttpd/content/mksymtab.sh b/examples/thttpd/content/mksymtab.sh index 6554ade..f9bb735 100755 --- a/examples/thttpd/content/mksymtab.sh +++ b/examples/thttpd/content/mksymtab.sh @@ -19,12 +19,21 @@ fi varlist=`find $dir -name "*-thunk.S"| xargs grep -h asciz | cut -f3 | sort | uniq` -echo "#ifndef __EXAMPLES_NXFLAT_TESTS_SYMTAB_H" -echo "#define __EXAMPLES_NXFLAT_TESTS_SYMTAB_H" -echo "" +# 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 "" -echo "static const struct symtab_s g_thttpd_exports[] = " + +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 @@ -33,6 +42,4 @@ for string in $varlist; do done echo "};" -echo "#define NEXPORTS (sizeof(g_thttpd_exports)/sizeof(struct symtab_s))" -echo "" -echo "#endif /* __EXAMPLES_NXFLAT_TESTS_SYMTAB_H */" +echo "const int g_thttpd_nexports = sizeof(g_thttpd_exports) / sizeof(struct symtab_s);" diff --git a/examples/thttpd/thttpd_main.c b/examples/thttpd/thttpd_main.c index 60cca28..25e720e 100644 --- a/examples/thttpd/thttpd_main.c +++ b/examples/thttpd/thttpd_main.c @@ -67,12 +67,6 @@ # include <nuttx/net/net.h> #endif -#include "content/romfs.h" - -#ifdef CONFIG_THTTPD_NXFLAT -# include "content/symtab.h" -#endif - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -183,6 +177,18 @@ int g_thttpdnsymbols; #endif /**************************************************************************** + * Symbols from Auto-Generated Code + ****************************************************************************/ + +extern const unsigned char romfs_img[]; +extern const unsigned int romfs_img_len; + +#ifdef CONFIG_THTTPD_FLAT +extern const struct symtab_s g_thttpd_exports[]; +extern const int g_thttpd_nexports; +#endif + +/**************************************************************************** * Public Functions ****************************************************************************/ @@ -296,7 +302,7 @@ int main(int argc, FAR char *argv[]) #ifdef CONFIG_THTTPD_NXFLAT g_thttpdsymtab = g_thttpd_exports; - g_thttpdnsymbols = NEXPORTS; + g_thttpdnsymbols = g_thttpd_nexports; #endif printf("Starting THTTPD\n");
