Browse Source

Get a bit fancier with the builtin app specifications, so that we can generate them from apps as well as the config.

sbg
px4dev 12 years ago
parent
commit
3494039d90
  1. 5
      makefiles/config_px4fmu_default.mk
  2. 33
      makefiles/firmware.mk

5
makefiles/config_px4fmu_default.mk

@ -6,4 +6,9 @@ CONFIG = px4fmu_default @@ -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

33
makefiles/firmware.mk

@ -165,18 +165,45 @@ endif @@ -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)

Loading…
Cancel
Save