Commit Graph

190 Commits

Author SHA1 Message Date
Colin Cross 988414c2cf Sandbox soong_build by changing to root directory
This relands I12a0f907753fefd1997ab8b4ea2ac331234093cf along with
a fix to blueprint for absolute paths.

Store the current working directory and then change to the root
directory so that all file accesses must go through helpers in
the android package that properly track dependencies.

Change-Id: I24ac485677aa102eec1a2521d16820da6ee1ae77
Fixes: 146437378
Test: m checkbuild
Test: m OUT_DIR=/tmp/out nothing
2020-01-11 01:11:46 +00:00
Colin Cross 47e4f9e1e8 Revert "Sandbox soong_build by changing to root directory"
This reverts commit 05c25ccb4a.

Reason for revert: broke absolute OUT_DIR
Bug: 146437378

Change-Id: I523ed79d40e1c1ef040212ba794a7a084abea75d
2020-01-10 18:51:04 +00:00
Colin Cross 05c25ccb4a Sandbox soong_build by changing to root directory
Store the current working directory and then change to the root
directory so that all file accesses must go through helpers in
the android package that properly track dependencies.

Fixes: 146437378
Test: m checkbuild
Change-Id: I12a0f907753fefd1997ab8b4ea2ac331234093cf
2020-01-09 14:19:46 -08:00
Treehugger Robot 64d5ccef7a Merge changes from topic "carry_required"
* changes:
  APEX carries required properties of its dependencies
  *RequiredModuleNames functions are available via Module interface
2020-01-07 03:51:29 +00:00
Colin Cross c34d2329b4 Use blueprint.EarlyModuleContext
Make android.EarlyModuleContext wrap blueprint.EarlyModuleContext

Test: m checkbuild
Change-Id: I5e05c4f3dfb177811bc244a5cc2d71f42e47613b
2020-01-06 10:57:24 -08:00
Jiyong Park 6a8cf5fab4 *RequiredModuleNames functions are available via Module interface
...so that the required module names can be known to other modules

Bug: N/A
Test: m
Change-Id: Ib032b51c4ea4fd77bdebcf09b2d1c2aec1c8eb27
2020-01-06 10:35:58 +09:00
Colin Cross 1184b647d5 Add EarlyModuleContext for LoadHookContext
Make LoadHookContext embed a new EarlyModuleContext instead of
BaseModuleContext to reduce its API surface in preparation for
moving it to run during parsing instead of mutators.

Test: m checkbuild
Change-Id: I1cd3ff3b636e7e24991a9184d7521903473e505a
2020-01-04 08:40:55 -08:00
Colin Cross 5e70805690 Add helper functions for getting output files from modules
Add OutputFileForModule and OutputFilesForModules to get paths from
OutputFileProducers.

Bug: 122332855
Test: m checkbuild
Change-Id: I2e9aeeb55987742077250390cdb804ba22e79442
2019-12-19 17:52:50 +00:00
Colin Cross fb0c16e95a Move imageMutator before archMutator
Run the imageMutator between osMutator and archMutator so that
different arch variants can be set for the different partitions.

Bug: 142286466
Test: m checkbuild
Change-Id: I65d05714b75aa462bf9816da60fdc2deda4de593
Merged-In: I65d05714b75aa462bf9816da60fdc2deda4de593
(cherry picked from commit 9c8f687584)
2019-12-17 14:45:11 -08:00
Anton Hansson f56f74be4a Fix duplicate sentence in visibility documentation
This paragraph was duplicated.

Test: treehugger
Change-Id: I6057b96e310ac0ebf8f6f2a86f93efafd189579e
2019-12-16 11:39:17 +00:00
Paul Duffin e44358fa8f Add support for host sdk
Adds HostSupported() method to ModuleBase for use by sdk. Adds
host_supported/device_supported to all prebuilt modules and the
sdk snapshot (where necessary).

Adds TestHostSnapshot to verify the behavior is correct.

Bug: 143678475
Test: m nothing
Change-Id: I8b4d097e46d5804f62cb8f651a83069299a3e639
2019-12-02 12:59:38 +00:00
Jooyung Han 6aa363b7ae Merge "Fix: install flattened apex on system_ext" 2019-11-27 07:30:54 +00:00
Jooyung Han 91df2084ad Fix: install flattened apex on system_ext
This build rule is specific to platform APEXes.
For non-platform APEXes, MakeAsSystemExt() is not applied.

This fixes the cases of "soc_specific: true" apexes which fails to
build.

Bug: 139053989
Test: m nothing (soong tests)
Change-Id: I98d0257499647ab41cdaa62a3671d89addbdf833
Exempt-From-Owner-Approval: got +1 before rebasing
2019-11-27 07:30:37 +00:00
Colin Cross 09ef474b6f Merge changes I0dcc9c7b,I9bc40642
* changes:
  Move cc.imageMutator into the android package
  Make CreateVariations return []android.Module
2019-11-25 22:30:17 +00:00
Roland Levillain 97c1f34067 Fix a typo in a comment in `android/module.go`.
Test: m
Change-Id: I1ea4e3ba70fc5f9e919495442ff94ab1e3b1fce2
2019-11-22 14:20:54 +00:00
Colin Cross 7228ecd5e3 Move cc.imageMutator into the android package
Prepare for making the image mutator available to all modules and
moving it between the os and arch mutators by moving it into the
android package and using an interface implemented by the module
types to control it.

Bug: 142286466
Test: No unexpected changes to out/soong/build.ninja
Change-Id: I0dcc9c7b5ec80edffade340c367f6ae4da34151b
2019-11-20 15:21:32 -08:00
Sundong Ahn d95aa2d45c Change the partition of outputfile
If some apex module can be installed for both flattened and unflattened,
flattened apex should be installed to system_ext partition.
So add MakeAsSystemExt func to change the partition from system to
system_ext.

Bug: 139053989
Test: m -j
Change-Id: I3e3430413a9045d96130af99e249567b1a26ed7e
2019-11-14 16:04:15 +09:00
Jooyung Han 43240b1191 Remove unused "product_services_specific" prop
product_services_specific is not used any longer.

Bug: 135957588
Test: m
Change-Id: I6c09d3c09773034085a1419cbffe86954066df4e
2019-11-12 17:07:52 +09:00
Ramy Medhat dd0418a4d4 Run non-RBE supported actions in the local pool when USE_RBE is set.
Bug: 143938974
Test: ran CTS build at -j500 successfully.
Change-Id: I55074bd67308cd716972e24fb56a20bc393d5d9d
2019-11-05 22:57:35 +00:00
Colin Cross a195f91471 Split out osMutator from archMutator
Split the archMutator into two mutators, osMutator to create
android/linux/darwin variants, and archMutator to then further
split them into arm/arm64, etc.  When combined with alias
variants in Blueprint this will allow us to depend on the
"android" variant without having to know what architectures
were used to build it.

Test: m checkbuild
Change-Id: I0f51d60fc440cf5ae503904ce7849ec797af5fe2
2019-10-16 15:27:23 -07:00
Colin Cross 2334757d24 Merge "Filter product variable property structs" 2019-10-07 20:53:44 +00:00
Treehugger Robot 96ce6ab143 Merge "Use localPool consistently for UseGoma() == true" 2019-10-04 18:36:07 +00:00
Colin Cross 70dda7e3da Separate InstallPath from OutputPath
Create a new type InstallPath that is similar to OutputPath to
differentiate intermediates output paths from installed output
paths.

RelPathString is a poorly defined, undocumented function that is
primarily used to get an install path relative to out/soong to
generate an equivalent install path for Make relative to $(OUT_DIR).
Move it to InstallPath for now, and fix the one remaining user on
OutputPath.

Add a method to create an NDK install path so that ndk_sysroot.go
doesn't have to do it manually with PathForOutput.

Bug: 141877526
Test: m checkbuild
Change-Id: I83c5a0bd1fd6c3dba8d3b6d20d039f64f353ddd5
2019-10-03 10:07:53 -07:00
Colin Cross 90ba5f4e98 Add InstallInRoot to allow modules to install into root partition
If InstallInRoot() returns true the module will be installed to
$OUT/root or $OUT/recovery/root.

Bug: 141877526
Test: m checkbuild
Test: no change to build.ninja or Android-${TARGET_PRODUCT}.mk
Test: TestPathForModuleInstall
Change-Id: Id6e435c6019f11eeb5806528fd464dbf220b88d9
2019-10-03 10:07:46 -07:00
Colin Cross 2e2dbc250a Use localPool consistently for UseGoma() == true
Remove the distinction between pctx.StaticRule and
pctx.AndroidStaticRule so that all of the local rules correctly
get assigned to the localPool.  Also put Module and Singleton
rules into the localPool.

Test: compare out/soong/build.ninja
Change-Id: Id2bb38eff3c7209340fe55bc9006f00bd3661d81
2019-10-01 14:11:20 -07:00
Jaewoong Jung 0949f31657 Fix android_test install path.
Test: m nothing + diff soong mk and ninja files.
Bug: 140795853
Change-Id: I3667eac951dea7e447cf73219ff89199fca9ed63
2019-09-27 16:42:20 -07:00
Colin Cross 18c46807c9 Filter product variable property structs
For each module, take the default product variable properties and
create a new type that contains only the properties that exist in
the current module.  This will provide better errors when attemping
to set product variable properties that will never get used for
a module, and fixes errors when a module attempts to use a product
variable that also contains properties that don't apply to the
current module.

Fixes: 79249983
Test: TestProductVariables
Test: m checkbuild
Change-Id: I4dc24f7781b8ce798651cfc8bf3563005a92c13d
2019-09-26 15:03:07 -07:00
Jooyung Han 344d5439c1 Add "apex_vndk" module type
"apex_vndk" is a variant of "apex" module.

apex_vndk {
  name: "com.android.vndk",
  ..
}

This rule is used to produce a VNDK APEX per vndk version.
It supports automatic inclusion of vndk libs.

If "vndk_version" property is set, the prebuilt vndk libs of
the version will be included in the apex bundle.

apex_vndk {
  name: "com.android.vndk.v29"
  vndk_version: "29",
  ...
}

Otherwise, platform's vndk version is used.

This will replace /system/{lib}/vndk-{ver} and vndk-sp-{ver}.

Bug: 134357236
Bug: 139772411
Test: m com.android.vndk
Change-Id: Ib5c86e625839389670d13c683a7427198ef6852f
2019-09-10 11:22:59 +09:00
Jooyung Han d48f3c3885 soong: Add tests for depending on disabled module
This will check if direct deps of android.Module type is "Enabled()".
Previously, this is checked only if a module calls VisitDeps*()
functions in GenerateAndroidBuildActions().

Most modules call VisitDeps*() in GenerateAndroidBuildActions(),
but some modules don't. For example, "apex" module calls
WalkDepsBlueprint() or VisitDirectDepsBlueprint() since it
exceptionally depends on non-android.Module modules.

Therefore, when an apex module depends on disabled(enabled:false) module,
build fails with panic, which is fixed by this change.

Test: m # runs soong tests
Change-Id: I81c5c148bbd51a253d2904690eb76ae7b6df1a0f
2019-08-26 13:19:42 +00:00
Treehugger Robot f02f30952d Merge "java_import can be included in apex" 2019-08-13 04:18:29 +00:00
Jiyong Park 9e6c242856 java_import can be included in apex
java_import can be included in apex via 'java_libs' property.

Bug: 139175488
Test: m (apex_test.go updated)
Change-Id: I3680a47cdac93b0cb2d41da8df3f8defa2bbe670
2019-08-13 09:36:39 +09:00
Colin Cross 607d8587e4 Add InstallBypassMake
Allow modules to mark themselves as InstallBypassMake, which will
cause android.PathForModuleInstall to return a path in $OUT_DIR
instead of $OUT_DIR/soong.  This can be used for modules that
can handle installation to the final location on their own.  The
main blocker for most modules is support for the "required" property,
which requires adding dependencies on the installed location of
other modules.

Bug: 122332855
Test: m checkbuild
Change-Id: I85238d937ff30335167d4b3fec79bbefc734b5e1
2019-08-06 09:45:04 -07:00
Paul Duffin 95d53b584f Add defaults_visibility support
Bug: 130796911
Test: m nothing
Change-Id: I7b9462d3360be2bbeaf6ff38c5328f45ff5b5ebb
2019-07-25 11:48:21 +01:00
Paul Duffin 63c6e183d5 Refactor visibility to support visibility on defaults modules
Existing modules, either general one or package ones have a single
visibility property, called visibility in general, and
default_visibility on package, that controls access to that module, or
in the case of package sets the default visibility of all modules in
that package. The property is checked and gathered during the similarly
named phases of visibility processing.

The defaults module will be different as it will have two properties.
The first, visibility, will not affect the visibility of the module, it
only affects the visibility of modules that 'extend' the defaults. So,
it will need checking but not parsing. The second property,
defaults_visibility, will affect the visibility of the module and so
will need both checking and parsing.

The current implementation does not handle those cases because:
1) It does not differentiate between the property that affects the
   module and those that do not. It checks and gathers all of them with
   the last property gathered overriding the rules for the previous
   properties.

2) It relies on overriding methods in MethodBase in order to change the
   default behavior for the package module. That works because
   packageModule embeds ModuleBase but will not work for
   DefaultsModuleBase as it does not embed ModuleBase and instead is
   embedded alongside it so attempting to override a method in
   MethodBase leads to ambiguity.

This change addresses the issues as follows:
1) It adds a new visibility() []string method to get access to the
   primary visibility rules, i.e. the ones that affect the module.

2) It adds two fields, 'visibilityPropertyInfo []visibilityProperty'
   to provide information about all the properties that need checking,
   and 'primaryVisibilityProperty visibilityProperty' to specify the
   property that affects the module.

The PackageFactory() and InitAndroidModule(Module) functions are
modified to initialize the fields. The override of the
visibilityProperties() method for packageModule is removed and the
default implementations of visibilityProperties() and visibility()
on ModuleBase return information from the two new fields.

The InitDefaultsModule is updated to also initialize the two new
fields. It uses nil for primaryVisibilityProperty for now but that
will be changed to return defaults_visibility. It also uses the
commonProperties structure created for the defaults directly instead
of having to search for it through properties().

Changed the visibilityProperty to take a pointer to the property that
can be used to retrieve the value rather than a lambda function.

Bug: 130796911
Test: m nothing
Change-Id: Icadd470a5f692a48ec61de02bf3dfde3e2eea2ef
2019-07-25 11:31:42 +01:00
Justin Yun d5f6c8261a Rename product_services to system_ext
Bug: 134359158
Test: build and check if system_ext.img is created
Change-Id: Ice3229baf97a94c24a6eea22e7d4571941d7f843
2019-07-09 08:57:05 +00:00
Colin Cross 9a36223d59 Add a String() method to android.Module
Add a String() method to android.Module for use in debugging.  Store
the name and variations of the module as they are mutated.

Test: TestModuleString
Bug: 136473661
Change-Id: I74e393703dcfc96ed4e21ac4a4419a7858b59216
2019-07-03 15:37:11 -07:00
Paul Duffin e484f47a63 Inherit default_visibility from parent package
Enhances the visibility mechanism to use the default_visibility
property of the closest ancestor package that has the property
specified.

Bug: 133290645
Test: m droid
Change-Id: I7248e9034a73894ac8d514f913316438c4d7c079
2019-06-27 13:24:59 +01:00
Paul Duffin e2453c705f Allow default visibility to be set per package
Adds a package module type with a default_visibility property. The
package module type can only be specified once per package.

Bug: 133290645
Test: m droid
Change-Id: Ibb2fb499c9ea88ecaa662d3cd2cbde478e4b9a4b
2019-06-27 13:24:50 +01:00
Jaewoong Jung 5b425e2e20 Optionally embed NOTICE files in apks.
If embed_notices or ALWAYS_EMBED_NOTICES is set, collect NOTICE files
from all dependencies of the android_app, merge them with the app's own
one (if exists), transform it to HTML, gzip it, and put it as an asset
in the final APK output.

Bug: 135460391
Test: app_test.go
Change-Id: I52d92e2fd19b3f5f396100424665c5cc344190d8
2019-06-24 19:10:22 -07:00
Colin Cross 4b69c497da Add implicit outputs to ErrorRule rules
When building with ALLOW_MISSING_DEPENDENCIES=true, Soong replaces
rules in modules that have missing dependencies with ErrorRule
rules that print an error.  The ErrorRules were not listing
implicit outputs, which could lead to dangling dependencies.

Test: manual
Change-Id: Ife1604c0a9a1159087b12568fd4c2b69517d81a7
2019-06-12 20:20:13 +00:00
Colin Cross dc35e21124 Consolidate *MutatorContext and ModuleContext into BaseModuleContext
Following 99bdb2ab4fd5168a71a20aecf10611425be47ec4 in build/blueprint,
move more methods into BaseModuleContext.

This reapplies I9f8df94f1ae2b55d3cccf7b9468247f3e7cb2ebd after fixing
missing errors thrown for missing defaults modules when
AllowMissingDependencies == true.

Test: m checkbuild
Test: defaults_test.go
Change-Id: Ia17b2bcbf2bac6889c419b2e73953946f6aa40ad
2019-06-10 16:30:35 -07:00
Colin Cross b88b3c5e77 Capture missing dependency error rules
Allow missing dependency errors to be tested by capturing the
missing dependency error rule instead of the originally requested
rule.

Test: all soong tests
Change-Id: Id2b23b9ee354cdafc44fb9adfaf8fe7bab973478
2019-06-10 15:51:06 -07:00
Colin Cross 6c4f21f3a1 Reimplement AddMissingDependencies
AddMissingDependencies is needed in BaseModuleContext in order
to allow PathsForModuleSrc and friends to be called in mutators,
It's not a simple move, as it currently writes to a module
field that would be lost if any mutators cloned new variants
by calling CreateVariations.  Reimplement it using a mutated
property instead.

Test: m checkbuild
Change-Id: I851125065e4c5302b552773dae4640426c62965e
2019-06-10 15:51:06 -07:00
Treehugger Robot b6fd6f75f2 Merge "Clean up sortedKeys function" 2019-06-10 19:16:14 +00:00
Colin Cross 380c69aab4 Revert "Consolidate *MutatorContext and ModuleContext into BaseModuleContext"
This reverts commit 7e0a2cb590.

Reason for revert: broke TARGET_BUILD_APPS builds

Change-Id: I5316a62f77bb38f6195e3df5e31b073dbd1eb682
2019-06-10 17:49:58 +00:00
Inseob Kim 1a365c6a7f Clean up sortedKeys function
This introduces a generic function SortedStringKeys which can be used to
get a slice of sorted string keys for all kinds of maps having string
keys.

Bug: N/A
Test: m
Change-Id: I542194c68984d909b7ad1dbf060d4d3a98f0ef23
2019-06-08 16:10:38 +09:00
Colin Cross 7e0a2cb590 Consolidate *MutatorContext and ModuleContext into BaseModuleContext
Following 99bdb2ab4fd5168a71a20aecf10611425be47ec4 in build/blueprint,
move more methods into BaseModuleContext.

Test: m checkbuild
Change-Id: I9f8df94f1ae2b55d3cccf7b9468247f3e7cb2ebd
2019-06-07 13:29:12 -07:00
Colin Cross 0ea8ba82fc Consolidate baseContext, BaseContext, and BaseModuleContext
blueprint.BaseModuleContext is the set of methods available to all
module-specific calls (GenerateBuildActions or mutators).  The
android package split the same functionality across baseContext (nee
androidBaseContext), BaseModuleContext, and BaseContext.
Consolidate all of them into android.BaseModuleContext.

Test: m checkbuild
Change-Id: I2d7f5c56fd4424032cb93edff6dc730ff33e4f1e
2019-06-06 20:01:31 -07:00
Colin Cross 4157e88427 Rename ModuleBase receivers
I3b23590b8ce7c8a1ea1139411d84a53163288da7 renamed AndroidModuleBase
to ModuleBase, but left the receivers called 'a'.  Rename them to
'm' to match the type.

Test: m checkbuild
Change-Id: I0ebb738152febfd9a2a56ac0b197f19f9e01a1e7
2019-06-06 20:01:23 -07:00
Colin Cross 25de6c30d3 Remove repetition in android package names
Types in the android package don't need to be prefixed with 'android'.

Test: m checkbuild
Change-Id: Ieefcfc1a2c4161d9c412f40ef31867149ec21aec
2019-06-06 17:24:01 -07:00