• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1variant_list := $(filter AUX-%,$(MAKECMDGOALS))
2
3ifdef variant_list
4AUX_OS_VARIANT_LIST := $(patsubst AUX-%,%,$(variant_list))
5else
6AUX_OS_VARIANT_LIST := $(TARGET_AUX_OS_VARIANT_LIST)
7endif
8
9# exclude AUX targets from build
10ifeq ($(AUX_OS_VARIANT_LIST),none)
11AUX_OS_VARIANT_LIST :=
12endif
13
14# temporary workaround to support external toolchain
15ifeq ($(NANOHUB_TOOLCHAIN),)
16AUX_OS_VARIANT_LIST :=
17endif
18
19# setup toolchain paths for various CPU architectures
20# this one will come from android prebuilts eventually
21AUX_TOOLCHAIN_cortexm4 := $(NANOHUB_TOOLCHAIN)
22ifeq ($(wildcard $(AUX_TOOLCHAIN_cortexm4)gcc),)
23AUX_TOOLCHAIN_cortexm4:=
24endif
25
26# there is no MAKE var that defines path to HOST toolchain
27# all the interesting paths are hardcoded in soong, and are not available from here
28# There is no other way but to hardcode them again, as we may need host x86 toolcain for AUX
29ifeq ($(HOST_OS),linux)
30AUX_TOOLCHAIN_x86 := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/bin/x86_64-linux-
31endif
32
33# setup AUX globals
34AUX_SHLIB_SUFFIX := .so
35AUX_GLOBAL_ARFLAGS := cqsD
36AUX_STATIC_LIB_SUFFIX := .a
37
38# Load ever-lasting "indexed" version of AUX variant environment; it is treated as READ-ONLY from this
39# moment on.
40#
41# $(1) - variant
42# no return value
43define aux-variant-setup-paths
44$(eval AUX_OUT_ROOT_$(1) := $(PRODUCT_OUT)/aux/$(1)) \
45$(eval AUX_COMMON_OUT_ROOT_$(1) := $(AUX_OUT_ROOT_$(1))/common) \
46$(eval AUX_OUT_$(1) := $(AUX_OUT_ROOT_$(1))/$(AUX_OS_$(1))-$(AUX_ARCH_$(1))-$(AUX_CPU_$(1))) \
47$(eval AUX_OUT_INTERMEDIATES_$(1) := $(AUX_OUT_$(1))/obj) \
48$(eval AUX_OUT_COMMON_INTERMEDIATES_$(1) := $(AUX_COMMON_OUT_ROOT_$(1))/obj) \
49$(eval AUX_OUT_HEADERS_$(1) := $(AUX_OUT_INTERMEDIATES_$(1))/include) \
50$(eval AUX_OUT_NOTICE_FILES_$(1) := $(AUX_OUT_INTERMEDIATES_$(1))/NOTICE_FILES) \
51$(eval AUX_OUT_FAKE_$(1) := $(AUX_OUT_$(1))/fake_packages) \
52$(eval AUX_OUT_GEN_$(1) := $(AUX_OUT_$(1))/gen) \
53$(eval AUX_OUT_COMMON_GEN_$(1) := $(AUX_COMMON_OUT_ROOT_$(1))/gen) \
54$(eval AUX_OUT_EXECUTABLES_$(1) := $(AUX_OUT_$(1))/bin) \
55$(eval AUX_OUT_UNSTRIPPED_$(1) := $(AUX_OUT_$(1))/symbols)
56endef
57
58# Copy "indexed" AUX environment for given VARIANT into
59# volatile not-indexed set of variables for simplicity of access.
60# Injection of index support throughout the build system is suboptimal
61# hence volatile environment is constructed
62# Unlike HOST*, TARGET* variables, AUX* variables are NOT read-only, but their
63# indexed versions are.
64#
65# $(1) - variant
66# no return value
67define aux-variant-load-env
68$(eval AUX_OS_VARIANT:=$(1)) \
69$(eval AUX_OS:=$(AUX_OS_$(1))) \
70$(eval AUX_ARCH:=$(AUX_ARCH_$(1))) \
71$(eval AUX_SUBARCH:=$(AUX_SUBARCH_$(1))) \
72$(eval AUX_CPU:=$(AUX_CPU_$(1))) \
73$(eval AUX_OS_PATH:=$(AUX_OS_PATH_$(1))) \
74$(eval AUX_OUT_ROOT := $(AUX_OUT_ROOT_$(1))) \
75$(eval AUX_COMMON_OUT_ROOT := $(AUX_COMMON_OUT_ROOT_$(1))) \
76$(eval AUX_OUT := $(AUX_OUT_$(1))) \
77$(eval AUX_OUT_INTERMEDIATES := $(AUX_OUT_INTERMEDIATES_$(1))) \
78$(eval AUX_OUT_COMMON_INTERMEDIATES := $(AUX_OUT_COMMON_INTERMEDIATES_$(1))) \
79$(eval AUX_OUT_HEADERS := $(AUX_OUT_HEADERS_$(1))) \
80$(eval AUX_OUT_NOTICE_FILES := $(AUX_OUT_NOTICE_FILES_$(1))) \
81$(eval AUX_OUT_FAKE := $(AUX_OUT_FAKE_$(1))) \
82$(eval AUX_OUT_GEN := $(AUX_OUT_GEN_$(1))) \
83$(eval AUX_OUT_COMMON_GEN := $(AUX_OUT_COMMON_GEN_$(1))) \
84$(eval AUX_OUT_EXECUTABLES := $(AUX_OUT_EXECUTABLES_$(1))) \
85$(eval AUX_OUT_UNSTRIPPED := $(AUX_OUT_UNSTRIPPED_$(1)))
86endef
87
88# given a variant:path pair, load the variant conviguration with aux-variant-setup-paths from file
89# this is a build system extension mechainsm, since configuration typically resides in non-build
90# project space
91#
92# $(1) - variant:path pair
93# $(2) - file suffix
94# no return value
95define aux-variant-import-from-pair
96$(eval _pair := $(subst :, ,$(1))) \
97$(eval _name:=$(word 1,$(_pair))) \
98$(eval _path:=$(word 2,$(_pair))) \
99$(eval include $(_path)/$(_name)$(2)) \
100$(eval AUX_OS_VARIANT_LIST_$(AUX_OS_$(1)):=) \
101$(call aux-variant-setup-paths,$(_name)) \
102$(eval AUX_ALL_VARIANTS += $(_name)) \
103$(eval AUX_ALL_OSES := $(filter-out $(AUX_OS_$(_name)),$(AUX_ALL_OSES)) $(AUX_OS_$(_name))) \
104$(eval AUX_ALL_CPUS := $(filter-out $(AUX_CPU_$(_name)),$(AUX_ALL_CPUS)) $(AUX_CPU_$(_name))) \
105$(eval AUX_ALL_ARCHS := $(filter-out $(AUX_ARCH_$(_name)),$(AUX_ALL_ARCHS)) $(AUX_ARCH_$(_name))) \
106$(eval AUX_ALL_SUBARCHS := $(filter-out $(AUX_SUBARCH_$(_name)),$(AUX_ALL_SUBARCHS)) $(AUX_SUBARCH_$(_name)))
107endef
108
109# Load system configuration referenced by AUX variant config;
110# this is a build extension mechanism; typically system config
111# resides in a non-build projects;
112# system config may define new rules and globally visible BUILD*
113# includes to support project-specific build steps and toolchains
114# MAintains list of valiants that reference this os config in OS "indexed" var
115# this facilitates multivariant build of the OS (or whataver it is the name of common component these variants share)
116#
117# $(1) - variant
118# no return value
119define aux-import-os-config
120$(eval _aioc_os := $(AUX_OS_$(1))) \
121$(eval AUX_OS_PATH_$(1) := $(patsubst $(_aioc_os):%,%,$(filter $(_aioc_os):%,$(AUX_ALL_OS_PATHS)))) \
122$(eval _aioc_os_cfg := $(AUX_OS_PATH_$(1))/$(_aioc_os)$(os_sfx)) \
123$(if $(wildcard $(_aioc_os_cfg)),,$(error AUX '$(_aioc_os)' OS config file [$(notdir $(_aioc_os_cfg))] required by AUX variant '$(1)' does not exist)) \
124$(if $(filter $(_aioc_os),$(_os_list)),,$(eval include $(_aioc_os_cfg))) \
125$(eval AUX_OS_VARIANT_LIST_$(_aioc_os) += $(1)) \
126$(eval _os_list += $(_aioc_os))
127endef
128
129# make sure that AUX config variables are minimally sane;
130# as a bare minimum they must contain the vars described by aux_env
131# Generate error if requirement is not met.
132#
133#$(1) - variant
134# no return value
135define aux-variant-validate
136$(eval _all:=) \
137$(eval _req:=$(addsuffix _$(1),$(aux_env))) \
138$(foreach var,$(_req),$(eval _all += $(var))) \
139$(eval _missing := $(filter-out $(_all),$(_req))) \
140$(if $(_missing),$(error AUX variant $(1) must define vars: $(_missing)))
141endef
142
143AUX_ALL_VARIANTS :=
144AUX_ALL_OSES :=
145AUX_ALL_CPUS :=
146AUX_ALL_ARCHS :=
147AUX_ALL_SUBARCHS :=
148
149variant_sfx :=_aux_variant_config.mk
150os_sfx :=_aux_os_config.mk
151
152config_roots := $(wildcard device vendor)
153all_configs :=
154ifdef config_roots
155all_configs := $(sort $(shell find $(config_roots) -maxdepth 4 -name '*$(variant_sfx)' -o -name '*$(os_sfx)'))
156endif
157all_os_configs := $(filter %$(os_sfx),$(all_configs))
158all_variant_configs := $(filter %$(variant_sfx),$(all_configs))
159
160AUX_ALL_OS_PATHS := $(foreach f,$(all_os_configs),$(patsubst %$(os_sfx),%,$(notdir $(f))):$(patsubst %/,%,$(dir $(f))))
161AUX_ALL_OS_VARIANT_PATHS := $(foreach f,$(all_variant_configs),$(patsubst %$(variant_sfx),%,$(notdir $(f))):$(patsubst %/,%,$(dir $(f))))
162
163my_variant_pairs := $(foreach v,$(AUX_OS_VARIANT_LIST),$(filter $(v):%,$(AUX_ALL_OS_VARIANT_PATHS)))
164my_missing_variants := $(foreach v,$(AUX_OS_VARIANT_LIST),$(if $(filter $(v):%,$(AUX_ALL_OS_VARIANT_PATHS)),,$(v)))
165
166ifneq ($(strip $(my_missing_variants)),)
167$(error Don't know how to build variant(s): $(my_missing_variants))
168endif
169
170# mandatory variables
171aux_env := AUX_OS AUX_ARCH AUX_SUBARCH AUX_CPU
172
173$(foreach v,$(my_variant_pairs),$(if $(filter $(v),$(AUX_ALL_VARIANTS)),,$(call aux-variant-import-from-pair,$(v),$(variant_sfx))))
174
175ifdef AUX_ALL_VARIANTS
176_os_list :=
177$(foreach v,$(AUX_ALL_VARIANTS),\
178  $(call aux-import-os-config,$(v)) \
179  $(call aux-variant-validate,$(v)) \
180)
181endif
182
183INSTALLED_AUX_TARGETS :=
184