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 ( |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 27 | vendorSuffix = ".vendor" |
| 28 | recoverySuffix = ".recovery" |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 29 | ) |
| 30 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 31 | type AndroidMkContext interface { |
| 32 | Target() android.Target |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 33 | subAndroidMk(*android.AndroidMkData, interface{}) |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 34 | useVndk() bool |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | type subAndroidMkProvider interface { |
| 38 | AndroidMk(AndroidMkContext, *android.AndroidMkData) |
| 39 | } |
| 40 | |
| 41 | func (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 Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 51 | } |
| 52 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 53 | func (c *Module) AndroidMk() android.AndroidMkData { |
Colin Cross | bc6fb16 | 2016-05-24 15:39:04 -0700 | [diff] [blame] | 54 | if c.Properties.HideFromMake { |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 55 | return android.AndroidMkData{ |
| 56 | Disabled: true, |
| 57 | } |
Colin Cross | bc6fb16 | 2016-05-24 15:39:04 -0700 | [diff] [blame] | 58 | } |
| 59 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 60 | ret := android.AndroidMkData{ |
| 61 | OutputFile: c.outputFile, |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 62 | Required: c.Properties.AndroidMkRuntimeLibs, |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 63 | Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk", |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 64 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 65 | Extra: []android.AndroidMkExtraFunc{ |
| 66 | func(w io.Writer, outputFile android.Path) { |
Colin Cross | 5beccee | 2017-12-07 15:28:59 -0800 | [diff] [blame] | 67 | if len(c.Properties.Logtags) > 0 { |
| 68 | fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(c.Properties.Logtags, " ")) |
| 69 | } |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 70 | if len(c.Properties.AndroidMkSharedLibs) > 0 { |
| 71 | fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " ")) |
| 72 | } |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 73 | fmt.Fprintln(w, "LOCAL_SOONG_LINK_TYPE :=", c.getMakeLinkType()) |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 74 | if c.useVndk() { |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 75 | fmt.Fprintln(w, "LOCAL_USE_VNDK := true") |
| 76 | } |
| 77 | }, |
| 78 | }, |
| 79 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 80 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 81 | for _, feature := range c.features { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 82 | c.subAndroidMk(&ret, feature) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 83 | } |
| 84 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 85 | c.subAndroidMk(&ret, c.compiler) |
| 86 | c.subAndroidMk(&ret, c.linker) |
Colin Cross | 8ff9ef4 | 2017-05-08 13:44:11 -0700 | [diff] [blame] | 87 | if c.sanitize != nil { |
| 88 | c.subAndroidMk(&ret, c.sanitize) |
| 89 | } |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 90 | c.subAndroidMk(&ret, c.installer) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 91 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 92 | if c.useVndk() && c.hasVendorVariant() { |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 93 | // .vendor suffix is added only when we will have two variants: core and vendor. |
| 94 | // The suffix is not added for vendor-only module. |
| 95 | ret.SubName += vendorSuffix |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 96 | } else if c.inRecovery() && !c.onlyInRecovery() { |
| 97 | ret.SubName += recoverySuffix |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 98 | } |
| 99 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 100 | return ret |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 101 | } |
| 102 | |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 103 | func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 104 | var testFiles []string |
| 105 | for _, d := range data { |
| 106 | rel := d.Rel() |
| 107 | path := d.String() |
| 108 | if !strings.HasSuffix(path, rel) { |
| 109 | panic(fmt.Errorf("path %q does not end with %q", path, rel)) |
| 110 | } |
| 111 | path = strings.TrimSuffix(path, rel) |
| 112 | testFiles = append(testFiles, path+":"+rel) |
| 113 | } |
| 114 | if len(testFiles) > 0 { |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 115 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 116 | fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " ")) |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 117 | }) |
| 118 | } |
| 119 | } |
| 120 | |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 121 | func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) { |
| 122 | exportedFlags := library.exportedFlags() |
| 123 | if len(exportedFlags) > 0 { |
| 124 | fmt.Fprintln(w, "LOCAL_EXPORT_CFLAGS :=", strings.Join(exportedFlags, " ")) |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 125 | } |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 126 | exportedFlagsDeps := library.exportedFlagsDeps() |
| 127 | if len(exportedFlagsDeps) > 0 { |
| 128 | fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedFlagsDeps.Strings(), " ")) |
| 129 | } |
| 130 | } |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 131 | |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 132 | func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 133 | if library.static() { |
| 134 | ret.Class = "STATIC_LIBRARIES" |
| 135 | } else if library.shared() { |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 136 | ret.Class = "SHARED_LIBRARIES" |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 137 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
| 138 | fmt.Fprintln(w, "LOCAL_SOONG_TOC :=", library.toc().String()) |
| 139 | fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", library.unstrippedOutputFile.String()) |
| 140 | }) |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 141 | } else if library.header() { |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 142 | ret.Class = "HEADER_LIBRARIES" |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 143 | } |
| 144 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 145 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 146 | library.androidMkWriteExportedFlags(w) |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 147 | fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES := ") |
| 148 | if library.sAbiOutputFile.Valid() { |
| 149 | fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiOutputFile.String()) |
| 150 | if library.sAbiDiff.Valid() && !library.static() { |
| 151 | fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiDiff.String()) |
Jayant Chowdhary | 715cac3 | 2017-04-20 06:53:59 -0700 | [diff] [blame] | 152 | fmt.Fprintln(w, "HEADER_ABI_DIFFS += ", library.sAbiDiff.String()) |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 153 | } |
| 154 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 155 | |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 156 | _, _, ext := splitFileExt(outputFile.Base()) |
| 157 | |
| 158 | fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 159 | |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 160 | if library.coverageOutputFile.Valid() { |
| 161 | fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", library.coverageOutputFile.String()) |
| 162 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 163 | }) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 164 | |
Colin Cross | 4ac4480 | 2017-02-15 14:06:12 -0800 | [diff] [blame] | 165 | if library.shared() { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 166 | ctx.subAndroidMk(ret, library.baseInstaller) |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 167 | } else { |
| 168 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
| 169 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true") |
| 170 | }) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 171 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 172 | } |
| 173 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 174 | func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Colin Cross | 0f86d18 | 2017-08-10 17:07:28 -0700 | [diff] [blame] | 175 | 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] | 176 | out := ret.OutputFile.Path() |
Dan Willemsen | 2e224ca | 2018-09-06 00:26:20 -0700 | [diff] [blame^] | 177 | varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, data.SubName) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 178 | |
Dan Willemsen | 2e224ca | 2018-09-06 00:26:20 -0700 | [diff] [blame^] | 179 | fmt.Fprintf(w, "\n%s := %s\n", varname, out.String()) |
| 180 | fmt.Fprintln(w, ".KATI_READONLY: "+varname) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 181 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 182 | } |
| 183 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 184 | func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Colin Cross | 1e7d370 | 2016-08-24 15:25:47 -0700 | [diff] [blame] | 185 | ctx.subAndroidMk(ret, binary.baseInstaller) |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 186 | |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 187 | ret.Class = "EXECUTABLES" |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 188 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 189 | fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", binary.unstrippedOutputFile.String()) |
Colin Cross | 9b09f24 | 2016-12-07 13:37:42 -0800 | [diff] [blame] | 190 | if len(binary.symlinks) > 0 { |
| 191 | fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS := "+strings.Join(binary.symlinks, " ")) |
| 192 | } |
| 193 | |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 194 | if binary.coverageOutputFile.Valid() { |
| 195 | fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", binary.coverageOutputFile.String()) |
| 196 | } |
Yifan Hong | 946e32e | 2018-04-03 13:22:50 -0700 | [diff] [blame] | 197 | |
| 198 | if len(binary.Properties.Overrides) > 0 { |
| 199 | fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES := "+strings.Join(binary.Properties.Overrides, " ")) |
| 200 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 201 | }) |
| 202 | } |
| 203 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 204 | func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 205 | ctx.subAndroidMk(ret, benchmark.binaryDecorator) |
Dan Willemsen | 58a5c8b | 2017-05-23 15:10:37 -0700 | [diff] [blame] | 206 | ret.Class = "NATIVE_TESTS" |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 207 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 208 | if len(benchmark.Properties.Test_suites) > 0 { |
| 209 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", |
| 210 | strings.Join(benchmark.Properties.Test_suites, " ")) |
| 211 | } |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 212 | if benchmark.testConfig != nil { |
| 213 | fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", benchmark.testConfig.String()) |
Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 214 | } |
Nelson Li | 1f6b14e | 2018-04-18 16:55:21 +0000 | [diff] [blame] | 215 | fmt.Fprintln(w, "LOCAL_NATIVE_BENCHMARK := true") |
Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 216 | }) |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 217 | |
| 218 | androidMkWriteTestData(benchmark.data, ctx, ret) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 222 | ctx.subAndroidMk(ret, test.binaryDecorator) |
Dan Willemsen | 0fe7253 | 2017-01-17 13:25:49 -0800 | [diff] [blame] | 223 | ret.Class = "NATIVE_TESTS" |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 224 | if Bool(test.Properties.Test_per_src) { |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 225 | ret.SubName = "_" + String(test.binaryDecorator.Properties.Stem) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 226 | } |
Colin Cross | faeb7aa | 2017-02-01 14:12:44 -0800 | [diff] [blame] | 227 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 228 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 229 | if len(test.Properties.Test_suites) > 0 { |
Dan Shi | 4df566d | 2017-04-03 12:29:25 -0700 | [diff] [blame] | 230 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 231 | strings.Join(test.Properties.Test_suites, " ")) |
| 232 | } |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 233 | if test.testConfig != nil { |
| 234 | fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", test.testConfig.String()) |
Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 235 | } |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 236 | }) |
| 237 | |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 238 | androidMkWriteTestData(test.data, ctx, ret) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 239 | } |
| 240 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 241 | func (test *testLibrary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 242 | ctx.subAndroidMk(ret, test.libraryDecorator) |
| 243 | } |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 244 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 245 | func (library *toolchainLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 246 | ret.Class = "STATIC_LIBRARIES" |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 247 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 248 | _, suffix, _ := splitFileExt(outputFile.Base()) |
| 249 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix) |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 250 | }) |
| 251 | } |
| 252 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 253 | func (installer *baseInstaller) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | 03ce63e | 2016-09-29 12:17:49 -0700 | [diff] [blame] | 254 | // Soong installation is only supported for host modules. Have Make |
| 255 | // installation trigger Soong installation. |
| 256 | if ctx.Target().Os.Class == android.Host { |
| 257 | ret.OutputFile = android.OptionalPathForPath(installer.path) |
| 258 | } |
| 259 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 260 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 261 | path := installer.path.RelPathString() |
Colin Cross | bf305de | 2016-03-29 17:32:06 -0700 | [diff] [blame] | 262 | dir, file := filepath.Split(path) |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 263 | stem, suffix, _ := splitFileExt(file) |
| 264 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix) |
Colin Cross | e14388b | 2016-05-03 14:08:40 -0700 | [diff] [blame] | 265 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir)) |
Colin Cross | bf305de | 2016-03-29 17:32:06 -0700 | [diff] [blame] | 266 | fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 267 | }) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 268 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 269 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 270 | func (c *stubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | 01a9059 | 2017-04-07 15:21:13 -0700 | [diff] [blame] | 271 | ret.SubName = ndkLibrarySuffix + "." + c.properties.ApiLevel |
Dan Albert | 705c84b | 2016-08-08 10:45:03 -0700 | [diff] [blame] | 272 | ret.Class = "SHARED_LIBRARIES" |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 273 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 274 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 275 | path, file := filepath.Split(c.installPath.String()) |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 276 | stem, suffix, _ := splitFileExt(file) |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 277 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 278 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path) |
| 279 | fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) |
Dan Willemsen | 866810d | 2017-04-04 14:13:45 -0700 | [diff] [blame] | 280 | fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true") |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 281 | }) |
| 282 | } |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 283 | |
| 284 | func (c *llndkStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 285 | ret.Class = "SHARED_LIBRARIES" |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 286 | ret.SubName = vendorSuffix |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 287 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 288 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 289 | c.libraryDecorator.androidMkWriteExportedFlags(w) |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 290 | _, _, ext := splitFileExt(outputFile.Base()) |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 291 | |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 292 | fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext) |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 293 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true") |
| 294 | fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true") |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 295 | fmt.Fprintln(w, "LOCAL_SOONG_TOC :=", c.toc().String()) |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 296 | }) |
| 297 | } |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 298 | |
| 299 | func (c *vndkPrebuiltLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 300 | ret.Class = "SHARED_LIBRARIES" |
| 301 | |
Jae Shin | 43ef264 | 2017-12-29 16:20:21 +0900 | [diff] [blame] | 302 | ret.SubName = c.NameSuffix() |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 303 | |
| 304 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
| 305 | c.libraryDecorator.androidMkWriteExportedFlags(w) |
| 306 | |
| 307 | path := c.path.RelPathString() |
| 308 | dir, file := filepath.Split(path) |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 309 | stem, suffix, ext := splitFileExt(file) |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 310 | fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext) |
| 311 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix) |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 312 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir)) |
| 313 | fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) |
| 314 | }) |
Colin Cross | 7a6fcbe | 2017-12-06 13:08:00 -0800 | [diff] [blame] | 315 | } |
Dan Albert | 8ba131b | 2017-12-14 13:23:15 -0800 | [diff] [blame] | 316 | |
| 317 | func (c *ndkPrebuiltStlLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 318 | ret.Class = "SHARED_LIBRARIES" |
Dan Albert | 8ba131b | 2017-12-14 13:23:15 -0800 | [diff] [blame] | 319 | } |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 320 | |
| 321 | func (c *vendorPublicLibraryStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 322 | ret.Class = "SHARED_LIBRARIES" |
| 323 | ret.SubName = vendorPublicLibrarySuffix |
| 324 | |
| 325 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
| 326 | c.libraryDecorator.androidMkWriteExportedFlags(w) |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 327 | _, _, ext := splitFileExt(outputFile.Base()) |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 328 | |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 329 | fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext) |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 330 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true") |
| 331 | fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true") |
| 332 | }) |
| 333 | } |