Commit graph

5075 commits

Author SHA1 Message Date
Paul Duffin
6a1160e749 Convert cc/prebuilt_test.go to use fixtures
Bug: 181070625
Test: m nothing
Change-Id: I6048812962382e2adaf79d941a24e5c0ffdd9b25
2021-03-11 15:04:43 +00:00
Paul Duffin
7d8a8ad0d1 Convert cc/cc_test.go tests that use CreateTestContext to fixtures
Bug: 181070625
Test: m nothing
Change-Id: I7e57c978fa07ee8c0f35d567753751bd7b128b1e
2021-03-11 15:04:39 +00:00
Paul Duffin
ecdac8a6d6 Convert fuchsia tests to use test fixtures
Bug: 181070625
Test: m nothing
Change-Id: Ic2b86f7c603ff1c4b48884cb58908db536d98f37
2021-03-11 07:26:11 +00:00
Treehugger Robot
b3d6edd6c0 Merge "AIDEGen: Add "-fprofile-sample-use" parameter into category." 2021-03-11 04:34:02 +00:00
Paul Duffin
02a3d65402 Support test fixtures in cc package
Restructures the cc package test setup code to create FixturePreparer
instances for setting up a test fixture and converts some tests to
use it.

The goal with this change is not to switch all the cc tests over to
directly using the new model but instead to ensure that the majority of
the cc tests run with the new model, to allow existing tests to easily
switch to the new model when needed and to allow dependent packages to
be switched to the new model.

Bug: 181070625
Test: m nothing
Change-Id: I00415f10fb44c1b9e78e1317e7f50bb61984d3a4
2021-03-09 23:06:00 +00:00
bralee
c117f6fc00 AIDEGen: Add "-fprofile-sample-use" parameter into category.
"-fprofile-sample-use" parameter needs to be added to
categorizeParameter function.

Bug: 181817731
Test: 1. aidegen -a -i c art build bootable frameworks/base/core libnativehelper external/protobuf external/gflags external/googletest hardware/interfaces/health packages/modules/Gki system/apex system/core/fastboot system/core/fs_mgr system/core/healthd system/core/init system/core/libbinderwrapper system/core/libcutils system/core/liblog system/core/libprocessgroup system/core/libutils system/core/property_service system/core/rootdir system/core/storaged system/extras system/gsid system/hwservicemanager system/libbase system/libhidl system/libhwbinder system/libvintf system/sepolicy system/update_engine test tools
      2. CLion launched without errors in 'CMake' tag.
Change-Id: I4e9b0fd19fe00d23a9aa535b1ab7ade9c4a46f69
2021-03-08 09:33:23 +08:00
Paul Duffin
cdcd2be1ff Fix build break caused by registering genrules twice
Two separate changes that passed presubmits separately and did not
conflict when merged together unfortunately clashed at runtime. The
changes are:
* Ic00c7e480dc738d7a88d038aca6ab95a1502a24a
* Ic98fdc29a63155174a3227e7e918b26f0a8763bb

Test: m nothing
Change-Id: I7b5704c22cc2ea2095f5fb92c59f0526bb445f13
2021-03-06 10:03:22 +00:00
Paul Duffin
0805d4ebdd Merge "Clean up cc.RegisterRequiredBuildComponentsForTest()" 2021-03-06 08:43:56 +00:00
Paul Duffin
6d119b804c Fix mutator ordering issue in apex tests
Previously, the override mutators were being run before the prebuilt
mutators that did not match the runtime behavior. This change fixes
that ordering.

In the process it broke TestApexWithAppImportsPrefer. That test tries
to verify that an apex that depends on an android_app will use an
android_app_import if that is preferred. Unfortunately, it only worked
because of the incorrect order of the mutators.

The test worked before this change because the prebuilt mutators were
being run after the overridableModuleDepsMutator. That meant that any
dependencies added by that mutator onto source modules could be
replaced by the PrebuiltPostDepsMutator with the preferred prebuilt
module.

Switching the order to match the runtime meant that the prebuilt
mutators were run before the overrides so never had a chance to replace
the dependencies added by the overrides.

Bug: 181953909
Bug: 181974714
Test: m nothing
Change-Id: Ic98fdc29a63155174a3227e7e918b26f0a8763bb
2021-03-05 18:38:58 +00:00
Paul Duffin
d6ceb8600c Clean up cc.RegisterRequiredBuildComponentsForTest()
Changes this function so it only registers components from the cc
package by pushing the call to genrule.RegisterGenruleBuildComponents()
down into those packages whose tests need it.

This will make it easier to migrate cc package tests to test fixtures
as the RegisterRequiredBuildComponentsForTest() no longer overlaps with
preparers from the genrule packages.

Bug: 181070625
Test: m nothing
Change-Id: Ic00c7e480dc738d7a88d038aca6ab95a1502a24a
2021-03-05 18:20:33 +00:00
Treehugger Robot
636d152e08 Merge "Remove Abseil checks from clang-tidy defaults." 2021-03-02 20:22:14 +00:00
Christopher Parsons
bc39e17a1d Merge "Support cc_object modules in mixed builds" 2021-03-02 16:44:56 +00:00
Paul Duffin
4b786d2da1 Merge "Remove deapexer and prebuilt apex select mutators" 2021-03-02 10:48:29 +00:00
Treehugger Robot
ce80f18749 Merge "APEX uses the latest version of the stub" 2021-03-02 01:02:18 +00:00
Chris Parsons
8d6e433c1e Support cc_object modules in mixed builds
Test: With a handwritten conversion of crtbegin_so1, USE_BAZEL_ANALYSIS=1 m crtbegin_so1
Change-Id: I7c777d7f46b37aa1827cc04205e2014f9293bf35
2021-03-01 18:22:34 -05:00
Krzysztof Kosiński
a3014f1c13 Remove Abseil checks from clang-tidy defaults.
Abseil is not available in Android, so these checks are not
actionable.

Test: Compiled frameworks/av, no more spurious warnings.
Change-Id: Ic573a3234a99b0fa1f63449e8d020a17a43a134c
2021-03-01 13:25:03 -08:00
Paul Duffin
c04fb9e6a2 Remove deapexer and prebuilt apex select mutators
Originally, when the prebuilt_apex was first created, it selected the
source to use in its DepsMutator. It did that because that was a
convenient place for it to perform that work which had to be:
* After the arch mutator had run so MultiTargets() was available.
* Before the prebuilt_select mutator runs as that relied on the Source
  property to have been set.

Change 064b70c9 then duplicated the call from the DepsMutator of the
deapexer module type that was added as part of the work to make dex
files available for hiddenapi processing.

Change 356f7d45 moved it out of the the DepsMutator methods into its
their own mutators, presumably because it interfered with the
Soong -> Bazel conversion work.

This change improves the existing PrebuiltSrcsSupplier mechanism to
support reporting errors so that the logic for selecting the source can
be done on demand rather than in separate mutators.

The main complication was that PrebuiltSrcsSupplier is called with a
BaseModuleContext for both source and prebuilt modules so it cannot use
any methods on it that are related to the current module. That
necessitated adding MultiTargets() to android.Module.

Bug: 181267622
Test: m droid
Change-Id: I106c78fd21016f051a315b82b470d8f12b1f820b
2021-03-01 17:11:25 +00:00
Jingwen Chen
37bd24a1db Merge "bp2build: add configurable attribute (select) support." 2021-03-01 13:43:55 +00:00
Jiyong Park
55549df051 APEX uses the latest version of the stub
Previously when an APEX whose min_sdk_version is set is linked to an
external library providing multiple versions of stubs, the
maximum version that is less than or equal to the min_sdk_version was
chosen. For example, if the versions of a library stubs are 28, 29, 30,
and 31, then APEX with min_sdk_version: 29 linked to the version 29 of
the stub.

This was to ensure that the APEX doesn't use any new APIs whose
existence can't be guaranteed.

This however imposes a severe restriction that the APEX can never use
new APIs even when the APIs are actually available: i.e. when the
APEX is running on a newer platform.

With the recent work about unguarded availability, using the future APIs
became much safer. When you use an API that is newer than your
min_sdk_version, the API is automatically declared as a weak symbol
(thus no link error at runtime), while the call to API is guaranteed to
be guarded with the `__builtin_available(...)` macro.

So, there really is no reason to use the old version of the stub. We can
always use the latest version of stub safely.

Bug: N/A
Test: m
Change-Id: Iaac0d8761d8929154527dc2e861a51ae31e23d49
2021-03-01 09:12:32 +00:00
Chih-hung Hsieh
7e52be849e Merge "Forbit extra quotes in tidy flag lists" 2021-02-27 08:45:47 +00:00
Jingwen Chen
5d8644990b bp2build: add configurable attribute (select) support.
This CL adds a basic framework to support configurable string_list
attributes, selecting on the Arch variant (x86, x86_64, arm, arm64).

It offers fine-grained controls to map individual configurable
properties (arch_variant) to configurable Bazel attributes, starting
with the string_list type for the copts property for cc_object.

This design is primarily motivated to have minimal boilerplate in
bp2build mutators, allowing anyone to opt-in configurable attributes,
and modify intermediate states before passing them on into the
CreateBazelTargetModule instantiator.

Fixes: 178130668

Test: go tests
Test: build/bazel/scripts/milestone-2/demo.sh

Change-Id: Id6f04d7c560312a93e193d7ca4e1b7ceb6062260
2021-02-26 05:17:54 -05:00
Justin Yun
07b9f86f0c Define getSnapshotNameSuffix()
By sharing a single function for generating snapshot name suffix,
make sure both the DepsMutator and the snapshot modules use the same
names.

Bug: 179666286
Test: m nothing
Change-Id: I9efa94f2981a6bd1b4128bf0e84ca44873ebf3b7
2021-02-26 14:00:03 +09:00
Chih-Hung Hsieh
217e09a784 Forbit extra quotes in tidy flag lists
* Start with clang-tidy flags;
  maybe other flags should be checked too.

Bug: 180862582
Test: make
Change-Id: I82f86a911733693a14fe56a35e28590b065e3ae7
2021-02-25 20:46:15 -08:00
Treehugger Robot
a777d960ab Merge "Remove dependency from vendor_snapshot to each module" 2021-02-26 03:57:42 +00:00
Jingwen Chen
1251bb5775 Merge "bp2build: add support for cc_object's objs and exclude_srcs properties." 2021-02-25 14:09:08 +00:00
Justin Yun
4813867ec3 Remove dependency from vendor_snapshot to each module
The 'vendor_snapshot' module is required to every cc_library to check
if the dependencies need to be rewritten to the snapshot modules or
not. However, as the 'vendor_snapshot' module has dependencies to the
snapshot modules, the dependency to the 'vendor_snapshot' module
creates circular dependencies.
The dependency from the 'vendor_snapshot' to the snapshot modules is
required only to read the module names of the snapshot modules. We
may remove the dependency by setting the name of the snapshot modules
directly.

Bug: 179666286
Test: m nothing
Change-Id: I14abcb06c5c81ef7f8535103578747385c89ae0f
2021-02-25 09:31:12 +00:00
Christopher Di Bella
c28f5d97a6 reverses common and external Clang flags
Flags for external projects are specialisations of the common flags, and
need to follow the common flags, not precede them.

Bug: 181177782
Test: None

Change-Id: I19c8c2a3539573e9b2f2d9e3e1c898fa09570663
2021-02-25 01:34:08 +00:00
Paul Duffin
b2773e116f Merge "Generated headers may not be arch specific" 2021-02-24 10:10:23 +00:00
Paul Duffin
efa0f00706 Merge "Fix the snapshot handling of generated headers" 2021-02-24 10:08:34 +00:00
Jingwen Chen
db12024524 bp2build: add support for cc_object's objs and exclude_srcs properties.
objs contains module references to other cc_objects that will be used
for linking later. This maps to cc_library deps.

Also support exclude_srcs, and added tests.

Test: bp2build generate, sync, bazel build //bionic/...

Change-Id: I21200ff73f24bcf5357d9df8dcb5519cde532a77
2021-02-24 01:08:57 -05:00
Treehugger Robot
bbfd5ab606 Merge "Move bazel.Properties to a BazelModuleBase" 2021-02-24 05:53:25 +00:00
Treehugger Robot
30899caf1f Merge "Refactor BazelTargetModule" 2021-02-23 20:40:23 +00:00
Liz Kammer
ea6666fba9 Move bazel.Properties to a BazelModuleBase
This allows more direct access to the bazel label and whether the module
is bp2build available.

Test: go test *
Change-Id: I23375835d20fa53d7d94127b2dc2d5bb20487bfb
2021-02-23 10:58:57 -05:00
Paul Duffin
1dd5764a4e Merge "Only export sysprop headers in exported sysprop include directory" 2021-02-23 15:28:26 +00:00
Treehugger Robot
2b22365c8c Merge "Export aidl, proto and sysprop generated headers separately" 2021-02-23 14:11:24 +00:00
Liz Kammer
fc46bc1ee4 Refactor BazelTargetModule
This eliminates the need to remove quotes, delete attributes, and
re-checking that name has correct prefix. Additionally, this allows
assignment directly to the BazelTargetModuleProperties struct, which
allows defaulting unused fields and clarity of which field is being set.

Test: go test soong tests
Test: ran ./build/bazel/scripts/milestone-2/demo.sh
Change-Id: Ia9bfcce76234c793a4ddd5f29a661150f83341c9
2021-02-23 08:29:40 -05:00
Treehugger Robot
277303f042 Merge "Add ctx to AndroidMkExtraEntriesFunc" 2021-02-22 22:40:31 +00:00
Paul Duffin
7a7d067c74 Generated headers may not be arch specific
Previously, it was assumed that generated headers must be arch specific
and so prevented the fields referencing the paths to those headers from
being automatically optimized by the sdk generation code. That is not
always the case, e.g. with headers generated from protos so this change
allows those fields to be optimized.

Bug: 180427921
Test: m nothing
Change-Id: Id2af419d58ae3c30ea6d9e87f71e33a9ff6ba13b
2021-02-22 18:23:22 +00:00
Paul Duffin
42dd4e6cd6 Fix the snapshot handling of generated headers
Previously, the snapshot handling code did not preserve the directory
structure of generated include directories and instead just copied the
headers into the same module specific directory and added that single
directory to the export_include_dirs (or similar) property.

That had a couple of issues:
* The include directory was repeated in the ..._include_dirs property.
* It did not work when the include directories overlapped.

In the latter case it had a couple of issues:
* Code which compiled fine against the source would not compile against
  the prebuilt.
* Header files were duplicated in the output.

e.g. assume the following generated header file structure:
  foo/
      foo.h
  bar/
      bar.h
      baz/
          baz.h

When the sdk snapshot was passed include directories of "foo", "bar" and
headers of "foo/foo.h", "bar/bar.h", "bar/baz/baz.h" it would generate a
snapshot with the structure:
  include_gen/
      foo.h
      bar.h
      baz/
         baz.h

And:
  export_include_dirs: ["include_gen", "include_gen"]

However, when the include directories overlapped and include directories
of "foo", "bar" and "bar/baz" were passed in the directory structure
would be the same and the export_include_dirs would contain 3 usages of
"include_gen".

That meant that source code which used the following would build
against the source (because it would find "baz.h" in the "bar/baz"
include directory) but would fail when built against the prebuilts
because the "include_gen" directory did not contain "baz.h":
    #include "baz.h"

This change preserves the input directory structure for generated files
in a similar way to how it does it for source files. So, the snapshot
structure looks something like this:

  include_gen/
      foo/
          foo.h
      bar/
          bar.h
          baz/
              baz.h

And:
  export_include_dirs: [
    "include_gen/foo",
    "include_gen/bar",
    "include_gen/bar/baz",
  ],

Bug: 180427921
Test: m nothing
Change-Id: Id69eef8cf5eecd033841d3b7cd0c044a697ce404
2021-02-22 18:23:22 +00:00
Paul Duffin
37e0de5004 Only export sysprop headers in exported sysprop include directory
Bug: 180712399
Test: m nothing
Change-Id: Ia93d20fe0fecf977773257fa43fe40e7fe9f024f
2021-02-22 18:05:18 +00:00
Paul Duffin
33056e8a9a Export aidl, proto and sysprop generated headers separately
Previously, a cc library that included .aidl, .proto and/or .sysprop
files and exported headers generated from at least one of those types
would actually export generated headers from all of them.

While headers generated from .sysprop files are always exported those
generated from .aidl or .proto should only be exported when explicitly
requested.

This change treats them separately as expected. It has the potential
to break the build as it could reduce the set of headers exported and
so a dependent module that needed those would break. The fix in that
case is to simply add one (or both) of the following to the module
that previously exported those headers:

  aidl: {
    export_aidl_headers: true,
  }

  proto: {
    export_proto_headers: true,
  }

Bug: 180712399
Test: m droid
Change-Id: I488182e27dd423d261443612f98d5c112dd3ef8f
2021-02-22 18:05:10 +00:00
Paul Duffin
bc179bc44f Merge "Add tests for exported generated headers" 2021-02-22 18:03:00 +00:00
Justin Yun
107a4cb56c Update test_min_api_level for cc_test
By replacing MinApiLevelModuleController with
ShippingApiLevelModuleController, we don't need to define
api-level-prop option. The property name must not be a parameter but
be defined in the module controller.

test_min_sdk_version is removed as it is not used.

Bug: 178990561
Test: atest vts_core_liblp_test
Change-Id: Ib4660b91c7adb2ec8b970197dc6f65b8e6952a66
2021-02-20 00:46:21 +00:00
Colin Cross
aa2555387d Add ctx to AndroidMkExtraEntriesFunc
Add a ctx parameter to AndroidMkExtraEntriesFunc to allow them to
access providers.

Test: m checkbuild
Change-Id: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc
Merged-In: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc
2021-02-19 23:05:40 +00:00
Elliott Hughes
272649ceb5 Merge "__ANDROID_UNGUARDED_AVAILABILITY__ is gone now." 2021-02-19 22:27:11 +00:00
Elliott Hughes
5a8c9531e4 __ANDROID_UNGUARDED_AVAILABILITY__ is gone now.
So no need to keep `-D`ing it.

Bug: http://b/179067538
Test: treehugger
Change-Id: If5bcead40d3bb355c241e363a8f1a956cb144438
2021-02-19 10:43:19 -08:00
Paul Duffin
3cb603eb51 Add tests for exported generated headers
Improves the test coverage for exporting of generated headers. These
tests highlight the bug described in b/180712399.

Follow up changes will refactor and fix bugs in this code. Adding the
tests separately help ensure that those changes do not inadvertantly
change the behavior.

Test: m nothing
Bug: 180712399
Change-Id: I0225b0cf53259071edb99a94be5014ed0e019bde
2021-02-19 17:12:01 +00:00
Julien Desprez
251261d01b Merge "Switch cc_test host_supported: true to unit tests" 2021-02-19 16:55:04 +00:00
Jingwen Chen
4e86b6ae43 Merge "bp2build: cc_object converter." 2021-02-19 03:54:43 +00:00
vichang
cd821d8283 Merge "Non-installable module should not be installed into a fuzzer .zip package" 2021-02-18 09:59:06 +00:00