diff options
Diffstat (limited to 'makefiles')
-rw-r--r-- | makefiles/config_px4fmu_default.mk | 5 | ||||
-rw-r--r-- | makefiles/firmware.mk | 33 |
2 files changed, 35 insertions, 3 deletions
diff --git a/makefiles/config_px4fmu_default.mk b/makefiles/config_px4fmu_default.mk index 5a61e9428..2c1764d61 100644 --- a/makefiles/config_px4fmu_default.mk +++ b/makefiles/config_px4fmu_default.mk @@ -6,4 +6,9 @@ CONFIG = px4fmu_default SRCS = $(PX4_BASE)/platforms/empty.c ROMFS_ROOT = $(PX4_BASE)/ROMFS/$(CONFIG) +# Commands from the NuttX export archive +# +# Each entry here is <command>.<priority>.<stacksize>.<entrypoint> +BUILTIN_COMMANDS = perf.SCHED_PRIORITY_DEFAULT.CONFIG_PTHREAD_STACK_DEFAULT.perf_main + include $(PX4_MK_DIR)/firmware.mk 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) |