blob: cdd4a5a391fd12106d347ad170236b4c185aaf7f [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,
Logan Chien43d34c32017-12-20 01:17:32 +080061 Required: c.Properties.AndroidMkRuntimeLibs,
62
Colin Crossa18e9cf2017-08-10 17:00:19 -070063 Extra: []android.AndroidMkExtraFunc{
64 func(w io.Writer, outputFile android.Path) {
Colin Cross5beccee2017-12-07 15:28:59 -080065 if len(c.Properties.Logtags) > 0 {
66 fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(c.Properties.Logtags, " "))
67 }
Colin Crossa18e9cf2017-08-10 17:00:19 -070068 fmt.Fprintln(w, "LOCAL_SANITIZE := never")
69 if len(c.Properties.AndroidMkSharedLibs) > 0 {
70 fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))
71 }
Nan Zhang0007d812017-11-07 10:57:05 -080072 if c.Target().Os == android.Android &&
73 String(c.Properties.Sdk_version) != "" && !c.useVndk() {
74 fmt.Fprintln(w, "LOCAL_SDK_VERSION := "+String(c.Properties.Sdk_version))
Colin Crossa18e9cf2017-08-10 17:00:19 -070075 fmt.Fprintln(w, "LOCAL_NDK_STL_VARIANT := none")
76 } else {
77 // These are already included in LOCAL_SHARED_LIBRARIES
78 fmt.Fprintln(w, "LOCAL_CXX_STL := none")
79 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070080 if c.useVndk() {
Colin Crossa18e9cf2017-08-10 17:00:19 -070081 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
82 }
83 },
84 },
85 }
Colin Crossca860ac2016-01-04 14:34:37 -080086
Colin Crossca860ac2016-01-04 14:34:37 -080087 for _, feature := range c.features {
Colin Crossb916a382016-07-29 17:28:03 -070088 c.subAndroidMk(&ret, feature)
Colin Crossca860ac2016-01-04 14:34:37 -080089 }
90
Colin Crossb916a382016-07-29 17:28:03 -070091 c.subAndroidMk(&ret, c.compiler)
92 c.subAndroidMk(&ret, c.linker)
Colin Cross8ff9ef42017-05-08 13:44:11 -070093 if c.sanitize != nil {
94 c.subAndroidMk(&ret, c.sanitize)
95 }
Colin Crossb916a382016-07-29 17:28:03 -070096 c.subAndroidMk(&ret, c.installer)
Colin Crossca860ac2016-01-04 14:34:37 -080097
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070098 if c.useVndk() && c.hasVendorVariant() {
Jiyong Park27b188b2017-07-18 13:23:39 +090099 // .vendor suffix is added only when we will have two variants: core and vendor.
100 // The suffix is not added for vendor-only module.
101 ret.SubName += vendorSuffix
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700102 }
103
Colin Crossa18e9cf2017-08-10 17:00:19 -0700104 return ret
Colin Crossca860ac2016-01-04 14:34:37 -0800105}
106
Anders Lewisb97e8182017-07-14 15:20:13 -0700107func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, ret *android.AndroidMkData) {
108 var testFiles []string
109 for _, d := range data {
110 rel := d.Rel()
111 path := d.String()
112 if !strings.HasSuffix(path, rel) {
113 panic(fmt.Errorf("path %q does not end with %q", path, rel))
114 }
115 path = strings.TrimSuffix(path, rel)
116 testFiles = append(testFiles, path+":"+rel)
117 }
118 if len(testFiles) > 0 {
Colin Cross27a4b052017-08-10 16:32:23 -0700119 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Anders Lewisb97e8182017-07-14 15:20:13 -0700120 fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " "))
Anders Lewisb97e8182017-07-14 15:20:13 -0700121 })
122 }
123}
124
Dan Willemsen58539402017-03-19 13:44:32 -0700125func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) {
126 exportedFlags := library.exportedFlags()
127 if len(exportedFlags) > 0 {
128 fmt.Fprintln(w, "LOCAL_EXPORT_CFLAGS :=", strings.Join(exportedFlags, " "))
Dan Willemsend5781342017-02-15 16:15:21 -0800129 }
Dan Willemsen58539402017-03-19 13:44:32 -0700130 exportedFlagsDeps := library.exportedFlagsDeps()
131 if len(exportedFlagsDeps) > 0 {
132 fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedFlagsDeps.Strings(), " "))
133 }
134}
Dan Willemsend5781342017-02-15 16:15:21 -0800135
Dan Willemsen58539402017-03-19 13:44:32 -0700136func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsend5781342017-02-15 16:15:21 -0800137 if library.static() {
138 ret.Class = "STATIC_LIBRARIES"
139 } else if library.shared() {
140 ctx.subAndroidMk(ret, &library.stripper)
141 ctx.subAndroidMk(ret, &library.relocationPacker)
142
143 ret.Class = "SHARED_LIBRARIES"
144 } else if library.header() {
Colin Cross0f86d182017-08-10 17:07:28 -0700145 ret.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
Dan Willemsend5781342017-02-15 16:15:21 -0800146 fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
147 fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
Colin Cross0f86d182017-08-10 17:07:28 -0700148 fmt.Fprintln(w, "LOCAL_MODULE :=", name+data.SubName)
Dan Willemsend5781342017-02-15 16:15:21 -0800149
150 archStr := ctx.Target().Arch.ArchType.String()
151 var host bool
152 switch ctx.Target().Os.Class {
153 case android.Host:
154 fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH := ", archStr)
155 host = true
156 case android.HostCross:
157 fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH := ", archStr)
158 host = true
159 case android.Device:
160 fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH := ", archStr)
161 }
162
163 if host {
Dan Willemsen866b5632017-09-22 12:28:24 -0700164 makeOs := ctx.Target().Os.String()
165 if ctx.Target().Os == android.Linux || ctx.Target().Os == android.LinuxBionic {
166 makeOs = "linux"
167 }
168 fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", makeOs)
Dan Willemsend5781342017-02-15 16:15:21 -0800169 fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700170 } else if ctx.useVndk() {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700171 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
Dan Willemsend5781342017-02-15 16:15:21 -0800172 }
173
Dan Willemsen58539402017-03-19 13:44:32 -0700174 library.androidMkWriteExportedFlags(w)
Dan Willemsend5781342017-02-15 16:15:21 -0800175 fmt.Fprintln(w, "include $(BUILD_HEADER_LIBRARY)")
Dan Willemsend5781342017-02-15 16:15:21 -0800176 }
177
178 return
179 }
180
Colin Cross27a4b052017-08-10 16:32:23 -0700181 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsen58539402017-03-19 13:44:32 -0700182 library.androidMkWriteExportedFlags(w)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800183 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES := ")
184 if library.sAbiOutputFile.Valid() {
185 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiOutputFile.String())
186 if library.sAbiDiff.Valid() && !library.static() {
187 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiDiff.String())
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700188 fmt.Fprintln(w, "HEADER_ABI_DIFFS += ", library.sAbiDiff.String())
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800189 }
190 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700191
Dan Willemsen1d577e22016-08-29 15:53:15 -0700192 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())
Dan Willemsen218f6562015-07-08 18:13:11 -0700193
Dan Willemsen97750522016-02-09 17:43:51 -0800194 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
Dan Willemsen218f6562015-07-08 18:13:11 -0700195
Dan Willemsen581341d2017-02-09 16:16:31 -0800196 if library.coverageOutputFile.Valid() {
197 fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", library.coverageOutputFile.String())
198 }
Colin Crossca860ac2016-01-04 14:34:37 -0800199 })
Colin Crossb916a382016-07-29 17:28:03 -0700200
Colin Cross4ac44802017-02-15 14:06:12 -0800201 if library.shared() {
Colin Crossb916a382016-07-29 17:28:03 -0700202 ctx.subAndroidMk(ret, library.baseInstaller)
203 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700204}
205
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700206func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross0f86d182017-08-10 17:07:28 -0700207 ret.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
Colin Crossca860ac2016-01-04 14:34:37 -0800208 out := ret.OutputFile.Path()
Dan Willemsen218f6562015-07-08 18:13:11 -0700209
Colin Cross0f86d182017-08-10 17:07:28 -0700210 fmt.Fprintln(w, "\n$("+prefix+"OUT_INTERMEDIATE_LIBRARIES)/"+name+data.SubName+objectExtension+":", out.String())
Dan Willemsen97750522016-02-09 17:43:51 -0800211 fmt.Fprintln(w, "\t$(copy-file-to-target)")
Dan Willemsen218f6562015-07-08 18:13:11 -0700212 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700213}
214
Colin Crossb916a382016-07-29 17:28:03 -0700215func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross1e7d3702016-08-24 15:25:47 -0700216 ctx.subAndroidMk(ret, binary.baseInstaller)
Colin Crossb916a382016-07-29 17:28:03 -0700217 ctx.subAndroidMk(ret, &binary.stripper)
Dan Willemsen7517ed02016-06-10 17:20:30 -0700218
Dan Willemsen218f6562015-07-08 18:13:11 -0700219 ret.Class = "EXECUTABLES"
Colin Cross27a4b052017-08-10 16:32:23 -0700220 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsen97750522016-02-09 17:43:51 -0800221 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
Colin Crossb916a382016-07-29 17:28:03 -0700222 if Bool(binary.Properties.Static_executable) {
Colin Cross3854a602016-01-11 12:49:11 -0800223 fmt.Fprintln(w, "LOCAL_FORCE_STATIC_EXECUTABLE := true")
224 }
Colin Cross9b09f242016-12-07 13:37:42 -0800225
226 if len(binary.symlinks) > 0 {
227 fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS := "+strings.Join(binary.symlinks, " "))
228 }
229
Dan Willemsen581341d2017-02-09 16:16:31 -0800230 if binary.coverageOutputFile.Valid() {
231 fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", binary.coverageOutputFile.String())
232 }
Yifan Hong946e32e2018-04-03 13:22:50 -0700233
234 if len(binary.Properties.Overrides) > 0 {
235 fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES := "+strings.Join(binary.Properties.Overrides, " "))
236 }
Colin Crossca860ac2016-01-04 14:34:37 -0800237 })
238}
239
Colin Crossb916a382016-07-29 17:28:03 -0700240func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
241 ctx.subAndroidMk(ret, benchmark.binaryDecorator)
Dan Willemsen58a5c8b2017-05-23 15:10:37 -0700242 ret.Class = "NATIVE_TESTS"
Colin Cross27a4b052017-08-10 16:32:23 -0700243 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crosse28f4e22017-04-24 18:10:29 -0700244 if len(benchmark.Properties.Test_suites) > 0 {
245 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
246 strings.Join(benchmark.Properties.Test_suites, " "))
247 }
Nelson Li1f6b14e2018-04-18 16:55:21 +0000248 fmt.Fprintln(w, "LOCAL_NATIVE_BENCHMARK := true")
Colin Crosse28f4e22017-04-24 18:10:29 -0700249 })
Anders Lewisb97e8182017-07-14 15:20:13 -0700250
251 androidMkWriteTestData(benchmark.data, ctx, ret)
Colin Crossb916a382016-07-29 17:28:03 -0700252}
253
254func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
255 ctx.subAndroidMk(ret, test.binaryDecorator)
Dan Willemsen0fe72532017-01-17 13:25:49 -0800256 ret.Class = "NATIVE_TESTS"
Colin Crossb916a382016-07-29 17:28:03 -0700257 if Bool(test.Properties.Test_per_src) {
Nan Zhang0007d812017-11-07 10:57:05 -0800258 ret.SubName = "_" + String(test.binaryDecorator.Properties.Stem)
Colin Crossa2344662016-03-24 13:14:12 -0700259 }
Colin Crossfaeb7aa2017-02-01 14:12:44 -0800260
Colin Cross27a4b052017-08-10 16:32:23 -0700261 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa929db02017-03-27 16:27:50 -0700262 if len(test.Properties.Test_suites) > 0 {
Dan Shi4df566d2017-04-03 12:29:25 -0700263 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
Colin Crossa929db02017-03-27 16:27:50 -0700264 strings.Join(test.Properties.Test_suites, " "))
265 }
Colin Crossa929db02017-03-27 16:27:50 -0700266 })
267
Anders Lewisb97e8182017-07-14 15:20:13 -0700268 androidMkWriteTestData(test.data, ctx, ret)
Colin Crossa2344662016-03-24 13:14:12 -0700269}
270
Colin Crossb916a382016-07-29 17:28:03 -0700271func (test *testLibrary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
272 ctx.subAndroidMk(ret, test.libraryDecorator)
273}
Dan Willemsene7932e82016-05-16 15:56:53 -0700274
Colin Crossb916a382016-07-29 17:28:03 -0700275func (library *toolchainLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
276 ret.Class = "STATIC_LIBRARIES"
Colin Cross27a4b052017-08-10 16:32:23 -0700277 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsene7932e82016-05-16 15:56:53 -0700278 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext())
Dan Willemsene7932e82016-05-16 15:56:53 -0700279 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
Dan Willemsene7932e82016-05-16 15:56:53 -0700280 })
281}
282
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700283func (stripper *stripper) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
284 // Make only supports stripping target modules
285 if ctx.Target().Os != android.Android {
286 return
287 }
288
Colin Cross27a4b052017-08-10 16:32:23 -0700289 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Nan Zhang0007d812017-11-07 10:57:05 -0800290 if Bool(stripper.StripProperties.Strip.None) {
291
Dan Willemsen7517ed02016-06-10 17:20:30 -0700292 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
Nan Zhang0007d812017-11-07 10:57:05 -0800293 } else if Bool(stripper.StripProperties.Strip.Keep_symbols) {
Dan Willemsen7517ed02016-06-10 17:20:30 -0700294 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := keep_symbols")
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700295 } else {
296 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := mini-debug-info")
Dan Willemsen7517ed02016-06-10 17:20:30 -0700297 }
Dan Willemsen7517ed02016-06-10 17:20:30 -0700298 })
299}
300
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700301func (packer *relocationPacker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross27a4b052017-08-10 16:32:23 -0700302 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700303 if packer.Properties.PackingRelocations {
304 fmt.Fprintln(w, "LOCAL_PACK_MODULE_RELOCATIONS := true")
305 }
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700306 })
307}
308
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700309func (installer *baseInstaller) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsen03ce63e2016-09-29 12:17:49 -0700310 // Soong installation is only supported for host modules. Have Make
311 // installation trigger Soong installation.
312 if ctx.Target().Os.Class == android.Host {
313 ret.OutputFile = android.OptionalPathForPath(installer.path)
314 }
315
Colin Cross27a4b052017-08-10 16:32:23 -0700316 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa2344662016-03-24 13:14:12 -0700317 path := installer.path.RelPathString()
Colin Crossbf305de2016-03-29 17:32:06 -0700318 dir, file := filepath.Split(path)
319 stem := strings.TrimSuffix(file, filepath.Ext(file))
Dan Willemsen1d577e22016-08-29 15:53:15 -0700320 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file))
Colin Crosse14388b2016-05-03 14:08:40 -0700321 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir))
Colin Crossbf305de2016-03-29 17:32:06 -0700322 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
Colin Crossa2344662016-03-24 13:14:12 -0700323 })
Dan Willemsen218f6562015-07-08 18:13:11 -0700324}
Dan Albert914449f2016-06-17 16:45:24 -0700325
Colin Crossb916a382016-07-29 17:28:03 -0700326func (c *stubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsen01a90592017-04-07 15:21:13 -0700327 ret.SubName = ndkLibrarySuffix + "." + c.properties.ApiLevel
Dan Albert705c84b2016-08-08 10:45:03 -0700328 ret.Class = "SHARED_LIBRARIES"
Dan Albert914449f2016-06-17 16:45:24 -0700329
Colin Cross27a4b052017-08-10 16:32:23 -0700330 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Cross0875c522017-11-28 17:34:01 -0800331 path, file := filepath.Split(c.installPath.String())
Dan Albert914449f2016-06-17 16:45:24 -0700332 stem := strings.TrimSuffix(file, filepath.Ext(file))
Dan Albertcdd4c242016-08-08 14:44:56 -0700333 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
334 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext())
Dan Albert914449f2016-06-17 16:45:24 -0700335 fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path)
336 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
Dan Willemsen866810d2017-04-04 14:13:45 -0700337 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
Dan Albert914449f2016-06-17 16:45:24 -0700338
339 // Prevent make from installing the libraries to obj/lib (since we have
340 // dozens of libraries with the same name, they'll clobber each other
341 // and the real versions of the libraries from the platform).
342 fmt.Fprintln(w, "LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES := false")
Dan Albert914449f2016-06-17 16:45:24 -0700343 })
344}
Dan Willemsenb916b802017-03-19 13:44:32 -0700345
346func (c *llndkStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
347 ret.Class = "SHARED_LIBRARIES"
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700348 ret.SubName = ".vendor"
Dan Willemsenb916b802017-03-19 13:44:32 -0700349
Colin Cross27a4b052017-08-10 16:32:23 -0700350 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsenb916b802017-03-19 13:44:32 -0700351 c.libraryDecorator.androidMkWriteExportedFlags(w)
352
353 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())
354 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
355 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
356 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
357 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700358 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
Dan Willemsenb916b802017-03-19 13:44:32 -0700359 })
360}
Justin Yun71549282017-11-17 12:10:28 +0900361
362func (c *vndkPrebuiltLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
363 ret.Class = "SHARED_LIBRARIES"
364
Jae Shin43ef2642017-12-29 16:20:21 +0900365 ret.SubName = c.NameSuffix()
Justin Yun71549282017-11-17 12:10:28 +0900366
367 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
368 c.libraryDecorator.androidMkWriteExportedFlags(w)
369
370 path := c.path.RelPathString()
371 dir, file := filepath.Split(path)
372 stem := strings.TrimSuffix(file, filepath.Ext(file))
373 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
374 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
375 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
376 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())
377 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file))
378 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir))
379 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
380 })
Colin Cross7a6fcbe2017-12-06 13:08:00 -0800381}
Dan Albert8ba131b2017-12-14 13:23:15 -0800382
383func (c *ndkPrebuiltStlLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
384 ret.Class = "SHARED_LIBRARIES"
385
386 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
387 // Prevent make from installing the libraries to obj/lib (since we have
388 // dozens of libraries with the same name, they'll clobber each other
389 // and the real versions of the libraries from the platform).
390 fmt.Fprintln(w, "LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES := false")
391 })
392}
Jiyong Park374510b2018-03-19 18:23:01 +0900393
394func (c *vendorPublicLibraryStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
395 ret.Class = "SHARED_LIBRARIES"
396 ret.SubName = vendorPublicLibrarySuffix
397
398 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
399 c.libraryDecorator.androidMkWriteExportedFlags(w)
400
401 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())
402 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
403 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
404 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
405 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
406 })
407}