• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Nanoapp Makefile
3#
4# Include this file in your nanoapp Makefile to produce binary nanoapps to
5# target a variety of architectures.
6#
7
8# Nanoapp Build Configuration Checks ###########################################
9
10ifeq ($(NANOAPP_NAME),)
11$(error "The NANOAPP_NAME variable must be set to the name of the nanoapp. \
12         This should be assigned by the Makefile that includes app.mk.")
13endif
14
15ifeq ($(NANOAPP_ID),)
16$(error "The NANOAPP_ID variable must be set to the ID of the nanoapp. \
17         This should be assigned by the Makefile that includes app.mk.")
18endif
19
20ifeq ($(NANOAPP_VERSION),)
21$(error "The NANOAPP_VERSION variable must be set to the version of the nanoapp. \
22         This should be assigned by the Makefile that includes app.mk.")
23endif
24
25ifeq ($(BUILD_ID),)
26# If BUILD_ID is unset this must be a local build.
27BUILD_ID = local
28endif
29
30NANOAPP_VERSION := $(strip $(NANOAPP_VERSION))
31MATCHED_NANOAPP_VERSION := $(shell echo $(NANOAPP_VERSION) \
32                                 | grep "^0x[0-9a-fA-F]\{8\}")
33ifneq ($(MATCHED_NANOAPP_VERSION), $(NANOAPP_VERSION))
34$(error "The NANOAPP_VERSION must be a 4-byte hex-formatted integer. Example: \
35         0x00000101")
36endif
37
38ifeq ($(NANOAPP_NAME_STRING),)
39$(error "The NANOAPP_NAME_STRING variable must be set to the friendly name of \
40         the nanoapp. This should be assigned by the Makefile that includes \
41         app.mk.")
42endif
43
44ifeq ($(NANOAPP_VENDOR_STRING),)
45$(info "NANOAPP_VENDOR_STRING not supplied, defaulting to \"Google\".")
46NANOAPP_VENDOR_STRING = \"Google\"
47endif
48
49ifeq ($(NANOAPP_IS_SYSTEM_NANOAPP),)
50$(info "NANOAPP_IS_SYSTEM_NANOAPP not supplied, defaulting to 0.")
51NANOAPP_IS_SYSTEM_NANOAPP = 0
52endif
53
54ifeq ($(CHRE_PREFIX),)
55ifeq ($(ANDROID_BUILD_TOP),)
56$(error "You must run lunch, or specify an explicit CHRE_PREFIX environment \
57         variable")
58else
59CHRE_PREFIX = $(ANDROID_BUILD_TOP)/system/chre
60endif
61endif
62
63# Nanoapp Build ################################################################
64
65# This variable indicates to the variants that some post-processing may be
66# required as the target is a nanoapp.
67IS_NANOAPP_BUILD = true
68
69# Common App Build Configuration ###############################################
70
71OUTPUT_NAME = $(NANOAPP_NAME)
72
73# Permissions declaration ######################################################
74
75ifneq ($(CHRE_NANOAPP_USES_AUDIO),)
76COMMON_CFLAGS += -DCHRE_NANOAPP_USES_AUDIO
77endif
78
79ifneq ($(CHRE_NANOAPP_USES_BLE),)
80COMMON_CFLAGS += -DCHRE_NANOAPP_USES_BLE
81endif
82
83ifneq ($(CHRE_NANOAPP_USES_GNSS),)
84COMMON_CFLAGS += -DCHRE_NANOAPP_USES_GNSS
85endif
86
87ifneq ($(CHRE_NANOAPP_USES_WIFI),)
88COMMON_CFLAGS += -DCHRE_NANOAPP_USES_WIFI
89endif
90
91ifneq ($(CHRE_NANOAPP_USES_WWAN),)
92COMMON_CFLAGS += -DCHRE_NANOAPP_USES_WWAN
93endif
94
95# Common Compiler Flags ########################################################
96
97# Add the CHRE API to the include search path.
98COMMON_CFLAGS += -I$(CHRE_PREFIX)/chre_api/include
99COMMON_CFLAGS += -I$(CHRE_PREFIX)/chre_api/include/chre_api
100
101# Don't pull in the utils folder if not desired
102ifneq ($(NANOAPP_NO_UTILS_INCLUDE),true)
103COMMON_CFLAGS += -I$(CHRE_PREFIX)/util/include
104endif
105
106# As one nanaopp should only run in one thread, we don't want the compiler to
107# generate __cxa_guard_acquire/__cxa_guard_release which could be not supported
108# by platforms.
109# Note: this flag is clang/GCC-specific, so ideally it would go in a
110# compiler-specific area, but today there is no good place and we do not build
111# with other toolchains using this build system.
112COMMON_CFLAGS += -fno-threadsafe-statics
113
114# Allows a nanoapp to know that is compiled separately from the CHRE system.
115COMMON_CFLAGS += -DCHRE_IS_NANOAPP_BUILD
116
117# Compile FlatBuffers in a portable way.
118COMMON_CFLAGS += -DFLATBUFFERS_CHRE
119
120# Nanoapp configuration flags.
121COMMON_CFLAGS += -DNANOAPP_ID=$(NANOAPP_ID)
122COMMON_CFLAGS += -DNANOAPP_VERSION=$(NANOAPP_VERSION)
123COMMON_CFLAGS += -DNANOAPP_VENDOR_STRING=$(NANOAPP_VENDOR_STRING)
124COMMON_CFLAGS += -DNANOAPP_NAME_STRING=$(NANOAPP_NAME_STRING)
125COMMON_CFLAGS += -DNANOAPP_IS_SYSTEM_NANOAPP=$(NANOAPP_IS_SYSTEM_NANOAPP)
126
127# Unstable ID ##################################################################
128
129COMMIT_HASH_DIRTY_SUFFIX = $(shell git diff --quiet || echo -dirty)
130COMMIT_HASH = $(shell git log -1 --pretty="format:%h" .)$(COMMIT_HASH_DIRTY_SUFFIX)
131NANOAPP_UNSTABLE_ID = "nanoapp=$(NANOAPP_NAME)@$(BUILD_ID)"
132COMMON_CFLAGS += -DNANOAPP_UNSTABLE_ID="\"$(NANOAPP_UNSTABLE_ID)\""
133
134# Optional tokenized logging support for nanoapps ##############################
135
136ifneq ($(CHRE_NANOAPP_TOKENIZED_LOGGING_ENABLED),)
137COMMON_CFLAGS += -DCHRE_NANOAPP_TOKENIZED_LOGGING_ENABLED
138include $(CHRE_PREFIX)/external/pigweed/pw_tokenizer.mk
139endif
140
141# Variant-specific Nanoapp Support Source Files ################################
142
143APP_SUPPORT_PATH = $(CHRE_PREFIX)/build/app_support
144SHARED_NANOAPP_LIB_PATH = $(CHRE_PREFIX)/platform/shared/nanoapp
145DSO_SUPPORT_LIB_SRCS = $(SHARED_NANOAPP_LIB_PATH)/nanoapp_support_lib_dso.cc
146STACK_CHECK_SRCS =  $(SHARED_NANOAPP_LIB_PATH)/nanoapp_stack_check.cc
147
148# Required includes for nanoapp_support_lib_dso.cc, but using a special prefix
149# directory and symlinks to effectively hide them from nanoapps
150DSO_SUPPORT_LIB_CFLAGS = -I$(CHRE_PREFIX)/platform/shared/nanoapp/include
151
152GOOGLE_HEXAGONV62_SLPI_SRCS += $(DSO_SUPPORT_LIB_SRCS)
153GOOGLE_HEXAGONV62_SLPI-UIMG_SRCS += $(DSO_SUPPORT_LIB_SRCS)
154GOOGLE_HEXAGONV65_ADSP-SEE_SRCS += $(DSO_SUPPORT_LIB_SRCS)
155GOOGLE_HEXAGONV65_ADSP-SEE-UIMG_SRCS += $(DSO_SUPPORT_LIB_SRCS)
156GOOGLE_HEXAGONV65_SLPI-SEE_SRCS += $(DSO_SUPPORT_LIB_SRCS)
157GOOGLE_HEXAGONV65_SLPI-SEE-UIMG_SRCS += $(DSO_SUPPORT_LIB_SRCS)
158GOOGLE_HEXAGONV66_ADSP-SEE_SRCS += $(DSO_SUPPORT_LIB_SRCS)
159GOOGLE_HEXAGONV66_ADSP-SEE-UIMG_SRCS += $(DSO_SUPPORT_LIB_SRCS)
160GOOGLE_HEXAGONV66_SLPI-SEE_SRCS += $(DSO_SUPPORT_LIB_SRCS)
161GOOGLE_HEXAGONV66_SLPI-SEE-UIMG_SRCS += $(DSO_SUPPORT_LIB_SRCS)
162GOOGLE_HEXAGONV66_SLPI-QSH_SRCS += $(DSO_SUPPORT_LIB_SRCS)
163GOOGLE_ARM64_ANDROID_SRCS += $(DSO_SUPPORT_LIB_SRCS)
164GOOGLE_X86_LINUX_SRCS += $(DSO_SUPPORT_LIB_SRCS)
165
166GOOGLE_HEXAGONV62_SLPI_CFLAGS += $(DSO_SUPPORT_LIB_CFLAGS)
167GOOGLE_HEXAGONV62_SLPI-UIMG_CFLAGS += $(DSO_SUPPORT_LIB_CFLAGS)
168GOOGLE_HEXAGONV65_ADSP-SEE_CFLAGS += $(DSO_SUPPORT_LIB_CFLAGS)
169GOOGLE_HEXAGONV65_ADSP-SEE-UIMG_CFLAGS += $(DSO_SUPPORT_LIB_CFLAGS)
170GOOGLE_HEXAGONV65_SLPI-SEE_CFLAGS += $(DSO_SUPPORT_LIB_CFLAGS)
171GOOGLE_HEXAGONV65_SLPI-SEE-UIMG_CFLAGS += $(DSO_SUPPORT_LIB_CFLAGS)
172GOOGLE_HEXAGONV66_ADSP-SEE_CFLAGS += $(DSO_SUPPORT_LIB_CFLAGS)
173GOOGLE_HEXAGONV66_ADSP-SEE-UIMG_CFLAGS += $(DSO_SUPPORT_LIB_CFLAGS)
174GOOGLE_HEXAGONV66_SLPI-SEE_CFLAGS += $(DSO_SUPPORT_LIB_CFLAGS)
175GOOGLE_HEXAGONV66_SLPI-SEE-UIMG_CFLAGS += $(DSO_SUPPORT_LIB_CFLAGS)
176GOOGLE_HEXAGONV66_SLPI-QSH_CFLAGS += $(DSO_SUPPORT_LIB_CFLAGS)
177GOOGLE_ARM64_ANDROID_CFLAGS += $(DSO_SUPPORT_LIB_CFLAGS)
178GOOGLE_X86_LINUX_CFLAGS += $(DSO_SUPPORT_LIB_CFLAGS)
179
180# Makefile Includes ############################################################
181
182# Standard library overrides include
183CHRE_STD_OVERRIDES_ALLOWED ?= true
184include $(CHRE_PREFIX)/std_overrides/std_overrides.mk
185
186# Common includes
187include $(CHRE_PREFIX)/build/defs.mk
188include $(CHRE_PREFIX)/build/common.mk
189
190# CHRE API version.
191include $(CHRE_PREFIX)/chre_api/chre_api_version.mk
192
193# Supported variants includes
194ifneq ($(CHRE_TARGET_EXTENSION),)
195include $(CHRE_TARGET_EXTENSION)
196endif
197include $(CHRE_PREFIX)/build/variant/aosp_cm4_exynos-embos.mk
198include $(CHRE_PREFIX)/build/variant/aosp_riscv55e03_tinysys.mk
199include $(CHRE_PREFIX)/build/variant/aosp_riscv55e300_tinysys.mk
200include $(CHRE_PREFIX)/build/variant/google_arm64_android.mk
201include $(CHRE_PREFIX)/build/variant/google_hexagonv62_slpi.mk
202include $(CHRE_PREFIX)/build/variant/google_hexagonv62_slpi-uimg.mk
203include $(CHRE_PREFIX)/build/variant/google_hexagonv65_adsp-see.mk
204include $(CHRE_PREFIX)/build/variant/google_hexagonv65_adsp-see-uimg.mk
205include $(CHRE_PREFIX)/build/variant/google_hexagonv65_slpi-see.mk
206include $(CHRE_PREFIX)/build/variant/google_hexagonv65_slpi-see-uimg.mk
207include $(CHRE_PREFIX)/build/variant/google_hexagonv66_adsp-see.mk
208include $(CHRE_PREFIX)/build/variant/google_hexagonv66_adsp-see-uimg.mk
209include $(CHRE_PREFIX)/build/variant/google_hexagonv66_slpi-see.mk
210include $(CHRE_PREFIX)/build/variant/google_hexagonv66_slpi-see-uimg.mk
211include $(CHRE_PREFIX)/build/variant/google_hexagonv66_slpi-qsh.mk
212include $(CHRE_PREFIX)/build/variant/google_x86_linux.mk
213