Skip to content

Commit

Permalink
BugID:19214045: Support for user defined application
Browse files Browse the repository at this point in the history
Allow user to create applications under: app/, app/subdir/

Change-Id: I29ca00b5b3c34234e60fdfce6d9adbda0c3306d7
  • Loading branch information
wenzong.fwz authored and Cheng-SG committed Mar 11, 2019
1 parent 4102dfa commit ae36823
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions build/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ config AOS_APP_NULL

source "app/example/Config.in"
source "app/profile/Config.in"
source "app/Config.in"
endchoice
endmenu

Expand Down
10 changes: 6 additions & 4 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,20 @@ endif
# get real app name and check if it available
appname = $(firstword $(components))
appdir = $(subst .,/,$(appname))
appmkfile = $(wildcard $(SOURCE_ROOT)app/*/$(appdir)/aos.mk $(SOURCE_ROOT)test/develop/$(appdir)/aos.mk)
appmkfile = $(wildcard $(SOURCE_ROOT)app/*/$(appdir)/aos.mk $(SOURCE_ROOT)app/$(appdir)/aos.mk $(SOURCE_ROOT)test/develop/$(appdir)/aos.mk)
$(if $(appmkfile),\
$(eval include $(appmkfile)) $(eval real_appname = $(NAME)),\
$(error App Unknown, Please make sure the "$(appname)" is existing!))

# determine what app type should be enabled: example, profile, test
ifneq ($(findstring profile,$(appmkfile)),)
ifneq ($(findstring profile/,$(appmkfile)),)
export AOS_APP_TYPE := AOS_APP_PROFILE
else ifneq ($(findstring example,$(appmkfile)),)
else ifneq ($(findstring example/,$(appmkfile)),)
export AOS_APP_TYPE := AOS_APP_EXAMPLE
else
else ifneq ($(findstring develop/,$(appmkfile)),)
export AOS_APP_TYPE :=
else
export AOS_APP_TYPE := AOS_APP_LOCALAPP
endif

boardname = $(word 2, $(components))
Expand Down
5 changes: 3 additions & 2 deletions build/build_rules/aos_target_config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ $(if $(filter 1,$(words $(TEMP_MAKEFILE))),,$(error More than one component with
$(eval TEMP_MAKEFILE := $(subst ././,./,$(TEMP_MAKEFILE)))
$(eval include $(TEMP_MAKEFILE))
$(eval deps :=)
$(eval NAME := $(strip $(NAME)))
$(eval $(NAME)_COMPONENTS += $($(NAME)_COMPONENTS-y))
$(eval deps_src := $($(NAME)_COMPONENTS))
$(eval components_cube := $(subst .,/,$(COMPONENTS)))
Expand Down Expand Up @@ -280,12 +281,12 @@ AOS_SDK_LDFLAGS += $(COMPILER_SPECIFIC_DEBUG_LDFLAGS)
endif

# Check if there are any unknown components; output error if so.
$(foreach comp, $(COMPONENTS), $(if $(wildcard $(APPDIR)/$(comp) $(CUBE_AOS_DIR)/$(comp) $(foreach dir, $(addprefix $(SOURCE_ROOT),$(COMPONENT_DIRECTORIES)), $(dir)/$(subst .,/,$(comp)) ) $(REAL_COMPONENTS)),,$(error Unknown component: $(comp))))
$(foreach comp, $(COMPONENTS), $(if $(wildcard $(APPDIR)/$(comp) $(CUBE_AOS_DIR)/$(comp) $(foreach dir, $(addprefix $(SOURCE_ROOT),$(COMPONENT_DIRECTORIES)), $(dir)/$(subst .,/,$(comp)) ) $($(comp)_LOCATION)),,$(error Unknown component: $(comp))))

# Find the matching platform and application from the build string components
PLATFORM_FULL :=$(strip $(foreach comp,$(subst .,/,$(COMPONENTS)),$(if $(wildcard $(SOURCE_ROOT)board/$(comp)),$(comp),)))

APP_FULL :=$(strip $(foreach comp,$(subst .,/,$(COMPONENTS)),$(if $(wildcard $(APPDIR)/$(comp) $(SOURCE_ROOT)app/example/$(comp) $(SOURCE_ROOT)app/profile/$(comp) $(SOURCE_ROOT)$(comp) $(SOURCE_ROOT)test/develop/$(comp)),$(comp),)))
APP_FULL :=$(strip $(foreach comp,$(subst .,/,$(COMPONENTS)),$(if $(wildcard $(APPDIR)/$(comp) $(SOURCE_ROOT)app/$(comp) $(SOURCE_ROOT)app/*/$(comp) $(SOURCE_ROOT)$(comp) $(SOURCE_ROOT)test/develop/$(comp)),$(comp),)))

PLATFORM :=$(notdir $(PLATFORM_FULL))
APP :=$(notdir $(APP_FULL))
Expand Down
16 changes: 14 additions & 2 deletions build/scripts/aos_parse_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ def get_app_name(mkfile):
if match:
name = match.group(2).replace("/", ".")

if not name:
patten = re.compile(r".*/app/(\w*/)?(.*)/aos.mk")
match = patten.match(mkfile)
if match:
name = match.group(2).replace("/", ".")

return name

def get_board_name(mkfile):
Expand Down Expand Up @@ -113,8 +119,14 @@ def write_config_file(source_root, config_file, mklist):
f.write("OBJ-$(%s) += %s\n" % (optname, compname))

for key in config_keys:
f.write("%s_MAKEFILE := %s\n" % (key, conf_dict[key]["mkfile"]))
f.write("%s_LOCATION := %s\n" % (key, os.path.dirname(conf_dict[key]["mkfile"])))
mkfile = conf_dict[key]["mkfile"]
location = os.path.dirname(mkfile)
aliasname = conf_dict[key]["aliasname"]
f.write("%s_MAKEFILE := %s\n" % (key, mkfile))
f.write("%s_LOCATION := %s\n" % (key, location))
if aliasname and aliasname != key:
f.write("%s_MAKEFILE := %s\n" % (aliasname, mkfile))
f.write("%s_LOCATION := %s\n" % (aliasname, location))

def main(argv):
if len(argv) < 3:
Expand Down

0 comments on commit ae36823

Please sign in to comment.