blob: 228b64af7be18564285d6f545c472188c840f82a [file] [log] [blame]
Dan Willemsen218f6562015-07-08 18:13:11 -07001// Copyright 2015 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package cc
16
17import (
Dan Willemsen97750522016-02-09 17:43:51 -080018 "fmt"
Dan Willemsen218f6562015-07-08 18:13:11 -070019 "io"
Colin Crossa2344662016-03-24 13:14:12 -070020 "path/filepath"
Dan Willemsen218f6562015-07-08 18:13:11 -070021 "strings"
22
Colin Cross635c3b02016-05-18 15:37:25 -070023 "android/soong/android"
Dan Willemsen218f6562015-07-08 18:13:11 -070024)
25
Jiyong Park27b188b2017-07-18 13:23:39 +090026var (
Jiyong Parkf9332f12018-02-01 00:54:12 +090027 vendorSuffix = ".vendor"
28 recoverySuffix = ".recovery"
Jiyong Park27b188b2017-07-18 13:23:39 +090029)
30
Dan Willemsenf2c27d72016-07-13 16:50:22 -070031type AndroidMkContext interface {
32 Target() android.Target
Colin Crossb916a382016-07-29 17:28:03 -070033 subAndroidMk(*android.AndroidMkData, interface{})
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070034 useVndk() bool
Colin Crossb916a382016-07-29 17:28:03 -070035}
36
37type subAndroidMkProvider interface {
38 AndroidMk(AndroidMkContext, *android.AndroidMkData)
39}
40
41func (c *Module) subAndroidMk(data *android.AndroidMkData, obj interface{}) {
42 if c.subAndroidMkOnce == nil {
43 c.subAndroidMkOnce = make(map[subAndroidMkProvider]bool)
44 }
45 if androidmk, ok := obj.(subAndroidMkProvider); ok {
46 if !c.subAndroidMkOnce[androidmk] {
47 c.subAndroidMkOnce[androidmk] = true
48 androidmk.AndroidMk(c, data)
49 }
50 }
Dan Willemsenf2c27d72016-07-13 16:50:22 -070051}
52
Colin Crossa18e9cf2017-08-10 17:00:19 -070053func (c *Module) AndroidMk() android.AndroidMkData {
Colin Crossbc6fb162016-05-24 15:39:04 -070054 if c.Properties.HideFromMake {
Colin Crossa18e9cf2017-08-10 17:00:19 -070055 return android.AndroidMkData{
56 Disabled: true,
57 }
Colin Crossbc6fb162016-05-24 15:39:04 -070058 }
59
Colin Crossa18e9cf2017-08-10 17:00:19 -070060 ret := android.AndroidMkData{
61 OutputFile: c.outputFile,
Logan Chien43d34c32017-12-20 01:17:32 +080062 Required: c.Properties.AndroidMkRuntimeLibs,
63
Colin Crossa18e9cf2017-08-10 17:00:19 -070064 Extra: []android.AndroidMkExtraFunc{
65 func(w io.Writer, outputFile android.Path) {
Colin Cross5beccee2017-12-07 15:28:59 -080066 if len(c.Properties.Logtags) > 0 {
67 fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(c.Properties.Logtags, " "))
68 }
Colin Crossa18e9cf2017-08-10 17:00:19 -070069 fmt.Fprintln(w, "LOCAL_SANITIZE := never")
70 if len(c.Properties.AndroidMkSharedLibs) > 0 {
71 fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))
72 }
Nan Zhang0007d812017-11-07 10:57:05 -080073 if c.Target().Os == android.Android &&
Jiyong Park97686282018-05-30 09:59:23 +090074 String(c.Properties.Sdk_version) != "" && !c.useVndk() && !c.inRecovery() {
Nan Zhang0007d812017-11-07 10:57:05 -080075 fmt.Fprintln(w, "LOCAL_SDK_VERSION := "+String(c.Properties.Sdk_version))
Colin Crossa18e9cf2017-08-10 17:00:19 -070076 fmt.Fprintln(w, "LOCAL_NDK_STL_VARIANT := none")
77 } else {
78 // These are already included in LOCAL_SHARED_LIBRARIES
79 fmt.Fprintln(w, "LOCAL_CXX_STL := none")
80 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070081 if c.useVndk() {
Colin Crossa18e9cf2017-08-10 17:00:19 -070082 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
83 }
84 },
85 },
86 }
Colin Crossca860ac2016-01-04 14:34:37 -080087
Colin Crossca860ac2016-01-04 14:34:37 -080088 for _, feature := range c.features {
Colin Crossb916a382016-07-29 17:28:03 -070089 c.subAndroidMk(&ret, feature)
Colin Crossca860ac2016-01-04 14:34:37 -080090 }
91
Colin Crossb916a382016-07-29 17:28:03 -070092 c.subAndroidMk(&ret, c.compiler)
93 c.subAndroidMk(&ret, c.linker)
Colin Cross8ff9ef42017-05-08 13:44:11 -070094 if c.sanitize != nil {
95 c.subAndroidMk(&ret, c.sanitize)
96 }
Colin Crossb916a382016-07-29 17:28:03 -070097 c.subAndroidMk(&ret, c.installer)
Colin Crossca860ac2016-01-04 14:34:37 -080098
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070099 if c.useVndk() && c.hasVendorVariant() {
Jiyong Park27b188b2017-07-18 13:23:39 +0900100 // .vendor suffix is added only when we will have two variants: core and vendor.
101 // The suffix is not added for vendor-only module.
102 ret.SubName += vendorSuffix
Jiyong Parkf9332f12018-02-01 00:54:12 +0900103 } else if c.inRecovery() && !c.onlyInRecovery() {
104 ret.SubName += recoverySuffix
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700105 }
106
Colin Crossa18e9cf2017-08-10 17:00:19 -0700107 return ret
Colin Crossca860ac2016-01-04 14:34:37 -0800108}
109
Anders Lewisb97e8182017-07-14 15:20:13 -0700110func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, ret *android.AndroidMkData) {
111 var testFiles []string
112 for _, d := range data {
113 rel := d.Rel()
114 path := d.String()
115 if !strings.HasSuffix(path, rel) {
116 panic(fmt.Errorf("path %q does not end with %q", path, rel))
117 }
118 path = strings.TrimSuffix(path, rel)
119 testFiles = append(testFiles, path+":"+rel)
120 }
121 if len(testFiles) > 0 {
Colin Cross27a4b052017-08-10 16:32:23 -0700122 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Anders Lewisb97e8182017-07-14 15:20:13 -0700123 fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " "))
Anders Lewisb97e8182017-07-14 15:20:13 -0700124 })
125 }
126}
127
Dan Willemsen58539402017-03-19 13:44:32 -0700128func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) {
129 exportedFlags := library.exportedFlags()
130 if len(exportedFlags) > 0 {
131 fmt.Fprintln(w, "LOCAL_EXPORT_CFLAGS :=", strings.Join(exportedFlags, " "))
Dan Willemsend5781342017-02-15 16:15:21 -0800132 }
Dan Willemsen58539402017-03-19 13:44:32 -0700133 exportedFlagsDeps := library.exportedFlagsDeps()
134 if len(exportedFlagsDeps) > 0 {
135 fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedFlagsDeps.Strings(), " "))
136 }
137}
Dan Willemsend5781342017-02-15 16:15:21 -0800138
Dan Willemsen58539402017-03-19 13:44:32 -0700139func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsend5781342017-02-15 16:15:21 -0800140 if library.static() {
141 ret.Class = "STATIC_LIBRARIES"
142 } else if library.shared() {
143 ctx.subAndroidMk(ret, &library.stripper)
144 ctx.subAndroidMk(ret, &library.relocationPacker)
145
146 ret.Class = "SHARED_LIBRARIES"
147 } else if library.header() {
Colin Cross0f86d182017-08-10 17:07:28 -0700148 ret.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
Dan Willemsend5781342017-02-15 16:15:21 -0800149 fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
150 fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
Colin Cross0f86d182017-08-10 17:07:28 -0700151 fmt.Fprintln(w, "LOCAL_MODULE :=", name+data.SubName)
Dan Willemsend5781342017-02-15 16:15:21 -0800152
153 archStr := ctx.Target().Arch.ArchType.String()
154 var host bool
155 switch ctx.Target().Os.Class {
156 case android.Host:
157 fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH := ", archStr)
158 host = true
159 case android.HostCross:
160 fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH := ", archStr)
161 host = true
162 case android.Device:
163 fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH := ", archStr)
164 }
165
166 if host {
Dan Willemsen866b5632017-09-22 12:28:24 -0700167 makeOs := ctx.Target().Os.String()
168 if ctx.Target().Os == android.Linux || ctx.Target().Os == android.LinuxBionic {
169 makeOs = "linux"
170 }
171 fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", makeOs)
Dan Willemsend5781342017-02-15 16:15:21 -0800172 fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700173 } else if ctx.useVndk() {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700174 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
Dan Willemsend5781342017-02-15 16:15:21 -0800175 }
176
Dan Willemsen58539402017-03-19 13:44:32 -0700177 library.androidMkWriteExportedFlags(w)
Dan Willemsend5781342017-02-15 16:15:21 -0800178 fmt.Fprintln(w, "include $(BUILD_HEADER_LIBRARY)")
Dan Willemsend5781342017-02-15 16:15:21 -0800179 }
180
181 return
182 }
183
Colin Cross27a4b052017-08-10 16:32:23 -0700184 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsen58539402017-03-19 13:44:32 -0700185 library.androidMkWriteExportedFlags(w)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800186 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES := ")
187 if library.sAbiOutputFile.Valid() {
188 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiOutputFile.String())
189 if library.sAbiDiff.Valid() && !library.static() {
190 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiDiff.String())
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700191 fmt.Fprintln(w, "HEADER_ABI_DIFFS += ", library.sAbiDiff.String())
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800192 }
193 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700194
Dan Willemsen1d577e22016-08-29 15:53:15 -0700195 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())
Dan Willemsen218f6562015-07-08 18:13:11 -0700196
Dan Willemsen97750522016-02-09 17:43:51 -0800197 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
Dan Willemsen218f6562015-07-08 18:13:11 -0700198
Dan Willemsen581341d2017-02-09 16:16:31 -0800199 if library.coverageOutputFile.Valid() {
200 fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", library.coverageOutputFile.String())
201 }
Colin Crossca860ac2016-01-04 14:34:37 -0800202 })
Colin Crossb916a382016-07-29 17:28:03 -0700203
Colin Cross4ac44802017-02-15 14:06:12 -0800204 if library.shared() {
Colin Crossb916a382016-07-29 17:28:03 -0700205 ctx.subAndroidMk(ret, library.baseInstaller)
206 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700207}
208
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700209func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross0f86d182017-08-10 17:07:28 -0700210 ret.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
Colin Crossca860ac2016-01-04 14:34:37 -0800211 out := ret.OutputFile.Path()
Dan Willemsen218f6562015-07-08 18:13:11 -0700212
Colin Cross0f86d182017-08-10 17:07:28 -0700213 fmt.Fprintln(w, "\n$("+prefix+"OUT_INTERMEDIATE_LIBRARIES)/"+name+data.SubName+objectExtension+":", out.String())
Dan Willemsen97750522016-02-09 17:43:51 -0800214 fmt.Fprintln(w, "\t$(copy-file-to-target)")
Dan Willemsen218f6562015-07-08 18:13:11 -0700215 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700216}
217
Colin Crossb916a382016-07-29 17:28:03 -0700218func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross1e7d3702016-08-24 15:25:47 -0700219 ctx.subAndroidMk(ret, binary.baseInstaller)
Colin Crossb916a382016-07-29 17:28:03 -0700220 ctx.subAndroidMk(ret, &binary.stripper)
Dan Willemsen7517ed02016-06-10 17:20:30 -0700221
Dan Willemsen218f6562015-07-08 18:13:11 -0700222 ret.Class = "EXECUTABLES"
Colin Cross27a4b052017-08-10 16:32:23 -0700223 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsen97750522016-02-09 17:43:51 -0800224 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
Colin Crossb916a382016-07-29 17:28:03 -0700225 if Bool(binary.Properties.Static_executable) {
Colin Cross3854a602016-01-11 12:49:11 -0800226 fmt.Fprintln(w, "LOCAL_FORCE_STATIC_EXECUTABLE := true")
227 }
Colin Cross9b09f242016-12-07 13:37:42 -0800228
229 if len(binary.symlinks) > 0 {
230 fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS := "+strings.Join(binary.symlinks, " "))
231 }
232
Dan Willemsen581341d2017-02-09 16:16:31 -0800233 if binary.coverageOutputFile.Valid() {
234 fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", binary.coverageOutputFile.String())
235 }
Yifan Hong946e32e2018-04-03 13:22:50 -0700236
237 if len(binary.Properties.Overrides) > 0 {
238 fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES := "+strings.Join(binary.Properties.Overrides, " "))
239 }
Colin Crossca860ac2016-01-04 14:34:37 -0800240 })
241}
242
Colin Crossb916a382016-07-29 17:28:03 -0700243func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
244 ctx.subAndroidMk(ret, benchmark.binaryDecorator)
Dan Willemsen58a5c8b2017-05-23 15:10:37 -0700245 ret.Class = "NATIVE_TESTS"
Colin Cross27a4b052017-08-10 16:32:23 -0700246 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crosse28f4e22017-04-24 18:10:29 -0700247 if len(benchmark.Properties.Test_suites) > 0 {
248 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
249 strings.Join(benchmark.Properties.Test_suites, " "))
250 }
Julien Despreze146e392018-08-02 15:00:46 -0700251 if benchmark.Properties.Test_config != nil {
252 fmt.Fprintln(w, "LOCAL_TEST_CONFIG :=",
253 benchmark.Properties.Test_config)
254 }
Nelson Li1f6b14e2018-04-18 16:55:21 +0000255 fmt.Fprintln(w, "LOCAL_NATIVE_BENCHMARK := true")
Colin Crosse28f4e22017-04-24 18:10:29 -0700256 })
Anders Lewisb97e8182017-07-14 15:20:13 -0700257
258 androidMkWriteTestData(benchmark.data, ctx, ret)
Colin Crossb916a382016-07-29 17:28:03 -0700259}
260
261func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
262 ctx.subAndroidMk(ret, test.binaryDecorator)
Dan Willemsen0fe72532017-01-17 13:25:49 -0800263 ret.Class = "NATIVE_TESTS"
Colin Crossb916a382016-07-29 17:28:03 -0700264 if Bool(test.Properties.Test_per_src) {
Nan Zhang0007d812017-11-07 10:57:05 -0800265 ret.SubName = "_" + String(test.binaryDecorator.Properties.Stem)
Colin Crossa2344662016-03-24 13:14:12 -0700266 }
Colin Crossfaeb7aa2017-02-01 14:12:44 -0800267
Colin Cross27a4b052017-08-10 16:32:23 -0700268 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa929db02017-03-27 16:27:50 -0700269 if len(test.Properties.Test_suites) > 0 {
Dan Shi4df566d2017-04-03 12:29:25 -0700270 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
Colin Crossa929db02017-03-27 16:27:50 -0700271 strings.Join(test.Properties.Test_suites, " "))
272 }
Julien Despreze146e392018-08-02 15:00:46 -0700273 if test.Properties.Test_config != nil {
274 fmt.Fprintln(w, "LOCAL_TEST_CONFIG :=",
275 test.Properties.Test_config)
276 }
Colin Crossa929db02017-03-27 16:27:50 -0700277 })
278
Anders Lewisb97e8182017-07-14 15:20:13 -0700279 androidMkWriteTestData(test.data, ctx, ret)
Colin Crossa2344662016-03-24 13:14:12 -0700280}
281
Colin Crossb916a382016-07-29 17:28:03 -0700282func (test *testLibrary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
283 ctx.subAndroidMk(ret, test.libraryDecorator)
284}
Dan Willemsene7932e82016-05-16 15:56:53 -0700285
Colin Crossb916a382016-07-29 17:28:03 -0700286func (library *toolchainLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
287 ret.Class = "STATIC_LIBRARIES"
Colin Cross27a4b052017-08-10 16:32:23 -0700288 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsene7932e82016-05-16 15:56:53 -0700289 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext())
Dan Willemsene7932e82016-05-16 15:56:53 -0700290 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
Dan Willemsene7932e82016-05-16 15:56:53 -0700291 })
292}
293
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700294func (stripper *stripper) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
295 // Make only supports stripping target modules
296 if ctx.Target().Os != android.Android {
297 return
298 }
299
Colin Cross27a4b052017-08-10 16:32:23 -0700300 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Nan Zhang0007d812017-11-07 10:57:05 -0800301 if Bool(stripper.StripProperties.Strip.None) {
302
Dan Willemsen7517ed02016-06-10 17:20:30 -0700303 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
Nan Zhang0007d812017-11-07 10:57:05 -0800304 } else if Bool(stripper.StripProperties.Strip.Keep_symbols) {
Dan Willemsen7517ed02016-06-10 17:20:30 -0700305 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := keep_symbols")
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700306 } else {
307 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := mini-debug-info")
Dan Willemsen7517ed02016-06-10 17:20:30 -0700308 }
Dan Willemsen7517ed02016-06-10 17:20:30 -0700309 })
310}
311
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700312func (packer *relocationPacker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross27a4b052017-08-10 16:32:23 -0700313 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700314 if packer.Properties.PackingRelocations {
315 fmt.Fprintln(w, "LOCAL_PACK_MODULE_RELOCATIONS := true")
316 }
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700317 })
318}
319
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700320func (installer *baseInstaller) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsen03ce63e2016-09-29 12:17:49 -0700321 // Soong installation is only supported for host modules. Have Make
322 // installation trigger Soong installation.
323 if ctx.Target().Os.Class == android.Host {
324 ret.OutputFile = android.OptionalPathForPath(installer.path)
325 }
326
Colin Cross27a4b052017-08-10 16:32:23 -0700327 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa2344662016-03-24 13:14:12 -0700328 path := installer.path.RelPathString()
Colin Crossbf305de2016-03-29 17:32:06 -0700329 dir, file := filepath.Split(path)
330 stem := strings.TrimSuffix(file, filepath.Ext(file))
Dan Willemsen1d577e22016-08-29 15:53:15 -0700331 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file))
Colin Crosse14388b2016-05-03 14:08:40 -0700332 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir))
Colin Crossbf305de2016-03-29 17:32:06 -0700333 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
Colin Crossa2344662016-03-24 13:14:12 -0700334 })
Dan Willemsen218f6562015-07-08 18:13:11 -0700335}
Dan Albert914449f2016-06-17 16:45:24 -0700336
Colin Crossb916a382016-07-29 17:28:03 -0700337func (c *stubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsen01a90592017-04-07 15:21:13 -0700338 ret.SubName = ndkLibrarySuffix + "." + c.properties.ApiLevel
Dan Albert705c84b2016-08-08 10:45:03 -0700339 ret.Class = "SHARED_LIBRARIES"
Dan Albert914449f2016-06-17 16:45:24 -0700340
Colin Cross27a4b052017-08-10 16:32:23 -0700341 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Cross0875c522017-11-28 17:34:01 -0800342 path, file := filepath.Split(c.installPath.String())
Dan Albert914449f2016-06-17 16:45:24 -0700343 stem := strings.TrimSuffix(file, filepath.Ext(file))
Dan Albertcdd4c242016-08-08 14:44:56 -0700344 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
345 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext())
Dan Albert914449f2016-06-17 16:45:24 -0700346 fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path)
347 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
Dan Willemsen866810d2017-04-04 14:13:45 -0700348 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
Dan Albert914449f2016-06-17 16:45:24 -0700349
350 // Prevent make from installing the libraries to obj/lib (since we have
351 // dozens of libraries with the same name, they'll clobber each other
352 // and the real versions of the libraries from the platform).
353 fmt.Fprintln(w, "LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES := false")
Dan Albert914449f2016-06-17 16:45:24 -0700354 })
355}
Dan Willemsenb916b802017-03-19 13:44:32 -0700356
357func (c *llndkStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
358 ret.Class = "SHARED_LIBRARIES"
Jiyong Parkf9332f12018-02-01 00:54:12 +0900359 ret.SubName = vendorSuffix
Dan Willemsenb916b802017-03-19 13:44:32 -0700360
Colin Cross27a4b052017-08-10 16:32:23 -0700361 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsenb916b802017-03-19 13:44:32 -0700362 c.libraryDecorator.androidMkWriteExportedFlags(w)
363
364 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())
365 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
366 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
367 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
368 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700369 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
Dan Willemsenb916b802017-03-19 13:44:32 -0700370 })
371}
Justin Yun71549282017-11-17 12:10:28 +0900372
373func (c *vndkPrebuiltLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
374 ret.Class = "SHARED_LIBRARIES"
375
Jae Shin43ef2642017-12-29 16:20:21 +0900376 ret.SubName = c.NameSuffix()
Justin Yun71549282017-11-17 12:10:28 +0900377
378 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
379 c.libraryDecorator.androidMkWriteExportedFlags(w)
380
381 path := c.path.RelPathString()
382 dir, file := filepath.Split(path)
383 stem := strings.TrimSuffix(file, filepath.Ext(file))
384 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
385 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
386 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
387 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())
388 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file))
389 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir))
390 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
391 })
Colin Cross7a6fcbe2017-12-06 13:08:00 -0800392}
Dan Albert8ba131b2017-12-14 13:23:15 -0800393
394func (c *ndkPrebuiltStlLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
395 ret.Class = "SHARED_LIBRARIES"
396
397 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
398 // Prevent make from installing the libraries to obj/lib (since we have
399 // dozens of libraries with the same name, they'll clobber each other
400 // and the real versions of the libraries from the platform).
401 fmt.Fprintln(w, "LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES := false")
402 })
403}
Jiyong Park374510b2018-03-19 18:23:01 +0900404
405func (c *vendorPublicLibraryStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
406 ret.Class = "SHARED_LIBRARIES"
407 ret.SubName = vendorPublicLibrarySuffix
408
409 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
410 c.libraryDecorator.androidMkWriteExportedFlags(w)
411
412 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())
413 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
414 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
415 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
416 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
417 })
418}