blob: efd4ee73d61cdf5a3e7239b2bdb066f967c22cf6 [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 (
27 vendorSuffix = ".vendor"
28)
29
Dan Willemsenf2c27d72016-07-13 16:50:22 -070030type AndroidMkContext interface {
31 Target() android.Target
Colin Crossb916a382016-07-29 17:28:03 -070032 subAndroidMk(*android.AndroidMkData, interface{})
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070033 useVndk() bool
Colin Crossb916a382016-07-29 17:28:03 -070034}
35
36type subAndroidMkProvider interface {
37 AndroidMk(AndroidMkContext, *android.AndroidMkData)
38}
39
40func (c *Module) subAndroidMk(data *android.AndroidMkData, obj interface{}) {
41 if c.subAndroidMkOnce == nil {
42 c.subAndroidMkOnce = make(map[subAndroidMkProvider]bool)
43 }
44 if androidmk, ok := obj.(subAndroidMkProvider); ok {
45 if !c.subAndroidMkOnce[androidmk] {
46 c.subAndroidMkOnce[androidmk] = true
47 androidmk.AndroidMk(c, data)
48 }
49 }
Dan Willemsenf2c27d72016-07-13 16:50:22 -070050}
51
Colin Crossa18e9cf2017-08-10 17:00:19 -070052func (c *Module) AndroidMk() android.AndroidMkData {
Colin Crossbc6fb162016-05-24 15:39:04 -070053 if c.Properties.HideFromMake {
Colin Crossa18e9cf2017-08-10 17:00:19 -070054 return android.AndroidMkData{
55 Disabled: true,
56 }
Colin Crossbc6fb162016-05-24 15:39:04 -070057 }
58
Colin Crossa18e9cf2017-08-10 17:00:19 -070059 ret := android.AndroidMkData{
60 OutputFile: c.outputFile,
61 Extra: []android.AndroidMkExtraFunc{
62 func(w io.Writer, outputFile android.Path) {
Colin Cross5beccee2017-12-07 15:28:59 -080063 if len(c.Properties.Logtags) > 0 {
64 fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(c.Properties.Logtags, " "))
65 }
Colin Crossa18e9cf2017-08-10 17:00:19 -070066 fmt.Fprintln(w, "LOCAL_SANITIZE := never")
67 if len(c.Properties.AndroidMkSharedLibs) > 0 {
68 fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))
69 }
Nan Zhang0007d812017-11-07 10:57:05 -080070 if c.Target().Os == android.Android &&
71 String(c.Properties.Sdk_version) != "" && !c.useVndk() {
72 fmt.Fprintln(w, "LOCAL_SDK_VERSION := "+String(c.Properties.Sdk_version))
Colin Crossa18e9cf2017-08-10 17:00:19 -070073 fmt.Fprintln(w, "LOCAL_NDK_STL_VARIANT := none")
74 } else {
75 // These are already included in LOCAL_SHARED_LIBRARIES
76 fmt.Fprintln(w, "LOCAL_CXX_STL := none")
77 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070078 if c.useVndk() {
Colin Crossa18e9cf2017-08-10 17:00:19 -070079 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
80 }
81 },
82 },
83 }
Colin Crossca860ac2016-01-04 14:34:37 -080084
Colin Crossca860ac2016-01-04 14:34:37 -080085 for _, feature := range c.features {
Colin Crossb916a382016-07-29 17:28:03 -070086 c.subAndroidMk(&ret, feature)
Colin Crossca860ac2016-01-04 14:34:37 -080087 }
88
Colin Crossb916a382016-07-29 17:28:03 -070089 c.subAndroidMk(&ret, c.compiler)
90 c.subAndroidMk(&ret, c.linker)
Colin Cross8ff9ef42017-05-08 13:44:11 -070091 if c.sanitize != nil {
92 c.subAndroidMk(&ret, c.sanitize)
93 }
Colin Crossb916a382016-07-29 17:28:03 -070094 c.subAndroidMk(&ret, c.installer)
Colin Crossca860ac2016-01-04 14:34:37 -080095
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070096 if c.useVndk() && c.hasVendorVariant() {
Jiyong Park27b188b2017-07-18 13:23:39 +090097 // .vendor suffix is added only when we will have two variants: core and vendor.
98 // The suffix is not added for vendor-only module.
99 ret.SubName += vendorSuffix
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700100 }
101
Colin Crossa18e9cf2017-08-10 17:00:19 -0700102 return ret
Colin Crossca860ac2016-01-04 14:34:37 -0800103}
104
Anders Lewisb97e8182017-07-14 15:20:13 -0700105func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, ret *android.AndroidMkData) {
106 var testFiles []string
107 for _, d := range data {
108 rel := d.Rel()
109 path := d.String()
110 if !strings.HasSuffix(path, rel) {
111 panic(fmt.Errorf("path %q does not end with %q", path, rel))
112 }
113 path = strings.TrimSuffix(path, rel)
114 testFiles = append(testFiles, path+":"+rel)
115 }
116 if len(testFiles) > 0 {
Colin Cross27a4b052017-08-10 16:32:23 -0700117 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Anders Lewisb97e8182017-07-14 15:20:13 -0700118 fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " "))
Anders Lewisb97e8182017-07-14 15:20:13 -0700119 })
120 }
121}
122
Dan Willemsen58539402017-03-19 13:44:32 -0700123func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) {
124 exportedFlags := library.exportedFlags()
125 if len(exportedFlags) > 0 {
126 fmt.Fprintln(w, "LOCAL_EXPORT_CFLAGS :=", strings.Join(exportedFlags, " "))
Dan Willemsend5781342017-02-15 16:15:21 -0800127 }
Dan Willemsen58539402017-03-19 13:44:32 -0700128 exportedFlagsDeps := library.exportedFlagsDeps()
129 if len(exportedFlagsDeps) > 0 {
130 fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedFlagsDeps.Strings(), " "))
131 }
132}
Dan Willemsend5781342017-02-15 16:15:21 -0800133
Dan Willemsen58539402017-03-19 13:44:32 -0700134func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsend5781342017-02-15 16:15:21 -0800135 if library.static() {
136 ret.Class = "STATIC_LIBRARIES"
137 } else if library.shared() {
138 ctx.subAndroidMk(ret, &library.stripper)
139 ctx.subAndroidMk(ret, &library.relocationPacker)
140
141 ret.Class = "SHARED_LIBRARIES"
142 } else if library.header() {
Colin Cross0f86d182017-08-10 17:07:28 -0700143 ret.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
Dan Willemsend5781342017-02-15 16:15:21 -0800144 fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
145 fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
Colin Cross0f86d182017-08-10 17:07:28 -0700146 fmt.Fprintln(w, "LOCAL_MODULE :=", name+data.SubName)
Dan Willemsend5781342017-02-15 16:15:21 -0800147
148 archStr := ctx.Target().Arch.ArchType.String()
149 var host bool
150 switch ctx.Target().Os.Class {
151 case android.Host:
152 fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH := ", archStr)
153 host = true
154 case android.HostCross:
155 fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH := ", archStr)
156 host = true
157 case android.Device:
158 fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH := ", archStr)
159 }
160
161 if host {
Dan Willemsen866b5632017-09-22 12:28:24 -0700162 makeOs := ctx.Target().Os.String()
163 if ctx.Target().Os == android.Linux || ctx.Target().Os == android.LinuxBionic {
164 makeOs = "linux"
165 }
166 fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", makeOs)
Dan Willemsend5781342017-02-15 16:15:21 -0800167 fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700168 } else if ctx.useVndk() {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700169 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
Dan Willemsend5781342017-02-15 16:15:21 -0800170 }
171
Dan Willemsen58539402017-03-19 13:44:32 -0700172 library.androidMkWriteExportedFlags(w)
Dan Willemsend5781342017-02-15 16:15:21 -0800173 fmt.Fprintln(w, "include $(BUILD_HEADER_LIBRARY)")
Dan Willemsend5781342017-02-15 16:15:21 -0800174 }
175
176 return
177 }
178
Colin Cross27a4b052017-08-10 16:32:23 -0700179 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsen58539402017-03-19 13:44:32 -0700180 library.androidMkWriteExportedFlags(w)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800181 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES := ")
182 if library.sAbiOutputFile.Valid() {
183 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiOutputFile.String())
184 if library.sAbiDiff.Valid() && !library.static() {
185 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiDiff.String())
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700186 fmt.Fprintln(w, "HEADER_ABI_DIFFS += ", library.sAbiDiff.String())
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800187 }
188 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700189
Dan Willemsen1d577e22016-08-29 15:53:15 -0700190 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())
Dan Willemsen218f6562015-07-08 18:13:11 -0700191
Dan Willemsen97750522016-02-09 17:43:51 -0800192 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
Dan Willemsen218f6562015-07-08 18:13:11 -0700193
Dan Willemsen581341d2017-02-09 16:16:31 -0800194 if library.coverageOutputFile.Valid() {
195 fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", library.coverageOutputFile.String())
196 }
Colin Crossca860ac2016-01-04 14:34:37 -0800197 })
Colin Crossb916a382016-07-29 17:28:03 -0700198
Colin Cross4ac44802017-02-15 14:06:12 -0800199 if library.shared() {
Colin Crossb916a382016-07-29 17:28:03 -0700200 ctx.subAndroidMk(ret, library.baseInstaller)
201 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700202}
203
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700204func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross0f86d182017-08-10 17:07:28 -0700205 ret.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
Colin Crossca860ac2016-01-04 14:34:37 -0800206 out := ret.OutputFile.Path()
Dan Willemsen218f6562015-07-08 18:13:11 -0700207
Colin Cross0f86d182017-08-10 17:07:28 -0700208 fmt.Fprintln(w, "\n$("+prefix+"OUT_INTERMEDIATE_LIBRARIES)/"+name+data.SubName+objectExtension+":", out.String())
Dan Willemsen97750522016-02-09 17:43:51 -0800209 fmt.Fprintln(w, "\t$(copy-file-to-target)")
Dan Willemsen218f6562015-07-08 18:13:11 -0700210 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700211}
212
Colin Crossb916a382016-07-29 17:28:03 -0700213func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross1e7d3702016-08-24 15:25:47 -0700214 ctx.subAndroidMk(ret, binary.baseInstaller)
Colin Crossb916a382016-07-29 17:28:03 -0700215 ctx.subAndroidMk(ret, &binary.stripper)
Dan Willemsen7517ed02016-06-10 17:20:30 -0700216
Dan Willemsen218f6562015-07-08 18:13:11 -0700217 ret.Class = "EXECUTABLES"
Colin Cross27a4b052017-08-10 16:32:23 -0700218 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsen97750522016-02-09 17:43:51 -0800219 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
Colin Crossb916a382016-07-29 17:28:03 -0700220 if Bool(binary.Properties.Static_executable) {
Colin Cross3854a602016-01-11 12:49:11 -0800221 fmt.Fprintln(w, "LOCAL_FORCE_STATIC_EXECUTABLE := true")
222 }
Colin Cross9b09f242016-12-07 13:37:42 -0800223
224 if len(binary.symlinks) > 0 {
225 fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS := "+strings.Join(binary.symlinks, " "))
226 }
227
Dan Willemsen581341d2017-02-09 16:16:31 -0800228 if binary.coverageOutputFile.Valid() {
229 fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", binary.coverageOutputFile.String())
230 }
Colin Crossca860ac2016-01-04 14:34:37 -0800231 })
232}
233
Colin Crossb916a382016-07-29 17:28:03 -0700234func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
235 ctx.subAndroidMk(ret, benchmark.binaryDecorator)
Dan Willemsen58a5c8b2017-05-23 15:10:37 -0700236 ret.Class = "NATIVE_TESTS"
Colin Cross27a4b052017-08-10 16:32:23 -0700237 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crosse28f4e22017-04-24 18:10:29 -0700238 if len(benchmark.Properties.Test_suites) > 0 {
239 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
240 strings.Join(benchmark.Properties.Test_suites, " "))
241 }
Colin Crosse28f4e22017-04-24 18:10:29 -0700242 })
Anders Lewisb97e8182017-07-14 15:20:13 -0700243
244 androidMkWriteTestData(benchmark.data, ctx, ret)
Colin Crossb916a382016-07-29 17:28:03 -0700245}
246
247func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
248 ctx.subAndroidMk(ret, test.binaryDecorator)
Dan Willemsen0fe72532017-01-17 13:25:49 -0800249 ret.Class = "NATIVE_TESTS"
Colin Crossb916a382016-07-29 17:28:03 -0700250 if Bool(test.Properties.Test_per_src) {
Nan Zhang0007d812017-11-07 10:57:05 -0800251 ret.SubName = "_" + String(test.binaryDecorator.Properties.Stem)
Colin Crossa2344662016-03-24 13:14:12 -0700252 }
Colin Crossfaeb7aa2017-02-01 14:12:44 -0800253
Colin Cross27a4b052017-08-10 16:32:23 -0700254 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa929db02017-03-27 16:27:50 -0700255 if len(test.Properties.Test_suites) > 0 {
Dan Shi4df566d2017-04-03 12:29:25 -0700256 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
Colin Crossa929db02017-03-27 16:27:50 -0700257 strings.Join(test.Properties.Test_suites, " "))
258 }
Colin Crossa929db02017-03-27 16:27:50 -0700259 })
260
Anders Lewisb97e8182017-07-14 15:20:13 -0700261 androidMkWriteTestData(test.data, ctx, ret)
Colin Crossa2344662016-03-24 13:14:12 -0700262}
263
Colin Crossb916a382016-07-29 17:28:03 -0700264func (test *testLibrary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
265 ctx.subAndroidMk(ret, test.libraryDecorator)
266}
Dan Willemsene7932e82016-05-16 15:56:53 -0700267
Colin Crossb916a382016-07-29 17:28:03 -0700268func (library *toolchainLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
269 ret.Class = "STATIC_LIBRARIES"
Colin Cross27a4b052017-08-10 16:32:23 -0700270 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsene7932e82016-05-16 15:56:53 -0700271 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext())
Dan Willemsene7932e82016-05-16 15:56:53 -0700272 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
Dan Willemsene7932e82016-05-16 15:56:53 -0700273 })
274}
275
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700276func (stripper *stripper) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
277 // Make only supports stripping target modules
278 if ctx.Target().Os != android.Android {
279 return
280 }
281
Colin Cross27a4b052017-08-10 16:32:23 -0700282 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Nan Zhang0007d812017-11-07 10:57:05 -0800283 if Bool(stripper.StripProperties.Strip.None) {
284
Dan Willemsen7517ed02016-06-10 17:20:30 -0700285 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
Nan Zhang0007d812017-11-07 10:57:05 -0800286 } else if Bool(stripper.StripProperties.Strip.Keep_symbols) {
Dan Willemsen7517ed02016-06-10 17:20:30 -0700287 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := keep_symbols")
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700288 } else {
289 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := mini-debug-info")
Dan Willemsen7517ed02016-06-10 17:20:30 -0700290 }
Dan Willemsen7517ed02016-06-10 17:20:30 -0700291 })
292}
293
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700294func (packer *relocationPacker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross27a4b052017-08-10 16:32:23 -0700295 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700296 if packer.Properties.PackingRelocations {
297 fmt.Fprintln(w, "LOCAL_PACK_MODULE_RELOCATIONS := true")
298 }
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700299 })
300}
301
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700302func (installer *baseInstaller) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsen03ce63e2016-09-29 12:17:49 -0700303 // Soong installation is only supported for host modules. Have Make
304 // installation trigger Soong installation.
305 if ctx.Target().Os.Class == android.Host {
306 ret.OutputFile = android.OptionalPathForPath(installer.path)
307 }
308
Colin Cross27a4b052017-08-10 16:32:23 -0700309 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa2344662016-03-24 13:14:12 -0700310 path := installer.path.RelPathString()
Colin Crossbf305de2016-03-29 17:32:06 -0700311 dir, file := filepath.Split(path)
312 stem := strings.TrimSuffix(file, filepath.Ext(file))
Dan Willemsen1d577e22016-08-29 15:53:15 -0700313 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file))
Colin Crosse14388b2016-05-03 14:08:40 -0700314 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir))
Colin Crossbf305de2016-03-29 17:32:06 -0700315 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
Colin Crossa2344662016-03-24 13:14:12 -0700316 })
Dan Willemsen218f6562015-07-08 18:13:11 -0700317}
Dan Albert914449f2016-06-17 16:45:24 -0700318
Colin Crossb916a382016-07-29 17:28:03 -0700319func (c *stubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsen01a90592017-04-07 15:21:13 -0700320 ret.SubName = ndkLibrarySuffix + "." + c.properties.ApiLevel
Dan Albert705c84b2016-08-08 10:45:03 -0700321 ret.Class = "SHARED_LIBRARIES"
Dan Albert914449f2016-06-17 16:45:24 -0700322
Colin Cross27a4b052017-08-10 16:32:23 -0700323 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Cross0875c522017-11-28 17:34:01 -0800324 path, file := filepath.Split(c.installPath.String())
Dan Albert914449f2016-06-17 16:45:24 -0700325 stem := strings.TrimSuffix(file, filepath.Ext(file))
Dan Albertcdd4c242016-08-08 14:44:56 -0700326 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
327 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext())
Dan Albert914449f2016-06-17 16:45:24 -0700328 fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path)
329 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
Dan Willemsen866810d2017-04-04 14:13:45 -0700330 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
Dan Albert914449f2016-06-17 16:45:24 -0700331
332 // Prevent make from installing the libraries to obj/lib (since we have
333 // dozens of libraries with the same name, they'll clobber each other
334 // and the real versions of the libraries from the platform).
335 fmt.Fprintln(w, "LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES := false")
Dan Albert914449f2016-06-17 16:45:24 -0700336 })
337}
Dan Willemsenb916b802017-03-19 13:44:32 -0700338
339func (c *llndkStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
340 ret.Class = "SHARED_LIBRARIES"
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700341 ret.SubName = ".vendor"
Dan Willemsenb916b802017-03-19 13:44:32 -0700342
Colin Cross27a4b052017-08-10 16:32:23 -0700343 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsenb916b802017-03-19 13:44:32 -0700344 c.libraryDecorator.androidMkWriteExportedFlags(w)
345
346 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())
347 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
348 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
349 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
350 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700351 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
Dan Willemsenb916b802017-03-19 13:44:32 -0700352 })
353}
Justin Yun71549282017-11-17 12:10:28 +0900354
355func (c *vndkPrebuiltLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
356 ret.Class = "SHARED_LIBRARIES"
357
358 ret.SubName = vndkSuffix + c.version()
359
360 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
361 c.libraryDecorator.androidMkWriteExportedFlags(w)
362
363 path := c.path.RelPathString()
364 dir, file := filepath.Split(path)
365 stem := strings.TrimSuffix(file, filepath.Ext(file))
366 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
367 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
368 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
369 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())
370 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file))
371 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir))
372 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
373 })
Colin Cross7a6fcbe2017-12-06 13:08:00 -0800374}
Dan Albert8ba131b2017-12-14 13:23:15 -0800375
376func (c *ndkPrebuiltStlLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
377 ret.Class = "SHARED_LIBRARIES"
378
379 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
380 // Prevent make from installing the libraries to obj/lib (since we have
381 // dozens of libraries with the same name, they'll clobber each other
382 // and the real versions of the libraries from the platform).
383 fmt.Fprintln(w, "LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES := false")
384 })
385}