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 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 26 | type AndroidMkContext interface { |
| 27 | Target() android.Target |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 28 | subAndroidMk(*android.AndroidMkData, interface{}) |
| 29 | } |
| 30 | |
| 31 | type subAndroidMkProvider interface { |
| 32 | AndroidMk(AndroidMkContext, *android.AndroidMkData) |
| 33 | } |
| 34 | |
| 35 | func (c *Module) subAndroidMk(data *android.AndroidMkData, obj interface{}) { |
| 36 | if c.subAndroidMkOnce == nil { |
| 37 | c.subAndroidMkOnce = make(map[subAndroidMkProvider]bool) |
| 38 | } |
| 39 | if androidmk, ok := obj.(subAndroidMkProvider); ok { |
| 40 | if !c.subAndroidMkOnce[androidmk] { |
| 41 | c.subAndroidMkOnce[androidmk] = true |
| 42 | androidmk.AndroidMk(c, data) |
| 43 | } |
| 44 | } |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 45 | } |
| 46 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 47 | func (c *Module) AndroidMk() (ret android.AndroidMkData, err error) { |
Colin Cross | bc6fb16 | 2016-05-24 15:39:04 -0700 | [diff] [blame] | 48 | if c.Properties.HideFromMake { |
| 49 | ret.Disabled = true |
| 50 | return ret, nil |
| 51 | } |
| 52 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 53 | ret.OutputFile = c.outputFile |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 54 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) (err error) { |
Colin Cross | 30d5f51 | 2016-05-03 18:02:42 -0700 | [diff] [blame] | 55 | fmt.Fprintln(w, "LOCAL_SANITIZE := never") |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 56 | if len(c.Properties.AndroidMkSharedLibs) > 0 { |
| 57 | fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " ")) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 58 | } |
Dan Willemsen | a96ff64 | 2016-06-07 12:34:45 -0700 | [diff] [blame] | 59 | if c.Target().Os == android.Android && c.Properties.Sdk_version != "" { |
| 60 | fmt.Fprintln(w, "LOCAL_SDK_VERSION := "+c.Properties.Sdk_version) |
| 61 | fmt.Fprintln(w, "LOCAL_NDK_STL_VARIANT := none") |
| 62 | } else { |
| 63 | // These are already included in LOCAL_SHARED_LIBRARIES |
| 64 | fmt.Fprintln(w, "LOCAL_CXX_STL := none") |
| 65 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 66 | return nil |
| 67 | }) |
| 68 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 69 | for _, feature := range c.features { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 70 | c.subAndroidMk(&ret, feature) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 71 | } |
| 72 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 73 | c.subAndroidMk(&ret, c.compiler) |
| 74 | c.subAndroidMk(&ret, c.linker) |
| 75 | c.subAndroidMk(&ret, c.installer) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 76 | |
| 77 | return ret, nil |
| 78 | } |
| 79 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 80 | func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 81 | writeExportedIncludes := func(w io.Writer) { |
Dan Willemsen | 3b1fffa | 2016-05-05 15:11:48 -0700 | [diff] [blame] | 82 | var exportedIncludes []string |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 83 | for _, flag := range library.exportedFlags() { |
Dan Willemsen | 3b1fffa | 2016-05-05 15:11:48 -0700 | [diff] [blame] | 84 | if strings.HasPrefix(flag, "-I") { |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 85 | exportedIncludes = append(exportedIncludes, strings.TrimPrefix(flag, "-I")) |
| 86 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 87 | } |
| 88 | if len(exportedIncludes) > 0 { |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 89 | fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DIRS :=", strings.Join(exportedIncludes, " ")) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 90 | } |
Dan Willemsen | 847dcc7 | 2016-09-29 12:13:36 -0700 | [diff] [blame] | 91 | exportedIncludeDeps := library.exportedFlagsDeps() |
| 92 | if len(exportedIncludeDeps) > 0 { |
| 93 | fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedIncludeDeps.Strings(), " ")) |
| 94 | } |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | if library.static() { |
| 98 | ret.Class = "STATIC_LIBRARIES" |
| 99 | } else if library.shared() { |
| 100 | ctx.subAndroidMk(ret, &library.stripper) |
| 101 | ctx.subAndroidMk(ret, &library.relocationPacker) |
| 102 | |
| 103 | ret.Class = "SHARED_LIBRARIES" |
| 104 | } else if library.header() { |
| 105 | ret.Custom = func(w io.Writer, name, prefix, moduleDir string) error { |
| 106 | fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)") |
| 107 | fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir) |
| 108 | fmt.Fprintln(w, "LOCAL_MODULE :=", name) |
| 109 | |
| 110 | archStr := ctx.Target().Arch.ArchType.String() |
| 111 | var host bool |
| 112 | switch ctx.Target().Os.Class { |
| 113 | case android.Host: |
| 114 | fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH := ", archStr) |
| 115 | host = true |
| 116 | case android.HostCross: |
| 117 | fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH := ", archStr) |
| 118 | host = true |
| 119 | case android.Device: |
| 120 | fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH := ", archStr) |
| 121 | } |
| 122 | |
| 123 | if host { |
| 124 | fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", ctx.Target().Os.String()) |
| 125 | fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true") |
| 126 | } |
| 127 | |
| 128 | writeExportedIncludes(w) |
| 129 | fmt.Fprintln(w, "include $(BUILD_HEADER_LIBRARY)") |
| 130 | |
| 131 | return nil |
| 132 | } |
| 133 | |
| 134 | return |
| 135 | } |
| 136 | |
| 137 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
| 138 | writeExportedIncludes(w) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 139 | |
Dan Willemsen | 1d577e2 | 2016-08-29 15:53:15 -0700 | [diff] [blame] | 140 | fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext()) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 141 | |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 142 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 143 | |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 144 | if library.coverageOutputFile.Valid() { |
| 145 | fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", library.coverageOutputFile.String()) |
| 146 | } |
| 147 | |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 148 | return nil |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 149 | }) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 150 | |
Colin Cross | 4ac4480 | 2017-02-15 14:06:12 -0800 | [diff] [blame] | 151 | if library.shared() { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 152 | ctx.subAndroidMk(ret, library.baseInstaller) |
| 153 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 154 | } |
| 155 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 156 | func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Nan Zhang | 6d34b30 | 2017-02-04 17:47:46 -0800 | [diff] [blame] | 157 | ret.Custom = func(w io.Writer, name, prefix, moduleDir string) error { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 158 | out := ret.OutputFile.Path() |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 159 | |
Dan Willemsen | 72d3993 | 2016-07-08 23:23:48 -0700 | [diff] [blame] | 160 | fmt.Fprintln(w, "\n$("+prefix+"OUT_INTERMEDIATE_LIBRARIES)/"+name+objectExtension+":", out.String()) |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 161 | fmt.Fprintln(w, "\t$(copy-file-to-target)") |
| 162 | |
| 163 | return nil |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 164 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 165 | } |
| 166 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 167 | func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Colin Cross | 1e7d370 | 2016-08-24 15:25:47 -0700 | [diff] [blame] | 168 | ctx.subAndroidMk(ret, binary.baseInstaller) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 169 | ctx.subAndroidMk(ret, &binary.stripper) |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 170 | |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 171 | ret.Class = "EXECUTABLES" |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 172 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 173 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 174 | if Bool(binary.Properties.Static_executable) { |
Colin Cross | 3854a60 | 2016-01-11 12:49:11 -0800 | [diff] [blame] | 175 | fmt.Fprintln(w, "LOCAL_FORCE_STATIC_EXECUTABLE := true") |
| 176 | } |
Colin Cross | 9b09f24 | 2016-12-07 13:37:42 -0800 | [diff] [blame] | 177 | |
| 178 | if len(binary.symlinks) > 0 { |
| 179 | fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS := "+strings.Join(binary.symlinks, " ")) |
| 180 | } |
| 181 | |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 182 | if binary.coverageOutputFile.Valid() { |
| 183 | fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", binary.coverageOutputFile.String()) |
| 184 | } |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 185 | return nil |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 186 | }) |
| 187 | } |
| 188 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 189 | func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 190 | ctx.subAndroidMk(ret, benchmark.binaryDecorator) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 194 | ctx.subAndroidMk(ret, test.binaryDecorator) |
Dan Willemsen | 0fe7253 | 2017-01-17 13:25:49 -0800 | [diff] [blame] | 195 | ret.Class = "NATIVE_TESTS" |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 196 | if Bool(test.Properties.Test_per_src) { |
| 197 | ret.SubName = "_" + test.binaryDecorator.Properties.Stem |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 198 | } |
Colin Cross | faeb7aa | 2017-02-01 14:12:44 -0800 | [diff] [blame] | 199 | |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 200 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
| 201 | if len(test.Properties.Test_suites) > 0 { |
Dan Shi | 4df566d | 2017-04-03 12:29:25 -0700 | [diff] [blame] | 202 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 203 | strings.Join(test.Properties.Test_suites, " ")) |
| 204 | } |
| 205 | return nil |
| 206 | }) |
| 207 | |
Colin Cross | faeb7aa | 2017-02-01 14:12:44 -0800 | [diff] [blame] | 208 | var testFiles []string |
| 209 | for _, d := range test.data { |
| 210 | rel := d.Rel() |
| 211 | path := d.String() |
| 212 | if !strings.HasSuffix(path, rel) { |
| 213 | panic(fmt.Errorf("path %q does not end with %q", path, rel)) |
| 214 | } |
| 215 | path = strings.TrimSuffix(path, rel) |
| 216 | testFiles = append(testFiles, path+":"+rel) |
| 217 | } |
| 218 | if len(testFiles) > 0 { |
| 219 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
| 220 | fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " ")) |
| 221 | return nil |
| 222 | }) |
| 223 | } |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 224 | } |
| 225 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 226 | func (test *testLibrary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 227 | ctx.subAndroidMk(ret, test.libraryDecorator) |
| 228 | } |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 229 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 230 | func (library *toolchainLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 231 | ret.Class = "STATIC_LIBRARIES" |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 232 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 233 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext()) |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 234 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
| 235 | |
| 236 | return nil |
| 237 | }) |
| 238 | } |
| 239 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 240 | func (stripper *stripper) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 241 | // Make only supports stripping target modules |
| 242 | if ctx.Target().Os != android.Android { |
| 243 | return |
| 244 | } |
| 245 | |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 246 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
| 247 | if stripper.StripProperties.Strip.None { |
| 248 | fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false") |
| 249 | } else if stripper.StripProperties.Strip.Keep_symbols { |
| 250 | fmt.Fprintln(w, "LOCAL_STRIP_MODULE := keep_symbols") |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 251 | } else { |
| 252 | fmt.Fprintln(w, "LOCAL_STRIP_MODULE := mini-debug-info") |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | return nil |
| 256 | }) |
| 257 | } |
| 258 | |
Dan Willemsen | 394e9dc | 2016-09-14 15:04:48 -0700 | [diff] [blame] | 259 | func (packer *relocationPacker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 260 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
| 261 | if packer.Properties.PackingRelocations { |
| 262 | fmt.Fprintln(w, "LOCAL_PACK_MODULE_RELOCATIONS := true") |
| 263 | } |
| 264 | return nil |
| 265 | }) |
| 266 | } |
| 267 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 268 | func (installer *baseInstaller) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | 03ce63e | 2016-09-29 12:17:49 -0700 | [diff] [blame] | 269 | // Soong installation is only supported for host modules. Have Make |
| 270 | // installation trigger Soong installation. |
| 271 | if ctx.Target().Os.Class == android.Host { |
| 272 | ret.OutputFile = android.OptionalPathForPath(installer.path) |
| 273 | } |
| 274 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 275 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 276 | path := installer.path.RelPathString() |
Colin Cross | bf305de | 2016-03-29 17:32:06 -0700 | [diff] [blame] | 277 | dir, file := filepath.Split(path) |
| 278 | stem := strings.TrimSuffix(file, filepath.Ext(file)) |
Dan Willemsen | 1d577e2 | 2016-08-29 15:53:15 -0700 | [diff] [blame] | 279 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file)) |
Colin Cross | e14388b | 2016-05-03 14:08:40 -0700 | [diff] [blame] | 280 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir)) |
Colin Cross | bf305de | 2016-03-29 17:32:06 -0700 | [diff] [blame] | 281 | fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 282 | return nil |
| 283 | }) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 284 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 285 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 286 | func (c *stubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Albert | fd86e9e | 2016-11-08 13:35:12 -0800 | [diff] [blame] | 287 | ret.SubName = "." + c.properties.ApiLevel |
Dan Albert | 705c84b | 2016-08-08 10:45:03 -0700 | [diff] [blame] | 288 | ret.Class = "SHARED_LIBRARIES" |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 289 | |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 290 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 291 | path, file := filepath.Split(c.installPath) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 292 | stem := strings.TrimSuffix(file, filepath.Ext(file)) |
Dan Albert | cdd4c24 | 2016-08-08 14:44:56 -0700 | [diff] [blame] | 293 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
| 294 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext()) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 295 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path) |
| 296 | fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) |
| 297 | |
| 298 | // Prevent make from installing the libraries to obj/lib (since we have |
| 299 | // dozens of libraries with the same name, they'll clobber each other |
| 300 | // and the real versions of the libraries from the platform). |
| 301 | fmt.Fprintln(w, "LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES := false") |
| 302 | return nil |
| 303 | }) |
| 304 | } |