Commit graph

2732 commits

Author SHA1 Message Date
Paul Duffin
cf7f2e0a9e Merge "Make TestingBuildParams.RelativeToTop() modify (Writable)Path(s)" 2021-03-28 22:00:05 +00:00
Rupert Shuttleworth
b33f9d87c4 Remove lib_dns from bp2build converter denylist (module name typo, should be libc_dns).
Test: TH.
Change-Id: I636b7d6d09e96f6e25525ca48783281892a1eb02
2021-03-25 22:23:00 +00:00
Rupert Shuttleworth
a9e182440d Don't convert libc_dns using the cc_library_static bp2build converter.
Test: Manually ran bp2build-incremental presubmit in a new AOSP checkout.
Change-Id: I063f6f244c34c4456af77fb25579f95d724e8893
2021-03-25 21:56:15 +00:00
Colin Cross
d91c9b1c04 Merge "Use interface for $(location) values in genrules" 2021-03-25 21:06:55 +00:00
Colin Cross
ba5fff85a7 Merge changes Ie8721dcd,If1827b9d,Iec250a2d,I3f46f611,Idf136919, ...
* changes:
  Replace ANDROID_SDK_HOME with ANDROID_PREFS_ROOT for metalava
  Simplify lint rules using improved RuleBuilder rsp support
  Support multiple rsp files in RuleBuilder
  Pass rsp files into sbox and rewrapper
  Add test for sbox input sandboxing
  Support multiple rsp files in REParams
  Move response file handling to a separate package
2021-03-25 20:55:56 +00:00
Treehugger Robot
d411f069ff Merge "Remove obsolete comment on PrebuiltPostDepsMutator" 2021-03-25 19:37:51 +00:00
Colin Cross
d11cf62ec7 Use interface for $(location) values in genrules
Use an interface instead of a string to retrieve the value for
$(location) or $(locations) expansions in genrules to allow
delaying the evaluation until the RuleBuilderCommand is available.
This allows using helpers like RuleBuilderCommand.PathForInputs
to properly rewrite the values for sandboxing.

Also remove the standalone SboxPathFor* methods that don't operate
on a specific RuleBuilderCommand that are now unnecessary.

Test: genrule_test.go
Change-Id: I8bb2647332ef118204a216cead23d062517e2b8c
2021-03-25 11:06:45 -07:00
Colin Cross
ce3a51dc96 Support multiple rsp files in RuleBuilder
The lint rule is manually creating a second rsp file because Ninja
only supports on per rule.  Move the support into RuleBuilder so
that it can apply the same rewrites that it does to the primary
one.

Test: TestRuleBuilder_Build
Change-Id: Iec250a2d60e74ccf1b4ad085a960fec6867ea559
2021-03-25 11:06:45 -07:00
Colin Cross
e55bd423df Pass rsp files into sbox and rewrapper
The current implementation causes inputs listed in an rsp file used with
sbox to be duplicated 3 times in the build.ninja file; once as a
dependency of the rule, once in the rspfile_content field of the rule
with the paths rewritten to be relative to the sandbox, and once in the
rule to write the sbox manifest.  When RBE is enabled it also gets a
fourth copy in the list of files to be treated as inputs by rewrapper.

Reduce this to a single copy by using "$in" for the rspfile_content so
that the files only have to be listed in the input dependencies of the
rule, and then add support to sbox to rewrite the rsp file while copying
it into the sandbox, and pass it to rewrapper as well.

Test: m lint-check
Change-Id: I3f46f61119508d39a8bb231c99fc130153fb6f04
2021-03-25 11:06:45 -07:00
Colin Cross
045bfd9640 Add test for sbox input sandboxing
Add a test that was dropped in Ic0db961961b186e4ed9b76246881e3f04971825c.

Test: rule_builder_test.go
Change-Id: Idf136919939ad28eb5260dd8d686abe6948f47c7
2021-03-25 11:06:45 -07:00
Colin Cross
a4eafddc41 Support multiple rsp files in REParams
rewrapper supports a comma separate list of rsp files, replace
REParams.RSPFile with REParmas.RSPFiles.

Test: remoteexec_test.go
Change-Id: I7850c071c23d368d6fad4480dd527d146c13c6d3
2021-03-25 11:06:45 -07:00
Paul Duffin
bbb0f8fae4 Make TestingBuildParams.RelativeToTop() modify (Writable)Path(s)
Bug: 183650682
Test: m droid
Change-Id: I5cb150aa28cf1a06c353b67443fd2128aff4bb5d
2021-03-25 18:03:00 +00:00
Paul Duffin
301deecd6c Merge "Add Path.RelativeToTop" 2021-03-25 18:01:31 +00:00
Jingwen Chen
6400f20430 Merge "bp2build: add a per-module denylist." 2021-03-25 15:02:57 +00:00
Paul Duffin
85d8f0dcd9 Add Path.RelativeToTop
Makes Path.RelativeToTop the source of truth as to what `relative to
top` means.

Uses it in PathRelativeToTop so that it will be tested by the existing
tests that use AssertPathRelativeToTop.

Also adds RelativeToTop() to WritablePaths and Paths.

Bug: 183650682
Test: m droid
Change-Id: I88dc56afd1314e51b4e41795a2448cab4ce8a899
2021-03-25 13:14:37 +00:00
Jingwen Chen
5d72cba25c bp2build: add a per-module denylist.
This speeds up development of experimental converters.

Test: TH
Change-Id: I1623d3dbf63c8ed777646d64560d77b38edf9213
2021-03-25 09:29:26 +00:00
Paul Duffin
74abc5d4ee Remove config from basePath
Bug: 183650682
Test: m droid
Change-Id: I60eb2b8ed0317e874ecdafd5cb37d7c997d41bb8
2021-03-25 09:18:29 +00:00
Paul Duffin
d65c58b204 Add buildDir to WritablePath implementations
First, the buildDir() method was renamed to getBuildDir() to avoid
clashing with the buildDir field.

Then, a buildDir was added to both `OutputPath` and `InstallPath` but
not to `PhonyPath` as it does not contain any path components. Instead
the `PhonyPath.getBuildDir()` was changed to simply return "".

Bug: 183650682
Test: m droid
Change-Id: I12e1854c829b980c5c01205753c62c00dc0a4774
2021-03-25 09:18:29 +00:00
Paul Duffin
580efc8716 Add srcDir to SourcePath
Bug: 183650682
Test: m droid
Change-Id: I08f7dba449538d289a6c4d6b5325c1a833cff834
2021-03-25 09:18:29 +00:00
Paul Duffin
3cb2c06b44 Cleanup some issues left over from previous reviews
Bug: 183235980
Test: m nothing
Change-Id: I187765c56b889445de3a4729405ee745e5f73729
2021-03-24 22:08:05 +00:00
Paul Duffin
76e5c8a37f Convert test that disallows non existent paths to use fixtures
This change needed to add some additional files to the registered
files for PrepareForTestWithJavaDefaultModules because otherwise they
would fail when "TestAllowNonExistentPaths = false". Those files were
being added by the TestJavaLintRequiresCustomLintFileToExist (albeit in
some cases in different locations to that required by the default
modules but as the files are needed by the modules defined in
PrepareForTestWithJavaDefaultModules they should be defined in it.

A couple of other places also provided some files so moving them into
PrepareForTestWithJavaDefaultModules caused some conflicts which needed
to be resolved.

Bug: 183184375
Test: m nothing
Change-Id: I76ce9f1673c1c1c4000635b76b8377d582224bf1
2021-03-24 22:08:05 +00:00
Jingwen Chen
95c6eb3959 Merge "bp2build: add allowlist for package-level conversions." 2021-03-24 21:38:07 +00:00
Lukács T. Berki
543d4a5156 Merge "Make GENERATE_BAZEL_FILES=true correct." 2021-03-24 07:01:16 +00:00
Jingwen Chen
12b4c2706d bp2build: add allowlist for package-level conversions.
This CL adds the support for specifying lists of directories in
build/soong/android/bazel.go, which are then written into
out/soong/bp2build/MANIFEST. Using this configuration,
modules/directories can either default to bp2build_available: true or
false, while still retaining the ability to opt-in or out at the module level.

It also ensures that ConvertWithBp2Build returns true iff the module
type has a registered bp2build converter.

Test: go tests
Test: demo.sh full
Test: TreeHugger presubmits for bp2build and mixed builds.

Change-Id: I0e0f6f4b1b2ec045f2f1c338f7084defc5d23a55
2021-03-24 02:27:19 -04:00
Inseob Kim
eb120bd741 Merge "Add WithDexpreopt soong variable" 2021-03-24 06:20:03 +00:00
Colin Cross
fa65cee27f Fix genrule depending on disabled module with ALLOW_MISSING_DEPENDENCIES=true
If a genrule depends on a module that is disabled, in this case because
it is a device module in a host-only build, it can cause panics when
getPathsFromModuleDep retrieves a nil Path from the disabled module.
Treat disabled modules as missing dependencies.

Test: TestGenruleAllowMissingDependencies
Change-Id: I3c689c6b5505b21eaf7ae7cb93c00f96f438ac17
2021-03-23 16:17:37 -07:00
Jaewoong Jung
6158dfeb95 Remove obsolete comment on PrebuiltPostDepsMutator
Test: N/A
Change-Id: If01139ed361dd16022b50c503349d1d05282052b
2021-03-23 14:08:29 -07:00
Lukacs T. Berki
f0b3b94bb3 Make GENERATE_BAZEL_FILES=true correct.
This is achieved by writing soong.environment.used in Main() instead of
as a side effect of a singleton. This makes a difference because build
actions are not generated when GENERATE_BAZEL_FILES=true is set,
therefore the side effect did not happen.

Arguably, Main() is made worse by this change, but I don't want to
tackle the problem of readably determining which mode soong_build is
running in in this change.

Test: Presubmits + the additional test.
Change-Id: I66af2429aedf008762173eaaa55b828b4cf4328b
2021-03-23 15:18:22 +01:00
Inseob Kim
7b85eeb41e Add WithDexpreopt soong variable
Test: m selinux_policy on sc-arc
Change-Id: I9e8ba5746e4648a04fe4d8fbe5d3403ba06b5914
2021-03-23 20:52:24 +09:00
Paul Duffin
e0998ab561 Merge "Add preparer for overlay pre-singleton registration" 2021-03-23 07:21:30 +00:00
Paul Duffin
010bb3c5b3 Merge "Add TestingModule.VariablesForTestsRelativeToTop" 2021-03-23 07:21:01 +00:00
Paul Duffin
a327008e65 Merge "Add TestingBuildParams.RelativeToTop()" 2021-03-23 07:20:33 +00:00
Paul Duffin
332310aac4 Merge "Improve searching for TestingBuildParams using the output file" 2021-03-23 07:20:04 +00:00
Paul Duffin
b09a2d6af4 Merge "Move helper methods that take testBuildProvider into baseTestingComponent" 2021-03-23 07:19:42 +00:00
Paul Duffin
48c21e6454 Merge "Extract functionality common to TestingModule/Singleton" 2021-03-23 07:19:13 +00:00
Treehugger Robot
9b6108f8de Merge "Fix PackagingBase.CopyDepsToZip" 2021-03-23 04:21:38 +00:00
Treehugger Robot
04a2693407 Merge "Fix default value of BoardSepolicyVers" 2021-03-23 03:53:18 +00:00
Paul Duffin
42da69d784 Add preparer for overlay pre-singleton registration
It appears as though this is the first pre-singleton type to actually
be registered with the InitRegistrationContext as it failed due to an
uninitialized map, so this change also fixes that.

Bug: 182885307
Test: m nothing
Change-Id: Ibbf6d0db5f3c2fcc89291a16aa5f16b8b5009bd3
2021-03-22 22:09:53 +00:00
Paul Duffin
97d8b40fec Add TestingModule.VariablesForTestsRelativeToTop
Bug: 182885307
Test: m nothing
Change-Id: Id1265b07533f226965555e703fb9fa81aea4ec91
2021-03-22 22:09:53 +00:00
Paul Duffin
709e0e32c2 Add TestingBuildParams.RelativeToTop()
The methods returns a copy of TestingBuildParams with every usage of a
path that is relative to the temporary test build directory with a path
relative to a notional top. Similar to how PathRelativeToTop does.

Bug: 182885307
Test: m nothing
Change-Id: I6ec20fc52ed76748138f0d48b4df80f765dfcfdc
2021-03-22 22:09:53 +00:00
Paul Duffin
4e6e35c561 Improve searching for TestingBuildParams using the output file
When searching for an TestingBuildParams this change will compare the
supplied path against the value returned by PathRelativeToTop() as well
as the String() and Rel() values. In the event that it cannot find the
file it also formats the available outputs, one per line with both rel
and path relative to top.

Bug: 182885307
Test: m nothing
Change-Id: Icbd37018b9a028abf37e27d1bea12a407316e031
2021-03-22 22:09:53 +00:00
Paul Duffin
0eda26b96b Move helper methods that take testBuildProvider into baseTestingComponent
Allows the removal of the provider parameter and makes it easier to add
new functionality to baseTestingComponent.

Bug: 182885307
Test: m nothing
Change-Id: Ie8ac600cbce982f2c5fc24a22968efe0c2a29d0c
2021-03-22 22:09:53 +00:00
Paul Duffin
31a228846b Extract functionality common to TestingModule/Singleton
Bug: 182885307
Test: m nothing
Change-Id: Ib7c96b34512ad2a190a24c9dd07ea259d1378b44
2021-03-22 22:09:53 +00:00
Paul Duffin
4ca6752b21 Replace FixturePreparer.visit() with list()
The visit() method was dropped in favor of a list() method as the
latter makes it easier to treat fixtureFactory, simpleFixturePreparer
and compositeFixturePreparer as simple collections of already flattened
and deduped *simpleFixturePreparers. That will be used in a follow up
change.

Bug: 183235980
Test: m nothing
Change-Id: Ia41ae9bd4f9c39c85865ba698e0da6be00519caf
2021-03-22 18:31:53 +00:00
Paul Duffin
cff464f794 Remove errorHandler from FixtureFactory
The ExtendWithErrorHandler method simply wraps the FixtureErrorHandler
in a FixturePreparer that will set the error handler in the fixture.

Bug: 183235980
Test: m nothing

Change-Id: Icf9a5f62cb532efc120300c2f906cd3397aa6763
2021-03-22 18:31:53 +00:00
Paul Duffin
592518290f Allow access to preparers that produced a TestResult
The Preparer() method allows for another test to be run using the same
preparers as were used to create the TestResult. That is useful when
testing functionality like the sdk snapshot mechanism that generates an
Android.bp and a set of files that are intended to be reconsumed by
Soong. This method allows the test to process that output to ensure
that it is valid. A follow up change will migrate the CheckSnapshot()
method to use this as part of the migration of the sdk package to the
test fixture model.

Previously, the dedupAndFlattenPreparers() would not construct a list
containing all the preparers passed to it as it was trying to avoid
constructing such a list unless necessary. However, as every usage of
this method now needs to construct such a list that functionality has
been added to it.

Bug: 181070625
Test: m nothing
Change-Id: Iab34e2c861bdfd05c44e982224f70c5abc19e468
2021-03-22 18:31:53 +00:00
Paul Duffin
30ac3e7ca7 Remove uses of FixtureFactory from android package
Bug: 183235980
Test: m nothing
Change-Id: I72898ada020ee1a73fd534c61afb5c22fa00c1e5
2021-03-22 18:31:53 +00:00
Paul Duffin
ff2aa69a86 Deprecate FixtureFactory in favor of FixturePreparer
Prior to this FixtureFactory was basically a FixturePreparer with the
additional support for buildDirSupplier. This makes that a reality by
moving the functionality of FixtureFactory into FixturePreparer and
making FixtureFactory extend that with buildDirSupplier.

This also deprecates the Extend() method in favour of simply using the
GroupFixturePreparers() method.

Once all usages of buildDir have been removed so the buildDirSupplier
is no longer required then FixtureFactory will be removed altogether.
In the meantime follow up changes will migrate those tests that do not
require a buildDirSupplier to just use FixturePreparers in preparation
for the eventual removal of FixtureFactory.

Bug: 183235980
Test: m nothing
Change-Id: Ibb4e5bfec2f76ee34dd7de6aed6bbbfe27d337b8
2021-03-22 18:31:53 +00:00
Paul Duffin
6bef6fee3c Merge "Ensure that DepIsInSameApex is not called for ExcludeFromApexContentsTag" 2021-03-22 18:30:10 +00:00
Inseob Kim
0c4eec85fa Fix default value of BoardSepolicyVers
PlatformSepolicyVersion and BoardSepolicyVers haven't assigned correctly
so far. Below is the reason why it hasn't been discovered yet.

DeviceConfig.PlatformSepolicyVersion() was added to support mixed
sepolicy build (setting BOARD_SEPOLICY_VERS and building vendor sepolicy
with old plat policy files). Soong compares PlatformSepolicyVersion()
and BoardSepolicyVers(), and used old vendor sources if both are
different. Back then, the only place where such logic played a role was
selinux contexts. Test codes were running as intended: after setting
BOARD_SEPOLICY_VERS the context files were built against old policies.

But there were two mistakes:

1) PlatformSepolicyVersion() was not added to soong_config.mk, so it was
always empty.
2) BOARD_SEPOLICY_VERS was set to default in system/sepolicy/Android.mk,
which was processed after soong_config. So if BOARD_SEPOLICY_VERS was
not set in BoardConfig.mk, BoardSepolicyVers() was empty, not
PLATFORM_SEPOLICY_VERSION.

And there were no issues as Soong only checked equality.

To fix the issue correctly, this commit adds the variable
PlatformSepolicyVersion, and then handles BoardSepolicyVers correctly by
returning PlatformSepolicyVersion if it's empty.

Test: set BOARD_SEPOLICY_VERS and see vendor_file_contexts changes
Change-Id: Ie55827f47d2903e9739eccacc3874d354d5c9f2d
2021-03-22 22:34:56 +09:00