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 15package java 16 17import ( 18 "fmt" 19 "io" 20 21 "android/soong/android" 22) 23 24func (library *Library) AndroidMkEntriesHostDex() android.AndroidMkEntries { 25 hostDexNeeded := Bool(library.deviceProperties.Hostdex) && !library.Host() 26 if library.hideApexVariantFromMake { 27 hostDexNeeded = false 28 } 29 30 if hostDexNeeded { 31 var output android.Path 32 if library.dexJarFile != nil { 33 output = library.dexJarFile 34 } else { 35 output = library.implementationAndResourcesJar 36 } 37 return android.AndroidMkEntries{ 38 Class: "JAVA_LIBRARIES", 39 SubName: "-hostdex", 40 OutputFile: android.OptionalPathForPath(output), 41 Required: library.deviceProperties.Target.Hostdex.Required, 42 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", 43 ExtraEntries: []android.AndroidMkExtraEntriesFunc{ 44 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 45 entries.SetBool("LOCAL_IS_HOST_MODULE", true) 46 entries.SetPath("LOCAL_PREBUILT_MODULE_FILE", output) 47 if library.dexJarFile != nil { 48 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile) 49 } 50 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile) 51 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar) 52 entries.SetString("LOCAL_MODULE_STEM", library.Stem()+"-hostdex") 53 }, 54 }, 55 } 56 } 57 return android.AndroidMkEntries{Disabled: true} 58} 59 60func (library *Library) AndroidMkEntries() []android.AndroidMkEntries { 61 var entriesList []android.AndroidMkEntries 62 63 if library.hideApexVariantFromMake { 64 // For a java library built for an APEX we don't need Make module 65 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true}) 66 } else if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) { 67 // Platform variant. If not available for the platform, we don't need Make module. 68 // May still need to add some additional dependencies. 69 checkedModulePaths := library.additionalCheckedModules 70 if len(checkedModulePaths) != 0 { 71 entriesList = append(entriesList, android.AndroidMkEntries{ 72 Class: "FAKE", 73 // Need at least one output file in order for this to take effect. 74 OutputFile: android.OptionalPathForPath(checkedModulePaths[0]), 75 Include: "$(BUILD_PHONY_PACKAGE)", 76 ExtraEntries: []android.AndroidMkExtraEntriesFunc{ 77 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 78 entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", checkedModulePaths.Strings()...) 79 }, 80 }, 81 }) 82 } else { 83 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true}) 84 } 85 } else { 86 entriesList = append(entriesList, android.AndroidMkEntries{ 87 Class: "JAVA_LIBRARIES", 88 OutputFile: android.OptionalPathForPath(library.outputFile), 89 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", 90 ExtraEntries: []android.AndroidMkExtraEntriesFunc{ 91 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 92 if len(library.logtagsSrcs) > 0 { 93 var logtags []string 94 for _, l := range library.logtagsSrcs { 95 logtags = append(logtags, l.Rel()) 96 } 97 entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...) 98 } 99 100 if library.installFile == nil { 101 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true) 102 } 103 if library.dexJarFile != nil { 104 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile) 105 } 106 if len(library.dexpreopter.builtInstalled) > 0 { 107 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled) 108 } 109 entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion.String()) 110 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar) 111 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile) 112 113 if library.jacocoReportClassesFile != nil { 114 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile) 115 } 116 117 entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.classLoaderContexts.UsesLibs()...) 118 119 if len(library.additionalCheckedModules) != 0 { 120 entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...) 121 } 122 123 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", library.dexer.proguardDictionary) 124 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", library.dexer.proguardUsageZip) 125 entries.SetString("LOCAL_MODULE_STEM", library.Stem()) 126 127 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", library.linter.reports) 128 129 if library.dexpreopter.configPath != nil { 130 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", library.dexpreopter.configPath) 131 } 132 }, 133 }, 134 }) 135 } 136 137 entriesList = append(entriesList, library.AndroidMkEntriesHostDex()) 138 139 return entriesList 140} 141 142// Called for modules that are a component of a test suite. 143func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string) { 144 entries.SetString("LOCAL_MODULE_TAGS", "tests") 145 if len(test_suites) > 0 { 146 entries.AddCompatibilityTestSuites(test_suites...) 147 } else { 148 entries.AddCompatibilityTestSuites("null-suite") 149 } 150} 151 152func (j *Test) AndroidMkEntries() []android.AndroidMkEntries { 153 entriesList := j.Library.AndroidMkEntries() 154 entries := &entriesList[0] 155 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 156 testSuiteComponent(entries, j.testProperties.Test_suites) 157 if j.testConfig != nil { 158 entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig) 159 } 160 androidMkWriteExtraTestConfigs(j.extraTestConfigs, entries) 161 androidMkWriteTestData(j.data, entries) 162 if !BoolDefault(j.testProperties.Auto_gen_config, true) { 163 entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true") 164 } 165 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", j.testProperties.Test_mainline_modules...) 166 if Bool(j.testProperties.Test_options.Unit_test) { 167 entries.SetBool("LOCAL_IS_UNIT_TEST", true) 168 } 169 }) 170 171 return entriesList 172} 173 174func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) { 175 if len(extraTestConfigs) > 0 { 176 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...) 177 } 178} 179 180func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries { 181 entriesList := j.Library.AndroidMkEntries() 182 entries := &entriesList[0] 183 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 184 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites) 185 }) 186 187 return entriesList 188} 189 190func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries { 191 if prebuilt.hideApexVariantFromMake || !prebuilt.ContainingSdk().Unversioned() { 192 return []android.AndroidMkEntries{android.AndroidMkEntries{ 193 Disabled: true, 194 }} 195 } 196 return []android.AndroidMkEntries{android.AndroidMkEntries{ 197 Class: "JAVA_LIBRARIES", 198 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile), 199 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", 200 ExtraEntries: []android.AndroidMkExtraEntriesFunc{ 201 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 202 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable)) 203 if prebuilt.dexJarFile != nil { 204 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile) 205 } 206 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile) 207 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile) 208 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String()) 209 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem()) 210 }, 211 }, 212 }} 213} 214 215func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries { 216 if prebuilt.hideApexVariantFromMake { 217 return []android.AndroidMkEntries{android.AndroidMkEntries{ 218 Disabled: true, 219 }} 220 } 221 return []android.AndroidMkEntries{android.AndroidMkEntries{ 222 Class: "JAVA_LIBRARIES", 223 OutputFile: android.OptionalPathForPath(prebuilt.dexJarFile), 224 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", 225 ExtraEntries: []android.AndroidMkExtraEntriesFunc{ 226 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 227 if prebuilt.dexJarFile != nil { 228 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile) 229 } 230 if len(prebuilt.dexpreopter.builtInstalled) > 0 { 231 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled) 232 } 233 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem()) 234 }, 235 }, 236 }} 237} 238 239func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries { 240 if prebuilt.hideApexVariantFromMake { 241 return []android.AndroidMkEntries{{ 242 Disabled: true, 243 }} 244 } 245 return []android.AndroidMkEntries{android.AndroidMkEntries{ 246 Class: "JAVA_LIBRARIES", 247 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile), 248 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", 249 ExtraEntries: []android.AndroidMkExtraEntriesFunc{ 250 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 251 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) 252 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.classpathFile) 253 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.classpathFile) 254 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage) 255 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags) 256 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile) 257 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest) 258 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String()) 259 }, 260 }, 261 }} 262} 263 264func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries { 265 266 if !binary.isWrapperVariant { 267 return []android.AndroidMkEntries{android.AndroidMkEntries{ 268 Class: "JAVA_LIBRARIES", 269 OutputFile: android.OptionalPathForPath(binary.outputFile), 270 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", 271 ExtraEntries: []android.AndroidMkExtraEntriesFunc{ 272 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 273 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile) 274 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar) 275 if binary.dexJarFile != nil { 276 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile) 277 } 278 if len(binary.dexpreopter.builtInstalled) > 0 { 279 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled) 280 } 281 }, 282 }, 283 ExtraFooters: []android.AndroidMkExtraFootersFunc{ 284 func(w io.Writer, name, prefix, moduleDir string) { 285 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)") 286 }, 287 }, 288 }} 289 } else { 290 outputFile := binary.wrapperFile 291 // Have Make installation trigger Soong installation by using Soong's install path as 292 // the output file. 293 if binary.Host() { 294 outputFile = binary.binaryFile 295 } 296 297 return []android.AndroidMkEntries{android.AndroidMkEntries{ 298 Class: "EXECUTABLES", 299 OutputFile: android.OptionalPathForPath(outputFile), 300 ExtraEntries: []android.AndroidMkExtraEntriesFunc{ 301 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 302 entries.SetBool("LOCAL_STRIP_MODULE", false) 303 }, 304 }, 305 ExtraFooters: []android.AndroidMkExtraFootersFunc{ 306 func(w io.Writer, name, prefix, moduleDir string) { 307 // Ensure that the wrapper script timestamp is always updated when the jar is updated 308 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)") 309 fmt.Fprintln(w, "jar_installed_module :=") 310 }, 311 }, 312 }} 313 } 314} 315 316func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries { 317 if app.hideApexVariantFromMake || app.appProperties.HideFromMake { 318 return []android.AndroidMkEntries{android.AndroidMkEntries{ 319 Disabled: true, 320 }} 321 } 322 return []android.AndroidMkEntries{android.AndroidMkEntries{ 323 Class: "APPS", 324 OutputFile: android.OptionalPathForPath(app.outputFile), 325 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk", 326 ExtraEntries: []android.AndroidMkExtraEntriesFunc{ 327 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 328 // App module names can be overridden. 329 entries.SetString("LOCAL_MODULE", app.installApkName) 330 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall) 331 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage) 332 if app.dexJarFile != nil { 333 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile) 334 } 335 if app.implementationAndResourcesJar != nil { 336 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar) 337 } 338 if app.headerJarFile != nil { 339 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile) 340 } 341 if app.bundleFile != nil { 342 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile) 343 } 344 if app.jacocoReportClassesFile != nil { 345 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile) 346 } 347 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", app.dexer.proguardDictionary) 348 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", app.dexer.proguardUsageZip) 349 350 if app.Name() == "framework-res" { 351 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)") 352 // Make base_rules.mk not put framework-res in a subdirectory called 353 // framework_res. 354 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true) 355 } 356 357 filterRRO := func(filter overlayType) android.Paths { 358 var paths android.Paths 359 for _, d := range app.rroDirs { 360 if d.overlayType == filter { 361 paths = append(paths, d.path) 362 } 363 } 364 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make 365 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority). 366 return android.ReversePaths(paths) 367 } 368 deviceRRODirs := filterRRO(device) 369 if len(deviceRRODirs) > 0 { 370 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...) 371 } 372 productRRODirs := filterRRO(product) 373 if len(productRRODirs) > 0 { 374 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...) 375 } 376 377 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources)) 378 379 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath) 380 381 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged()) 382 383 entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString()) 384 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...) 385 386 if app.embeddedJniLibs { 387 jniSymbols := app.JNISymbolsInstalls(app.installPathForJNISymbols.String()) 388 entries.SetString("LOCAL_SOONG_JNI_LIBS_SYMBOLS", jniSymbols.String()) 389 } else { 390 for _, jniLib := range app.jniLibs { 391 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name) 392 } 393 } 394 395 if len(app.jniCoverageOutputs) > 0 { 396 entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...) 397 } 398 if len(app.dexpreopter.builtInstalled) > 0 { 399 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled) 400 } 401 if app.dexpreopter.configPath != nil { 402 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", app.dexpreopter.configPath) 403 } 404 for _, extra := range app.extraOutputFiles { 405 install := app.onDeviceDir + "/" + extra.Base() 406 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install) 407 } 408 409 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports) 410 }, 411 }, 412 ExtraFooters: []android.AndroidMkExtraFootersFunc{ 413 func(w io.Writer, name, prefix, moduleDir string) { 414 if app.noticeOutputs.Merged.Valid() { 415 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", 416 app.installApkName, app.noticeOutputs.Merged.String(), app.installApkName+"_NOTICE") 417 } 418 if app.noticeOutputs.TxtOutput.Valid() { 419 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", 420 app.installApkName, app.noticeOutputs.TxtOutput.String(), app.installApkName+"_NOTICE.txt") 421 } 422 if app.noticeOutputs.HtmlOutput.Valid() { 423 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", 424 app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html") 425 } 426 }, 427 }, 428 }} 429} 430 431func (a *AndroidApp) getOverriddenPackages() []string { 432 var overridden []string 433 if len(a.appProperties.Overrides) > 0 { 434 overridden = append(overridden, a.appProperties.Overrides...) 435 } 436 if a.Name() != a.installApkName { 437 overridden = append(overridden, a.Name()) 438 } 439 return overridden 440} 441 442func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries { 443 entriesList := a.AndroidApp.AndroidMkEntries() 444 entries := &entriesList[0] 445 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 446 testSuiteComponent(entries, a.testProperties.Test_suites) 447 if a.testConfig != nil { 448 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig) 449 } 450 androidMkWriteExtraTestConfigs(a.extraTestConfigs, entries) 451 androidMkWriteTestData(a.data, entries) 452 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", a.testProperties.Test_mainline_modules...) 453 }) 454 455 return entriesList 456} 457 458func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries { 459 entriesList := a.AndroidApp.AndroidMkEntries() 460 entries := &entriesList[0] 461 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 462 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites) 463 // introduce a flag variable to control the generation of the .config file 464 entries.SetString("LOCAL_DISABLE_TEST_CONFIG", "true") 465 }) 466 467 return entriesList 468} 469 470func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries { 471 if a.hideApexVariantFromMake { 472 return []android.AndroidMkEntries{{ 473 Disabled: true, 474 }} 475 } 476 entriesList := a.Library.AndroidMkEntries() 477 entries := &entriesList[0] 478 479 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 480 if a.aarFile != nil { 481 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile) 482 } 483 484 if a.Name() == "framework-res" { 485 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)") 486 // Make base_rules.mk not put framework-res in a subdirectory called 487 // framework_res. 488 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true) 489 } 490 491 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage) 492 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile) 493 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile) 494 entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...) 495 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true) 496 }) 497 498 return entriesList 499} 500 501func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries { 502 return []android.AndroidMkEntries{android.AndroidMkEntries{ 503 Class: "JAVA_LIBRARIES", 504 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar), 505 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", 506 ExtraEntries: []android.AndroidMkExtraEntriesFunc{ 507 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 508 if BoolDefault(jd.properties.Installable, true) { 509 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip) 510 } 511 if jd.stubsSrcJar != nil { 512 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar) 513 } 514 }, 515 }, 516 }} 517} 518 519func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries { 520 return []android.AndroidMkEntries{android.AndroidMkEntries{ 521 Class: "JAVA_LIBRARIES", 522 OutputFile: android.OptionalPathForPath(ddoc.Javadoc.docZip), 523 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", 524 ExtraEntries: []android.AndroidMkExtraEntriesFunc{ 525 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 526 if ddoc.Javadoc.docZip != nil { 527 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip) 528 } 529 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !BoolDefault(ddoc.Javadoc.properties.Installable, true)) 530 }, 531 }, 532 }} 533} 534 535func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries { 536 // If the stubsSrcJar is not generated (because generate_stubs is false) then 537 // use the api file as the output file to ensure the relevant phony targets 538 // are created in make if only the api txt file is being generated. This is 539 // needed because an invalid output file would prevent the make entries from 540 // being written. 541 // 542 // Note that dstubs.apiFile can be also be nil if WITHOUT_CHECKS_API is true. 543 // TODO(b/146727827): Revert when we do not need to generate stubs and API separately. 544 545 outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar) 546 if !outputFile.Valid() { 547 outputFile = android.OptionalPathForPath(dstubs.apiFile) 548 } 549 return []android.AndroidMkEntries{android.AndroidMkEntries{ 550 Class: "JAVA_LIBRARIES", 551 OutputFile: outputFile, 552 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", 553 ExtraEntries: []android.AndroidMkExtraEntriesFunc{ 554 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 555 if dstubs.Javadoc.stubsSrcJar != nil { 556 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar) 557 } 558 if dstubs.apiVersionsXml != nil { 559 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml) 560 } 561 if dstubs.annotationsZip != nil { 562 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip) 563 } 564 if dstubs.metadataZip != nil { 565 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.metadataZip) 566 } 567 }, 568 }, 569 ExtraFooters: []android.AndroidMkExtraFootersFunc{ 570 func(w io.Writer, name, prefix, moduleDir string) { 571 if dstubs.apiFile != nil { 572 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name()) 573 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.apiFile) 574 } 575 if dstubs.removedApiFile != nil { 576 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name()) 577 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.removedApiFile) 578 } 579 if dstubs.checkCurrentApiTimestamp != nil { 580 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api") 581 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:", 582 dstubs.checkCurrentApiTimestamp.String()) 583 584 fmt.Fprintln(w, ".PHONY: checkapi") 585 fmt.Fprintln(w, "checkapi:", 586 dstubs.checkCurrentApiTimestamp.String()) 587 588 fmt.Fprintln(w, ".PHONY: droidcore") 589 fmt.Fprintln(w, "droidcore: checkapi") 590 } 591 if dstubs.updateCurrentApiTimestamp != nil { 592 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api") 593 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:", 594 dstubs.updateCurrentApiTimestamp.String()) 595 596 fmt.Fprintln(w, ".PHONY: update-api") 597 fmt.Fprintln(w, "update-api:", 598 dstubs.updateCurrentApiTimestamp.String()) 599 } 600 if dstubs.checkLastReleasedApiTimestamp != nil { 601 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api") 602 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:", 603 dstubs.checkLastReleasedApiTimestamp.String()) 604 605 fmt.Fprintln(w, ".PHONY: checkapi") 606 fmt.Fprintln(w, "checkapi:", 607 dstubs.checkLastReleasedApiTimestamp.String()) 608 609 fmt.Fprintln(w, ".PHONY: droidcore") 610 fmt.Fprintln(w, "droidcore: checkapi") 611 } 612 if dstubs.apiLintTimestamp != nil { 613 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint") 614 fmt.Fprintln(w, dstubs.Name()+"-api-lint:", 615 dstubs.apiLintTimestamp.String()) 616 617 fmt.Fprintln(w, ".PHONY: checkapi") 618 fmt.Fprintln(w, "checkapi:", 619 dstubs.Name()+"-api-lint") 620 621 fmt.Fprintln(w, ".PHONY: droidcore") 622 fmt.Fprintln(w, "droidcore: checkapi") 623 624 if dstubs.apiLintReport != nil { 625 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint", 626 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt") 627 } 628 } 629 if dstubs.checkNullabilityWarningsTimestamp != nil { 630 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings") 631 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:", 632 dstubs.checkNullabilityWarningsTimestamp.String()) 633 634 fmt.Fprintln(w, ".PHONY:", "droidcore") 635 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings") 636 } 637 }, 638 }, 639 }} 640} 641 642func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries { 643 if a.hideApexVariantFromMake { 644 // The non-platform variant is placed inside APEX. No reason to 645 // make it available to Make. 646 return nil 647 } 648 return []android.AndroidMkEntries{android.AndroidMkEntries{ 649 Class: "APPS", 650 OutputFile: android.OptionalPathForPath(a.outputFile), 651 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk", 652 ExtraEntries: []android.AndroidMkExtraEntriesFunc{ 653 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 654 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged()) 655 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString()) 656 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...) 657 if len(a.dexpreopter.builtInstalled) > 0 { 658 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled) 659 } 660 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel()) 661 if Bool(a.properties.Export_package_resources) { 662 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.outputFile) 663 } 664 }, 665 }, 666 }} 667} 668 669func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries { 670 entriesList := a.AndroidAppImport.AndroidMkEntries() 671 entries := &entriesList[0] 672 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 673 testSuiteComponent(entries, a.testProperties.Test_suites) 674 androidMkWriteTestData(a.data, entries) 675 }) 676 return entriesList 677} 678 679func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) { 680 var testFiles []string 681 for _, d := range data { 682 testFiles = append(testFiles, d.String()+":"+d.Rel()) 683 } 684 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...) 685} 686 687func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries { 688 return []android.AndroidMkEntries{android.AndroidMkEntries{ 689 Class: "ETC", 690 OutputFile: android.OptionalPathForPath(r.outputFile), 691 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk", 692 ExtraEntries: []android.AndroidMkExtraEntriesFunc{ 693 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 694 entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString()) 695 entries.SetPath("LOCAL_MODULE_PATH", r.installDir.ToMakePath()) 696 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...) 697 }, 698 }, 699 }} 700} 701 702func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries { 703 return []android.AndroidMkEntries{ 704 android.AndroidMkEntries{ 705 Class: "APPS", 706 OutputFile: android.OptionalPathForPath(apkSet.packedOutput), 707 Include: "$(BUILD_SYSTEM)/soong_android_app_set.mk", 708 ExtraEntries: []android.AndroidMkExtraEntriesFunc{ 709 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { 710 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", apkSet.Privileged()) 711 entries.SetString("LOCAL_APK_SET_INSTALL_FILE", apkSet.InstallFile()) 712 entries.SetPath("LOCAL_APKCERTS_FILE", apkSet.apkcertsFile) 713 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", apkSet.properties.Overrides...) 714 }, 715 }, 716 }, 717 } 718} 719