Squashed commit of the following:
Merged in masayuki2009/nuttx.apps/loadable_app (pull request #148) loadable app support * apps: Introduce a build system for loadable apps for nsh. This PR consits of following changes. (NOTE: Changes to each application will be provided separately) apps/nshlib/Kconfig: Add 'option modules' to NSH_FILE_APPS so that a user can change an application configuration to tristate (y/n/m) apps/Make.defs: Override COMPILE and COMPILEXX macros to compile loadable apps. To make loadable apps, -DLOADABLE_APP is added to the flags. Also, introduce ELFLD to link a lodable app. Please note that the variable 'LOADABLE' must be defined in each application Makefile if you want to make a loadable app. apps/Application.mk: Add .build target in case of 'LOADABLE=y' which is used to link a final loadable application and install the app to apps/bin. apps/Makefile: Add SYMTABSRC and SYMTABOBJ variables for loadable apps which will be generated under the apps directory. Add make_symbols target which will be called when all applications are installed to generate symtab_app.c which is used for nsh to inform symbol information to the NuttX kernel. Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com> * apps/examples/hello: Apply changes to support a lodable app. Kconfig: Change the application state from bool to tristate Make.defs: Change the condition to build. By default, the application is not selected (i.e. 'n'), so if other states (i.e. y/m) are selected, the application will be compiled. Makefile: If the application is specified to 'm', the variable 'LOADABLE' must be defined here. Also note that other variables (PRIORITY and STACKSIZE) can only be used for built-in apps. hello_main.c Add LOADABLE_APP condition to main(). Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com> * apps/examples/helloxx: Apply changes to support a lodable app. Kconfig: Change the application state from bool to tristate Make.defs: Change the condition to build. By default, the application is not selected (i.e. 'n'), so if other states (i.e. y/m) are selected, the application will be compiled. Makefile: If the application is specified to 'm', the variable 'LOADABLE' must be defined here. Also note that other variables (PRIORITY and STACKSIZE) can only be used for built-in apps. helloxx_main.c Add LOADABLE_APP condition to main(). Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com> Approved-by: GregoryN <gnutt@nuttx.org>
This commit is contained in:
parent
3e81973cd5
commit
922283ee5d
@ -89,9 +89,16 @@ $(MAINOBJ): %$(OBJEXT): %.c
|
|||||||
$(call COMPILE, $<, $@)
|
$(call COMPILE, $<, $@)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(LOADABLE),y)
|
||||||
|
.built: $(OBJS)
|
||||||
|
$(call ELFLD, $(APPNAME)_main, $(OBJS), $(APPNAME))
|
||||||
|
$(Q) mkdir -p $(BIN_DIR)
|
||||||
|
$(Q) install $(APPNAME) $(BIN_DIR)$(DELIM)$(APPNAME)
|
||||||
|
else
|
||||||
.built: $(OBJS)
|
.built: $(OBJS)
|
||||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
$(call ARCHIVE, $(BIN), $(OBJS))
|
||||||
$(Q) touch $@
|
$(Q) touch $@
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_BUILD_KERNEL),y)
|
ifeq ($(CONFIG_BUILD_KERNEL),y)
|
||||||
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ)
|
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ)
|
||||||
|
27
Make.defs
27
Make.defs
@ -56,6 +56,33 @@ define REGISTER
|
|||||||
endef
|
endef
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# COMPILE - a macro to compile a loadable app in C
|
||||||
|
|
||||||
|
ifeq ($(LOADABLE),y)
|
||||||
|
define COMPILE
|
||||||
|
@echo "CC) $1"
|
||||||
|
$(Q) $(CC) -c $(CELFFLAGS) -DLOADABLE_APP $1 -o $2
|
||||||
|
endef
|
||||||
|
endif
|
||||||
|
|
||||||
|
# COMPILEXX - a macro to compile a loadable app in C++
|
||||||
|
|
||||||
|
ifeq ($(LOADABLE),y)
|
||||||
|
define COMPILEXX
|
||||||
|
@echo "CXX: $1"
|
||||||
|
$(Q) $(CXX) -c $(CXXELFFLAGS) -DLOADABLE_APP $1 -o $2
|
||||||
|
endef
|
||||||
|
endif
|
||||||
|
|
||||||
|
# ELFLD - a macro to link loadable app
|
||||||
|
# Example: $(call ELFLD, entry point, in-file(s), out-file)
|
||||||
|
|
||||||
|
define ELFLD
|
||||||
|
@echo "LD: $3"
|
||||||
|
$(Q) $(LD) $(LDELFFLAGS) $2 -o $3
|
||||||
|
$(Q) chmod +x $3
|
||||||
|
endef
|
||||||
|
|
||||||
# Tools
|
# Tools
|
||||||
#
|
#
|
||||||
# In a normal build, tools will reside in the nuttx/tools sub-directory and
|
# In a normal build, tools will reside in the nuttx/tools sub-directory and
|
||||||
|
17
Makefile
17
Makefile
@ -73,6 +73,11 @@ BIN_DIR = $(APPDIR)$(DELIM)bin
|
|||||||
|
|
||||||
BIN = libapps$(LIBEXT)
|
BIN = libapps$(LIBEXT)
|
||||||
|
|
||||||
|
# Symbol table for loadable apps.
|
||||||
|
|
||||||
|
SYMTABSRC = $(APPDIR)$(DELIM)symtab_apps.c
|
||||||
|
SYMTABOBJ = $(APPDIR)$(DELIM)symtab_apps.o
|
||||||
|
|
||||||
# Build targets
|
# Build targets
|
||||||
|
|
||||||
all: $(BIN)
|
all: $(BIN)
|
||||||
@ -97,7 +102,15 @@ $(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),depend))
|
|||||||
$(foreach SDIR, $(CLEANDIRS), $(eval $(call SDIR_template,$(SDIR),clean)))
|
$(foreach SDIR, $(CLEANDIRS), $(eval $(call SDIR_template,$(SDIR),clean)))
|
||||||
$(foreach SDIR, $(CLEANDIRS), $(eval $(call SDIR_template,$(SDIR),distclean)))
|
$(foreach SDIR, $(CLEANDIRS), $(eval $(call SDIR_template,$(SDIR),distclean)))
|
||||||
|
|
||||||
$(BIN): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all)
|
make_symbols:
|
||||||
|
ifeq ($(CONFIG_EXAMPLES_NSH_SYMTAB),y)
|
||||||
|
mkdir -p $(BIN_DIR)
|
||||||
|
$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(BIN_DIR) $(SYMTABSRC)
|
||||||
|
$(call COMPILE, $(SYMTABSRC), $(SYMTABOBJ))
|
||||||
|
$(call ARCHIVE, $(APPDIR)$(DELIM)$(BIN), $(SYMTABOBJ))
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(BIN): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all) make_symbols
|
||||||
|
|
||||||
.install: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_install)
|
.install: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_install)
|
||||||
|
|
||||||
@ -143,6 +156,7 @@ clean_context:
|
|||||||
$(Q) $(MAKE) -C platform clean_context TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"
|
$(Q) $(MAKE) -C platform clean_context TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"
|
||||||
|
|
||||||
clean: $(foreach SDIR, $(CLEANDIRS), $(SDIR)_clean)
|
clean: $(foreach SDIR, $(CLEANDIRS), $(SDIR)_clean)
|
||||||
|
$(call DELFILE, $(SYMTABSRC))
|
||||||
$(call DELFILE, $(BIN))
|
$(call DELFILE, $(BIN))
|
||||||
$(call DELFILE, Kconfig)
|
$(call DELFILE, Kconfig)
|
||||||
$(call DELDIR, $(BIN_DIR))
|
$(call DELDIR, $(BIN_DIR))
|
||||||
@ -164,6 +178,7 @@ else
|
|||||||
)
|
)
|
||||||
endif
|
endif
|
||||||
$(call DELFILE, .depend)
|
$(call DELFILE, .depend)
|
||||||
|
$(call DELFILE, $(SYMTABSRC))
|
||||||
$(call DELFILE, $(BIN))
|
$(call DELFILE, $(BIN))
|
||||||
$(call DELFILE, Kconfig)
|
$(call DELFILE, Kconfig)
|
||||||
$(call DELDIR, $(BIN_DIR))
|
$(call DELDIR, $(BIN_DIR))
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
config EXAMPLES_HELLO
|
config EXAMPLES_HELLO
|
||||||
bool "\"Hello, World!\" example"
|
tristate "\"Hello, World!\" example"
|
||||||
default n
|
default n
|
||||||
---help---
|
---help---
|
||||||
Enable the \"Hello, World!\" example
|
Enable the \"Hello, World!\" example
|
||||||
|
@ -34,6 +34,6 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
ifeq ($(CONFIG_EXAMPLES_HELLO),y)
|
ifneq ($(CONFIG_EXAMPLES_HELLO),)
|
||||||
CONFIGURED_APPS += examples/hello
|
CONFIGURED_APPS += examples/hello
|
||||||
endif
|
endif
|
||||||
|
@ -41,8 +41,13 @@ CONFIG_EXAMPLES_HELLO_PRIORITY ?= SCHED_PRIORITY_DEFAULT
|
|||||||
CONFIG_EXAMPLES_HELLO_STACKSIZE ?= 2048
|
CONFIG_EXAMPLES_HELLO_STACKSIZE ?= 2048
|
||||||
|
|
||||||
APPNAME = hello
|
APPNAME = hello
|
||||||
PRIORITY = $(CONFIG_EXAMPLES_HELLO_PRIORITY)
|
|
||||||
|
ifeq ($(CONFIG_EXAMPLES_HELLO),m)
|
||||||
|
LOADABLE = y
|
||||||
|
else
|
||||||
|
PRIORITY = $(CONFIG_EXAMPLES_HELLO_PRIORITY)
|
||||||
STACKSIZE = $(CONFIG_EXAMPLES_HELLO_STACKSIZE)
|
STACKSIZE = $(CONFIG_EXAMPLES_HELLO_STACKSIZE)
|
||||||
|
endif
|
||||||
|
|
||||||
# Hello, World! Example
|
# Hello, World! Example
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
* hello_main
|
* hello_main
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_BUILD_KERNEL
|
#if defined (CONFIG_BUILD_KERNEL) || defined (LOADABLE_APP)
|
||||||
int main(int argc, FAR char *argv[])
|
int main(int argc, FAR char *argv[])
|
||||||
#else
|
#else
|
||||||
int hello_main(int argc, char *argv[])
|
int hello_main(int argc, char *argv[])
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
config EXAMPLES_HELLOXX
|
config EXAMPLES_HELLOXX
|
||||||
bool "\"Hello, World!\" C++ example"
|
tristate "\"Hello, World!\" C++ example"
|
||||||
default n
|
default n
|
||||||
depends on HAVE_CXX
|
depends on HAVE_CXX
|
||||||
---help---
|
---help---
|
||||||
|
@ -34,6 +34,6 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
ifeq ($(CONFIG_EXAMPLES_HELLOXX),y)
|
ifneq ($(CONFIG_EXAMPLES_HELLOXX),)
|
||||||
CONFIGURED_APPS += examples/helloxx
|
CONFIGURED_APPS += examples/helloxx
|
||||||
endif
|
endif
|
||||||
|
@ -48,7 +48,12 @@ PROGNAME = $(CONFIG_EXAMPLES_HELLOXX_PROGNAME)
|
|||||||
# helloxx built-in application info
|
# helloxx built-in application info
|
||||||
|
|
||||||
APPNAME = helloxx
|
APPNAME = helloxx
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_EXAMPLES_HELLOXX),m)
|
||||||
|
LOADABLE = y
|
||||||
|
else
|
||||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||||
STACKSIZE = 2048
|
STACKSIZE = 2048
|
||||||
|
endif
|
||||||
|
|
||||||
include $(APPDIR)/Application.mk
|
include $(APPDIR)/Application.mk
|
||||||
|
@ -127,7 +127,7 @@ static CHelloWorld g_HelloWorld;
|
|||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_BUILD_KERNEL
|
#if defined (CONFIG_BUILD_KERNEL) || defined (LOADABLE_APP)
|
||||||
int main(int argc, FAR char *argv[])
|
int main(int argc, FAR char *argv[])
|
||||||
#else
|
#else
|
||||||
int helloxx_main(int argc, char *argv[])
|
int helloxx_main(int argc, char *argv[])
|
||||||
|
@ -182,6 +182,7 @@ config NSH_BUILTIN_APPS
|
|||||||
|
|
||||||
config NSH_FILE_APPS
|
config NSH_FILE_APPS
|
||||||
bool "Enable execution of program files"
|
bool "Enable execution of program files"
|
||||||
|
option modules
|
||||||
default n
|
default n
|
||||||
depends on LIBC_EXECFUNCS
|
depends on LIBC_EXECFUNCS
|
||||||
---help---
|
---help---
|
||||||
|
Loading…
Reference in New Issue
Block a user