aboutsummaryrefslogtreecommitdiff
path: root/makefiles/firmware.mk
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2013-02-20 22:07:18 -0800
committerpx4dev <px4@purgatory.org>2013-02-23 22:00:59 -0800
commit3494039d9000d211c122d73d5e7ac9cf9109dddb (patch)
treee5c09b52cf2871f8fec1bdc6a26c37c7e402ba41 /makefiles/firmware.mk
parent50739c1843d266a7ff26c26284dfec9d77cf80f5 (diff)
downloadpx4-firmware-3494039d9000d211c122d73d5e7ac9cf9109dddb.tar.gz
px4-firmware-3494039d9000d211c122d73d5e7ac9cf9109dddb.tar.bz2
px4-firmware-3494039d9000d211c122d73d5e7ac9cf9109dddb.zip
Get a bit fancier with the builtin app specifications, so that we can generate them from apps as well as the config.
Diffstat (limited to 'makefiles/firmware.mk')
-rw-r--r--makefiles/firmware.mk33
1 files changed, 30 insertions, 3 deletions
diff --git a/makefiles/firmware.mk b/makefiles/firmware.mk
index eade36905..a6c7e0f48 100644
--- a/makefiles/firmware.mk
+++ b/makefiles/firmware.mk
@@ -165,18 +165,45 @@ endif
#
# XXX need to fix stack size numbers here so that apps can set them.
#
+# Builtin commands can be generated by the configuration, in which case they
+# must refer to commands that already exist, or indirectly generated by applications
+# when they are built.
+#
+# The configuration supplies builtin command information in the BUILTIN_COMMANDS
+# variable. Applications make empty files in $(WORK_DIR)/builtin_commands whose
+# filename contains the same information.
+#
+# In each case, the command information consists of four fields separated with a
+# period. These fields are the command's name, its thread priority, its stack size
+# and the name of the function to call when starting the thread.
+#
+#
BUILTIN_CSRC = $(WORK_DIR)/builtin_commands.c
+# add command definitions from apps
+BUILTIN_COMMANDS += $(subst COMMAND.,,$(notdir $(wildcard $(WORK_DIR)/builtin_commands/APP.*)))
+
+# (BUILTIN_PROTO,<cmdspec>,<outputfile>)
+define BUILTIN_PROTO
+ echo 'extern int $(word 4,$1)(int argc, char *argv[]);' >> $2;
+endef
+
+# (BUILTIN_DEF,<cmdspec>,<outputfile>)
+define BUILTIN_DEF
+ echo ' {"$(word 1,$1)", $(word 2,$1), $(word 3,$1), $(word 4,$1)},' >> $2;
+endef
+
$(BUILTIN_CSRC): $(MAKEFILE_LIST)
@echo %% generating $@
$(Q) echo '/* builtin command list - automatically generated, do not edit */' > $@
$(Q) echo '#include <nuttx/config.h>' >> $@
$(Q) echo '#include <nuttx/binfmt/builtin.h>' >> $@
- $(Q) $(foreach app,$(APPS),echo 'extern int $(app)_main(int argc, char *argv[]);' >> $@;)
+ $(Q) $(foreach spec,$(BUILTIN_COMMANDS),$(call BUILTIN_PROTO,$(subst ., ,$(spec)),$@))
$(Q) echo 'const struct builtin_s g_builtins[] = {' >> $@
- $(Q) $(foreach app,$(APPS),echo ' {"$(app)", SCHED_PRIORITY_DEFAULT, CONFIG_PTHREAD_STACK_DEFAULT, $(app)_main},' >> $@;)
+ $(Q) $(foreach spec,$(BUILTIN_COMMANDS),$(call BUILTIN_DEF,$(subst ., ,$(spec)),$@))
+ $(Q) echo ' {NULL, 0, 0, NULL}' >> $@
$(Q) echo '};' >> $@
- $(Q) echo 'const int g_builtin_count = sizeof(g_builtins) / sizeof(g_builtins[0]);' >> $@
+ $(Q) echo 'const int g_builtin_count = $(words $(BUILTIN_COMMANDS));' >> $@
BUILTIN_OBJ = $(BUILTIN_CSRC:.c=.o)
LIBS += $(BUILTIN_OBJ)