Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 1 | // 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 | |
| 15 | package cc |
| 16 | |
| 17 | import ( |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 18 | "fmt" |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 19 | "io" |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 20 | "path/filepath" |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 21 | "strings" |
| 22 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 23 | "android/soong/android" |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 24 | ) |
| 25 | |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 26 | var ( |
| 27 | vendorSuffix = ".vendor" |
| 28 | ) |
| 29 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 30 | type AndroidMkContext interface { |
| 31 | Target() android.Target |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 32 | subAndroidMk(*android.AndroidMkData, interface{}) |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 33 | useVndk() bool |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | type subAndroidMkProvider interface { |
| 37 | AndroidMk(AndroidMkContext, *android.AndroidMkData) |
| 38 | } |
| 39 | |
| 40 | func (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 Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 52 | func (c *Module) AndroidMk() android.AndroidMkData { |
Colin Cross | bc6fb16 | 2016-05-24 15:39:04 -0700 | [diff] [blame] | 53 | if c.Properties.HideFromMake { |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 54 | return android.AndroidMkData{ |
| 55 | Disabled: true, |
| 56 | } |
Colin Cross | bc6fb16 | 2016-05-24 15:39:04 -0700 | [diff] [blame] | 57 | } |
| 58 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 59 | ret := android.AndroidMkData{ |
| 60 | OutputFile: c.outputFile, |
| 61 | Extra: []android.AndroidMkExtraFunc{ |
| 62 | func(w io.Writer, outputFile android.Path) { |
Colin Cross | 5beccee | 2017-12-07 15:28:59 -0800 | [diff] [blame] | 63 | if len(c.Properties.Logtags) > 0 { |
| 64 | fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(c.Properties.Logtags, " ")) |
| 65 | } |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 66 | 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 Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 70 | 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 Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 73 | 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 Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 78 | if c.useVndk() { |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 79 | fmt.Fprintln(w, "LOCAL_USE_VNDK := true") |
| 80 | } |
| 81 | }, |
| 82 | }, |
| 83 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 84 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 85 | for _, feature := range c.features { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 86 | c.subAndroidMk(&ret, feature) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 87 | } |
| 88 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 89 | c.subAndroidMk(&ret, c.compiler) |
| 90 | c.subAndroidMk(&ret, c.linker) |
Colin Cross | 8ff9ef4 | 2017-05-08 13:44:11 -0700 | [diff] [blame] | 91 | if c.sanitize != nil { |
| 92 | c.subAndroidMk(&ret, c.sanitize) |
| 93 | } |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 94 | c.subAndroidMk(&ret, c.installer) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 95 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 96 | if c.useVndk() && c.hasVendorVariant() { |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 97 | // .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 Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 102 | return ret |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 103 | } |
| 104 | |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 105 | func 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 Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 117 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 118 | fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " ")) |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 119 | }) |
| 120 | } |
| 121 | } |
| 122 | |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 123 | func (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 Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 127 | } |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 128 | exportedFlagsDeps := library.exportedFlagsDeps() |
| 129 | if len(exportedFlagsDeps) > 0 { |
| 130 | fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedFlagsDeps.Strings(), " ")) |
| 131 | } |
| 132 | } |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 133 | |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 134 | func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 135 | 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 Cross | 0f86d18 | 2017-08-10 17:07:28 -0700 | [diff] [blame] | 143 | ret.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) { |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 144 | fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)") |
| 145 | fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir) |
Colin Cross | 0f86d18 | 2017-08-10 17:07:28 -0700 | [diff] [blame] | 146 | fmt.Fprintln(w, "LOCAL_MODULE :=", name+data.SubName) |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 147 | |
| 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 Willemsen | 866b563 | 2017-09-22 12:28:24 -0700 | [diff] [blame] | 162 | 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 Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 167 | fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true") |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 168 | } else if ctx.useVndk() { |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 169 | fmt.Fprintln(w, "LOCAL_USE_VNDK := true") |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 170 | } |
| 171 | |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 172 | library.androidMkWriteExportedFlags(w) |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 173 | fmt.Fprintln(w, "include $(BUILD_HEADER_LIBRARY)") |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | return |
| 177 | } |
| 178 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 179 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 180 | library.androidMkWriteExportedFlags(w) |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 181 | 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 Chowdhary | 715cac3 | 2017-04-20 06:53:59 -0700 | [diff] [blame] | 186 | fmt.Fprintln(w, "HEADER_ABI_DIFFS += ", library.sAbiDiff.String()) |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 187 | } |
| 188 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 189 | |
Dan Willemsen | 1d577e2 | 2016-08-29 15:53:15 -0700 | [diff] [blame] | 190 | fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext()) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 191 | |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 192 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 193 | |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 194 | if library.coverageOutputFile.Valid() { |
| 195 | fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", library.coverageOutputFile.String()) |
| 196 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 197 | }) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 198 | |
Colin Cross | 4ac4480 | 2017-02-15 14:06:12 -0800 | [diff] [blame] | 199 | if library.shared() { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 200 | ctx.subAndroidMk(ret, library.baseInstaller) |
| 201 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 202 | } |
| 203 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 204 | func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Colin Cross | 0f86d18 | 2017-08-10 17:07:28 -0700 | [diff] [blame] | 205 | ret.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 206 | out := ret.OutputFile.Path() |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 207 | |
Colin Cross | 0f86d18 | 2017-08-10 17:07:28 -0700 | [diff] [blame] | 208 | fmt.Fprintln(w, "\n$("+prefix+"OUT_INTERMEDIATE_LIBRARIES)/"+name+data.SubName+objectExtension+":", out.String()) |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 209 | fmt.Fprintln(w, "\t$(copy-file-to-target)") |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 210 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 211 | } |
| 212 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 213 | func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Colin Cross | 1e7d370 | 2016-08-24 15:25:47 -0700 | [diff] [blame] | 214 | ctx.subAndroidMk(ret, binary.baseInstaller) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 215 | ctx.subAndroidMk(ret, &binary.stripper) |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 216 | |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 217 | ret.Class = "EXECUTABLES" |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 218 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 219 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 220 | if Bool(binary.Properties.Static_executable) { |
Colin Cross | 3854a60 | 2016-01-11 12:49:11 -0800 | [diff] [blame] | 221 | fmt.Fprintln(w, "LOCAL_FORCE_STATIC_EXECUTABLE := true") |
| 222 | } |
Colin Cross | 9b09f24 | 2016-12-07 13:37:42 -0800 | [diff] [blame] | 223 | |
| 224 | if len(binary.symlinks) > 0 { |
| 225 | fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS := "+strings.Join(binary.symlinks, " ")) |
| 226 | } |
| 227 | |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 228 | if binary.coverageOutputFile.Valid() { |
| 229 | fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", binary.coverageOutputFile.String()) |
| 230 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 231 | }) |
| 232 | } |
| 233 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 234 | func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 235 | ctx.subAndroidMk(ret, benchmark.binaryDecorator) |
Dan Willemsen | 58a5c8b | 2017-05-23 15:10:37 -0700 | [diff] [blame] | 236 | ret.Class = "NATIVE_TESTS" |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 237 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 238 | if len(benchmark.Properties.Test_suites) > 0 { |
| 239 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", |
| 240 | strings.Join(benchmark.Properties.Test_suites, " ")) |
| 241 | } |
Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 242 | }) |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 243 | |
| 244 | androidMkWriteTestData(benchmark.data, ctx, ret) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 248 | ctx.subAndroidMk(ret, test.binaryDecorator) |
Dan Willemsen | 0fe7253 | 2017-01-17 13:25:49 -0800 | [diff] [blame] | 249 | ret.Class = "NATIVE_TESTS" |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 250 | if Bool(test.Properties.Test_per_src) { |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 251 | ret.SubName = "_" + String(test.binaryDecorator.Properties.Stem) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 252 | } |
Colin Cross | faeb7aa | 2017-02-01 14:12:44 -0800 | [diff] [blame] | 253 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 254 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 255 | if len(test.Properties.Test_suites) > 0 { |
Dan Shi | 4df566d | 2017-04-03 12:29:25 -0700 | [diff] [blame] | 256 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 257 | strings.Join(test.Properties.Test_suites, " ")) |
| 258 | } |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 259 | }) |
| 260 | |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 261 | androidMkWriteTestData(test.data, ctx, ret) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 262 | } |
| 263 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 264 | func (test *testLibrary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 265 | ctx.subAndroidMk(ret, test.libraryDecorator) |
| 266 | } |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 267 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 268 | func (library *toolchainLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 269 | ret.Class = "STATIC_LIBRARIES" |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 270 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 271 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext()) |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 272 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 273 | }) |
| 274 | } |
| 275 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 276 | func (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 Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 282 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 283 | if Bool(stripper.StripProperties.Strip.None) { |
| 284 | |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 285 | fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false") |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 286 | } else if Bool(stripper.StripProperties.Strip.Keep_symbols) { |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 287 | fmt.Fprintln(w, "LOCAL_STRIP_MODULE := keep_symbols") |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 288 | } else { |
| 289 | fmt.Fprintln(w, "LOCAL_STRIP_MODULE := mini-debug-info") |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 290 | } |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 291 | }) |
| 292 | } |
| 293 | |
Dan Willemsen | 394e9dc | 2016-09-14 15:04:48 -0700 | [diff] [blame] | 294 | func (packer *relocationPacker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 295 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Dan Willemsen | 394e9dc | 2016-09-14 15:04:48 -0700 | [diff] [blame] | 296 | if packer.Properties.PackingRelocations { |
| 297 | fmt.Fprintln(w, "LOCAL_PACK_MODULE_RELOCATIONS := true") |
| 298 | } |
Dan Willemsen | 394e9dc | 2016-09-14 15:04:48 -0700 | [diff] [blame] | 299 | }) |
| 300 | } |
| 301 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 302 | func (installer *baseInstaller) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | 03ce63e | 2016-09-29 12:17:49 -0700 | [diff] [blame] | 303 | // 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 Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 309 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 310 | path := installer.path.RelPathString() |
Colin Cross | bf305de | 2016-03-29 17:32:06 -0700 | [diff] [blame] | 311 | dir, file := filepath.Split(path) |
| 312 | stem := strings.TrimSuffix(file, filepath.Ext(file)) |
Dan Willemsen | 1d577e2 | 2016-08-29 15:53:15 -0700 | [diff] [blame] | 313 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file)) |
Colin Cross | e14388b | 2016-05-03 14:08:40 -0700 | [diff] [blame] | 314 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir)) |
Colin Cross | bf305de | 2016-03-29 17:32:06 -0700 | [diff] [blame] | 315 | fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 316 | }) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 317 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 318 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 319 | func (c *stubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | 01a9059 | 2017-04-07 15:21:13 -0700 | [diff] [blame] | 320 | ret.SubName = ndkLibrarySuffix + "." + c.properties.ApiLevel |
Dan Albert | 705c84b | 2016-08-08 10:45:03 -0700 | [diff] [blame] | 321 | ret.Class = "SHARED_LIBRARIES" |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 322 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 323 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 324 | path, file := filepath.Split(c.installPath.String()) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 325 | stem := strings.TrimSuffix(file, filepath.Ext(file)) |
Dan Albert | cdd4c24 | 2016-08-08 14:44:56 -0700 | [diff] [blame] | 326 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
| 327 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext()) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 328 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path) |
| 329 | fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) |
Dan Willemsen | 866810d | 2017-04-04 14:13:45 -0700 | [diff] [blame] | 330 | fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true") |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 331 | |
| 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 Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 336 | }) |
| 337 | } |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 338 | |
| 339 | func (c *llndkStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 340 | ret.Class = "SHARED_LIBRARIES" |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 341 | ret.SubName = ".vendor" |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 342 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 343 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 344 | 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 Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 351 | fmt.Fprintln(w, "LOCAL_USE_VNDK := true") |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 352 | }) |
| 353 | } |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 354 | |
| 355 | func (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 Cross | 7a6fcbe | 2017-12-06 13:08:00 -0800 | [diff] [blame] | 374 | } |
Dan Albert | 8ba131b | 2017-12-14 13:23:15 -0800 | [diff] [blame^] | 375 | |
| 376 | func (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 | } |