Commit graph

492 commits

Author SHA1 Message Date
Chris Parsons
ad876010fe Refactor mixed build allowlist handling
This refactoring prepares for introduction of bazel prod mode, an
alternative mechanism for mixed builds allowlist handling.

 * Decide bazel-mode as close to soong_build main as possible
 * BazelContext itself decides whether a module is allowlisted
 * Separate bp2build and mixed build allowlist

Test: m nothing, manually verified all modules are mixed build disabled
(via metrics)
Test: USE_BAZEL_ANALYSIS=1 m nothing, manually verified that mixed build
disabled/enabled modules are identical before and after change.

Change-Id: I0f55d8b85000cb4a871a099edc6d7d868d7df509
2022-08-23 13:15:12 -04:00
Zhenhuang Wang
409d27712f Add a new test_options.tags attribute to customize test execution
The `test_options.tags` attribute provides additional metadata to
customize test execution by downstream test runners. The tags have no
special meaning to Soong.

Bug: 240928948
Test: manually add `test_options.tags` attribute and run:
    $ refreshmod && \
      cat out/target/product/generic/module-info.json |\
      grep <tags>
Change-Id: I35267f6608e48c6184e56530ef128d93b2f97522
2022-08-22 08:16:17 +00:00
Colin Cross
d079e0b270 Reformat build/soong for go 1.19
Test: none
Change-Id: I132368f0fcbdb5ea088b5b84dbe4ccfdd9e94cad
2022-08-17 10:43:13 -07:00
Zhenhuang Wang
0ac5a431a9 Move common test_options properties into the android package
Multiple modules (e.g. java, cc, python, rust) define the `test_options`
field. Extract the common properties in test_options to share across
different test rules.

Bug: 240928948
Test: `refreshmod` and diff with original module-info.json
Change-Id: I404a7a157b4ccaa53d800ee2217559ff695bd825
2022-08-17 01:19:15 +08:00
Sasha Smundak
e198eafaf6 Clean up android/module.go
Test: treehugger
Change-Id: I41973dfc6805009d44323f3f1a89f923abf39c79
2022-08-04 15:49:11 -07:00
Sasha Smundak
a095406411 Consolidate Bazel conversion state into a single field in CommonProperties
Bazel conversion state needs to be cloned during module cloning, so it
should be registered via module.AddProperties. Until now it was done
implicitly as the modules converted so far added the whole
base.commonProperties field (and thus transitively all its subfields).
However, adding CommonProperties also adds its fields to the list of
the module's attributes, which is undesirable. The problem surfaced
while implementing Bazel conversion to the `license` rule.

Bug: 190817312
Test: treehugger
Change-Id: Id3de4ede8df81b21f00065a3a1bdc2d707391c3a
2022-08-03 10:46:19 -07:00
Bob Badour
0cc5facf79 Remove obsolete notice property.
Bug: 192434786

Test: m droid dist

Change-Id: I0f384ae895cebab9732448b82db600c67eb8f711
2022-07-29 17:54:40 +00:00
Bob Badour
9f847581b7 Keep Notice property from erasing license texts.
Remove "default to file in directory". Use explicit applicable license.

Bug: 192434786

Test: m droid dist

Change-Id: Id3d845b2073f151a8c0bad874e7ab005771bdfcb
2022-07-14 10:40:01 -07:00
Cole Faust
01243368d7 Allowlist apexer for bp2build
This also introduces a workaround for the fact that
apexer depends on aapt2, but aapt2 doesn't build
with bp2build yet. Aapt2 is removed from apexer's
requirements during bp2build.

Bug: 204244290
Test: ./build/bazel/ci/bp2build.sh
Change-Id: I837597ce035c7d5c06e1a3957166583a7a94b5c7
2022-06-09 13:28:25 -07:00
Romain Jobredeaux
41758c71be Merge "Allow empty zip file in extra files in install command." 2022-06-07 15:14:18 +00:00
Liz Kammer
dfeb120324 Handle restricting to device only builds
By default, most module types are only enabled for device. Converting
this behavior and host_supported/device_supported properties allows us
to skip building incompatible targets.

Test: soong tests
Test: bp2build.sh
Change-Id: If1da523b4cc8c4cbf2bb26da063d9923b662cc32
2022-05-31 17:46:48 -04:00
Treehugger Robot
5bec8d41ea Merge "Clean up some bp2build technical debt" 2022-05-23 18:01:04 +00:00
Chris Parsons
f874e46153 Refactor mixed builds to only take one pass
This large refactoring has both immense performance implications and
improves mixed builds complexity / usability. Summary:

1. Queueing calls to Bazel is done in a new mutator instead of a full
   soong_build pass. Normal soong_build flow is interrupted (via a
   functional hook in blueprint) to invoke bazel and parse its response.
2. Implementing mixed build support for additional modules is as simple
   as implementing MixedBuildsBuildable. In this interface, define the
   request that must be queued to Bazel, and then subsequently define
   how to handle the returned bazel cquery metadata.
3. Mixed builds consists of only a single pass. This greatly
   improves mixed build performance.

Result:
  A 33% runtime improvement on soong analysis phase with mixed builds.

Caveats:
  C++ BazelHandler handling still remains a bit of a mess; I did what
  I could within this CL's scope, but this may require additional cleanup.

Test: Treehugger
Test: Verified that aosp_arm ninja file is bit-for-bit identical with or
without this change.

Change-Id: I412d9c94d429105f4ebfafc84100d546069e6621
2022-05-20 10:04:13 -04:00
Romain Jobredeaux
1cef629459 Allow empty zip file in extra files in install command.
Test: m
Bug: 229901709
Change-Id: I4c8d1b16f2232d4cda75467615779145d2c7315e
2022-05-19 14:50:27 -04:00
Liz Kammer
3bf97bd1c0 Clean up some bp2build technical debt
Previously we ran mutators in bp2build mode to add dependencies, now we
look up modules by name directly. Remove workarounds to allow bp2build
mode to not fail when adding/handling dependencies.

Test: m bp2build
Change-Id: Ibf6fd905150cac306e5c395902ef28f609f4df2a
2022-05-13 19:47:48 -04:00
Yike
f628202aab Export Java library dependency information
Write `static_libs` and `libs` of Java library and Android app modules to module_bp_java_deps.json. This enables downstream tools to correctly set up the runtime environment. Note that while static libraries don't need to be on the Java classpath these modules could have non-static library dependencies that do need to be present.

Test: m out/soong/module_bp_java_deps.json
Bug: 227538646
Change-Id: I7c4aecb2fb03c890f0d2aaae80e619f6176809ef
2022-04-18 10:23:28 +08:00
Ram Muthiah
ac38c0bb93 Merge changes from topic "refactor-packagingbase"
* changes:
  Move GatherPackagingSpecs out of CopyDepsToZip
  Keep 'partition' in PackagingSpec
2022-03-29 13:45:22 +00:00
Treehugger Robot
4242115d59 Merge "Add values to json module graph" 2022-03-28 20:25:43 +00:00
Jooyung Han
99c5fe6a38 Keep 'partition' in PackagingSpec
Add a property 'partition' to PackagingSpec and fill it when
PackagingSpec is created.

This will enable PackageModule to filter PackgingSpec based on
partition. (Will be used in a follow-up change)

Bug: 225121718
Test: m (nothing changes)
Change-Id: I7657edd380e215df66bae57d8b07dd4181841fdf
2022-03-28 14:29:14 +09:00
Liz Kammer
898e076d6f Add values to json module graph
Increases size of json module graph but it still remains smaller than
action information.

Test: m json-module-graph
Change-Id: I215e92afb0f5d3d688e5e590517392d0cc534455
2022-03-25 18:30:49 -04:00
Trevor Radcliffe
dadc037ef3 Merge "Allow appending artifact in dist with product name" 2022-03-25 14:34:23 +00:00
Trevor Radcliffe
90727f4576 Allow appending artifact in dist with product name
Some modules need to have their artifacts copied to dist with the
product name appended. This CL enables that functionality in a
boolean Soong property called append_artifact_with_product.

Fixes: 224561567
Test: Unit tests and build relevant target/modules
Change-Id: I4b824d4001679cebf0a9059be2d090d33a310933
2022-03-24 14:46:18 +00:00
Colin Cross
e7fe0962f4 Export the license metadata files for dexpreopted bootjars to Make
Track the license metadata file of the module used to dexpreopt
bootjars and pass it to Make.

Bug: 224612665
Test: m alllicensemetadata reportmissinglicenses
Change-Id: I8466c3d8edf7dc44976c2a343bd38799c6617db2
2022-03-15 19:56:45 -07:00
Bob Badour
4101c71e63 Support multiple library names per target.
The prior interface to make supported only a single package name per
target; although, a target might have multiple licenses each with its
own package name.

Bug: 151177513
Bug: 210912771

Test: m all dist
Test: flash; About Phone -> Legal Information -> Third-party licenses

Change-Id: I1db5fcfd4c066afd162adb4eb4177960c7a503bd
2022-02-11 10:36:22 -08:00
Sam Delmerico
75539d62ae add target_compatible_with stanza for host targets
Soong modules that are specific for the host platform (e.g.
java_library_host, cc_binary_host, java_genrule_host, etc.) should
not be built on the target platform (Android), so we add a
target_compatible_with attribute to skip this type of module on an
Android target build.

Bug: 215229742
Test: go test ./bp2build
Change-Id: Ifb76ef4e0dc4cb3adb6a64b5c375ce36f7973e48
2022-02-03 19:25:12 +00:00
Treehugger Robot
97cffec54e Merge changes from topic "sdk_repo_license"
* changes:
  Generate sdk_repo notice files from license metadata
  Annotate more java dependencies for licensing
  Track transitive packaged license deps of containers
2022-01-31 23:34:59 +00:00
Usta Shrestha
defcf8d227 Merge "name parameters for clarity" 2022-01-29 06:33:55 +00:00
Colin Cross
aa1cab0a62 Generate sdk_repo notice files from license metadata
Use the new license metadata files to generate the notice files
for sdk_repo modules.

Bug: 207445310
Test: m sdk_repo_build_tools
Change-Id: I8079061fbdf7417c94eebbb1b31486d3f506f931
2022-01-28 15:56:07 -08:00
Liz Kammer
5514698bc8 Reverse order of tag and android module checks
Currently, this checks validates a module then checks the tag for all
modules. However, we don't need to validate modules where the tag does
not apply.

Test: m nothing and compare ninja/mk files
Change-Id: I6298c9dc8aa37ffac74202bea59f4090fff90e4e
2022-01-24 16:17:30 -05:00
Yu Liu
4ae55d17f6 Support multilib in apex.
Bug: b/208325023
Test: Added unit tests, also tested with adbd apex build manually.
Change-Id: I47e04cd4eb5d05227f0a84683dcb66dff00e3514
2022-01-18 10:38:05 -08:00
Usta
6b1ffa423d name parameters for clarity
Change-Id: If1879de10586b89aa572d04d5ad4e6157f2f4f30
2022-01-15 01:42:19 -05:00
Treehugger Robot
8f5399889b Merge "Start unblocking com.android.runtime deps" 2022-01-13 19:57:01 +00:00
Sam Delmerico
443703ab32 Merge "Support enabled flag in product variable config" 2022-01-12 20:34:14 +00:00
Sam Delmerico
0e33c9d772 Support enabled flag in product variable config
Some Android.bp modules have `enabled: false` but only use a product
variable such as `source_build` to enable the module.  Currently b2build
does not handle this case at all. This commit adds the functionality
to support this use case.

Also, remove `__enabled` suffix in ProductVariable SelectKey.

Bug: 210546943
Test: go test ./bp2build
Topic: use_enabled_flag_product_variable_config
Change-Id: I459c17a84c172df010666391066bf4d11d19253e
2022-01-12 16:26:44 +00:00
Liz Kammer
9525e71003 Add SetProperties to json-module-graph
SetProperties contains name and type of properties set in the bp file
and any set via defaults. There may be properties that were not
specified in an Android.bp file due to:
* specified via go code (e.g. LoadHooks)
* property is _not_ a pointer -- so it is not possible to tell between
  not set in bp file and default value.

Test: soong tests
Test: m json-module-graph and verify
Change-Id: I4cb868b1d7db566e72636c6fb53bb9c7090f236a
2022-01-11 10:47:23 -05:00
Usta
851a3271ce Use Module.GetProperties() instead of ModuleBase.generalProperties
ModuleBase.generalProperties served the pupose of being a subset
of ModuleBase.customizableProperties. But now with the removal of
the latter, the former is simply a redirection to Module.GetProperties()

Bug: 206961391
Test: m nothing and diff the ninja files
Change-Id: I6dd8b7ba74eb5e7ffb61029b0f9129eec2ccfdaf
2022-01-08 03:09:52 +00:00
Liz Kammer
daa09efb5e Start unblocking com.android.runtime deps
Adds support to warn rather than error about missing deps in order to
suport modules in build/soong with deps outside of build/sooong in
bp2build integration tests.

Test: build/bazel/ci/bp2build.sh
Change-Id: I1282bccd37a3fc9f33555d34e68d7f0873d8272c
2022-01-06 10:40:43 -05:00
Usta
dca0219965 Remove customizableProperties from android.ModuleBase
- customizableProperties was being used to access all properties,
i.e. basically `GetProperties()`

- generalProperties was a subset of properties,
i.e. `initArchModule()` would only add new arch-specific properties
to `customizableProperties` (and `archProperties`) but not `generalProperties`

This PR sets generalProperties to contain all properties,
which then makes customizableProperties redundant.
And in arch.go, any iteration is done via `archProperties` instead.

Bug: 206961391
Test: m nothing and diff the ninja files
Change-Id: Ieb72b31c0a447fcbf34c92a04f002d7b9d777a86
2022-01-04 13:33:51 -05:00
Chris Parsons
58852a05f3 Handle the 'enabled' property in bp2build
Also fix some bugs pertaining to configurable attribute handling of bool
attributes and label sttributes, so that they may support values across
multiple different axes at the same time.

Test: unit tests for bp2build
Test: mixed_droid

Change-Id: I411efcfddf02d55dbc0775962068a11348a8bb2c
2021-12-21 16:37:32 -05:00
Colin Cross
c68db4b305 Remove InstallBypassMake and ToMakePath
InstallBypassMake and ToMakePath are obsolete, remove them.

Bug: 204136549
Test: m checkbuild
Change-Id: Ie5a6f7254b3d317ed6039e114ed6aec35e1ce273
2021-12-15 15:22:53 -08:00
Usta Shrestha
54c827fbcb Merge "cosmetic changes" 2021-12-15 18:56:01 +00:00
Liz Kammer
bbabe6f3eb Ensure reported unconverted deps are unique
Test: m bp2build
Change-Id: I4a260d1f2ff9f6fd39c55c447466618fcdef52c7
2021-12-14 09:37:47 -05:00
Usta
eabf0f36f3 cosmetic changes
base.module = module is redundant in InitDefaultsModule() becase of the preceding initAndroidModuleBase()
minor reformat of initArchModel()

Test: m nothing
Bug: n/a

Change-Id: I16d5a400a33098a81ffbf6c81eba5b13db6debf1
2021-12-13 13:33:15 -05:00
Colin Cross
d8395b1b2f Revert^2 "Build license metadata files in Soong" am: 4acaea9cbf
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1918948

Change-Id: I8682f46f7843e0d367b96a09135dad03e3df934c
2021-12-11 03:48:25 +00:00
Treehugger Robot
f4c2bf6559 Merge changes from topic "revert-1918946-revert-1899703-AMWIVCREEV-CCTEXIRRRV"
* changes:
  Revert^2 "Add dependency license annotations"
  Revert^2 "Build license metadata files in Soong"
2021-12-11 03:32:18 +00:00
Colin Cross
4acaea9cbf Revert^2 "Build license metadata files in Soong"
b3264f2090

Change-Id: I5ea5f7e29eb1dbc72b8b30f010006a25f5f72fac
2021-12-10 23:05:02 +00:00
Colin Cross
67938c2925 Merge changes from topic "revert-1899703-AMWIVCREEV"
* changes:
  Revert "Build license metadata files in Soong"
  Revert "Add dependency license annotations"
2021-12-10 23:04:45 +00:00
Colin Cross
b3264f2090 Revert "Build license metadata files in Soong"
Revert submission 1899703

Reason for revert: b/210158272
Reverted Changes:
I142c19284:Reuse license metadata files from Soong
Ife89b8f23:Add dependency license annotations
I8e7410837:Build license metadata files in Soong

Change-Id: I48f2bf2e2797ac9d38f7ece35ba616b823035607
2021-12-10 23:02:57 +00:00
Colin Cross
b435744fdc Merge changes from topic "soong-license-metadata"
* changes:
  Add dependency license annotations
  Build license metadata files in Soong
  Escape Host*Variable contents
2021-12-10 21:43:49 +00:00
Colin Cross
3dd2ff28ed Build license metadata files in Soong
Soong has enough information to build the license metadata files
without resorting to the fixups required in Make.

Bug: 207445310
Test: m checkbuild
Change-Id: I8e74108376162b8fdb87ba098ebe94350aa1f7c4
2021-12-08 15:08:59 -08:00
Chih-Hung Hsieh
80783774b9 Add (obj|tidy)-*_os, and (obj|tidy)-*_subset targets
* The obj-* targets only call clang or clang++ to compile
  C/C++ files, like the tidy-* targets only call clang-tidy.
* Add (obj|tidy)-dir_os and module_os-(obj|tidy) phony targets
  to include only targets of the specified OS.
* Add (obj|tidy)-dir_os_subset and module_os_subset-(obj|tidy) phony targets
  to include only a subset of that OS target group.
  * Most clang-tidy runs produce the same warnings for all variants
    of an OS. The *_subset targets reduce runs over multiple variants.
  * The obj-*subset targets are useful for a quick test to compile
    at least one variant of every C/C++ file for each OS.
* The (obj|tidy)-soong phony target is changed to include only
  (obj|tidy)-top_level_directory targets instead of ALL
  module-(obj|tidy) targets in all subdirectories.
* For aosp_arm64-eng make tidy-* targets; count NINJA commands:
    tidy-soong                     381K
    tidy-soong_subset              106K
    tidy-soong_android             294K
    tidy-soong_android_subset       73K
    tidy-soong_linux_glibc          84K
    tidy-soong_windows              12K
    tidy-bionic                     12K
    tidy-bionic_subset               2.4K
    tidy-bionic_android             11.5K
    tidy-bionic_android_subset       2.1K
    tidy-bionic_linux_glibc          1K
    tidy-device_android              7K
    tidy-device_android_subset       5K
    tidy-hardware_android            3K
    tidy-hardware_android_subset     9K
    libfec_rs-tidy                   33
    libfec_rs_subset-tidy             9
    libfec_rs_android-tidy           18
    libfec_rs_android_subset-tidy     3
* For aosp_arm64-eng make obj-* targets; count NINJA commands:
    obj-soong                      399K
    obj-soong_subset               112K
    obj-soong_android              305K
    obj-soong_android_subset        75K
    obj-soong_linux_glibc           90K
    obj-soong_linux_glibc_subset    38K
    obj-soong_windows               12K
    obj-bionic                      15K
    obj-bionic_subset                3K
    obj-bionic_android              14K
    obj-bionic_android_subset        2.3K
    obj-bionic_linux_glibc           1.3K
    obj-system-core                  6K
    obj-system-core_subset           3K
    obj-frameworks-base             16K
    obj-frameworks-base_subset       6K
    libfec_rs-obj                    33
    libfec_rs_subset-obj              9
    libfec_rs_android-obj            18
    libfec_rs_android_subset-obj      3

Test: NINJA_ARGS="-n" WITH_TIDY=1 make some_obj_tidy_target;
      compare output commands from various phony targets
Bug: 199169329
Bug: 202769240
Change-Id: I186c45dc07c5884888c1063dfc09cf212ffb0ebf
2021-12-07 12:58:11 -08:00
Usta
355a587e38 Removal of unused methods AppendProperties and PrependProperties from topDownMutatorContext
Test: m nothing
Bug: n/a

Change-Id: Ia37d1c9b96c39603964ba8db2ea6ba52d1138472
2021-12-02 15:21:45 -05:00
Colin Cross
9579f4c05d Merge "Switch default for InstallBypassMake to true" 2021-11-30 20:31:26 +00:00
Usta
ef3676c94b Minor refactoring of Append/PrependProperties() methods
Test: `m nothing` and compare ninja file
Bug: n/a

Change-Id: If6e4a0de0a8f4f479fe3cbe044cf50d07648c8d9
2021-11-23 17:31:51 -05:00
Colin Cross
d5e7af9003 Switch default for InstallBypassMake to true
Enable InstallBypassMake for all module types by switching its default
to true.

Bug: 204136549
Test: m checkbuild
Change-Id: Ied082995e74d71dee6aecea99689ac3f63600d3b
2021-11-22 21:57:36 -08:00
Colin Cross
50ed1f9ccb Install android_app_set modules in Soong
Add support for installing extra files from a zip file when installing
a primary file, and use it to support installing android_app_set modules,
which install a primary APK and then an unknown set of additional splits
APKs.

Test: app_set_test.go
Test: install test android_app_set
Bug: 204136549
Change-Id: Ia92f7e5c427adcef3bcf59c82a2f83450905c01d
2021-11-17 19:55:33 -08:00
Colin Cross
64002afc56 Fix InstallBypassMake symlink dependencies
Host symlinks cannot use order-only dependencies because they may be
used as part of the dependency chain on a tool, and an order-only
dependency would cause the target of the symlink not to be updated.
Use regular dependencies instead.

Bug: 204136549
Fixes: 205674000
Test: TestInstallBypassMake
Change-Id: Ib3f4ee143e94d1995ec6c60d314e7c91e57cc775
2021-11-09 17:25:57 -08:00
Colin Cross
1caea35278 Merge "Export Soong install rules to Make" 2021-11-01 21:31:56 +00:00
Chih-Hung Hsieh
a3d135b1af Add -{checkbuild,tidy} targets only for modules in mm
Test: lunch aosp_coral-userdebug; WITH_TIDY=1
      make 7-libgptutils.coral-checkbuild 7-libgptutils.coral-tidy
Test: only coral libgptutils in out/build-aosp_coral.ninja
Test: lunch aosp_arm64-eng; make has no *libgptutils* tagets
Test: no libgptutils in out/build-aosp_arm64.ninja
Test: lunch aosp_cf_arm64_phone-userdebug; make libskia-checkbuild
Test: lunch aosp_arm64-eng; WITH_TIDY=1 make tidy-soong

Bug: 202763874
Change-Id: I2d5a3fdc627d62e43c3f10e61b338a03c10440be
2021-10-29 18:02:27 -07:00
Colin Cross
6301c3cffa Export Soong install rules to Make
Previously Soong's install rules have been disabled when embedded
in Make (ctx.Config().KatiEnabled() == true).  The primary blocker
for moving installation into Soong has been the `required` proeprty,
which is too vague to be easily handled in Soong.  Keeping
installation in Make has resulted in two host bin directories,
the Make-owned directory (e.g. out/host/linux-x86/bin), and the
Soong-owned directory (e.g. out/soong/host/linux-x86/bin).  The
lack of knowledge in Soong about the final, Make-owned installation
location makes it hard to support NOTICE files entirely in Soong.

This patch begins to solve this problem by supporting the creation of
the installation rules into Soong, but rather than writing the rules
to the ninja file it writes them to a Makefile and lets Kati convert
them to ninja.  This allows Kati to inject extra dependencies to
handle the `required` property.

Converting all modules to create their installation rules in Soong
would be too complex, so only modules that return true from
InstallBypassMake will use the Soong installation rules.  This
is currently only set for robolectric tests.

Bug: 204136549
Test: m checkbuild
Change-Id: I28af9fa7fadece8ea1f98f5efd140c823751cae7
2021-10-29 16:34:55 -07:00
Chih-Hung Hsieh
3bb934f0ad Do not add .tidy files as RBE link inputs
* RBE adds implicit dependent files as inputs
  and creates too long commands.
* Adds .tidy files as validation paths.
* Change type of tidyFiles to WritablePaths.

Bug: 203577539
Test: lunch aosp_cf_arm64_phone-userdebug; USE_RBE=true WITH_TIDY=1 make
Test: USE_RBE=true WITH_TIDY=1 mm in external/skia
Change-Id: I5fc9d6f8c9c58abcd3721ca9fbae1bc785e4e609
2021-10-25 12:24:30 -07:00
Dan Willemsen
9fe1410213 Add android_sdk_repo_host to build platform-tools&build-tools
The Android SDK has been built with Make up until now, monolithically,
then split up into several sdk-repo zip files for different purposes.
The Mac and Windows SDKs really only need to contain the platform-tools
and build-tools pieces, but due to this monolithic sdk zip, we had to
build the whole SDK first.

This adds an `android_sdk_repo_host` module that can build these
platform-tools and build-tools zips.

Bug: 187222815
Change-Id: I55809e1d7447dd65e22461f921b2b8abb6d5f822
2021-10-13 01:25:02 -07:00
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
447f6c99c9 Bp2Build common properties auto-handling
Introduce `commonAttributes` & `fillCommonBp2BuildModuleAttrs used in
CreateBazelTargetModule

Adapt `bp2BuildInfo` to use `commonAttrs` instead of `Name`.
And thus also all downstream users of `CreateBazelTargetModule`.

As initial user, the Soong `required` property will be
translated to Bazel's `data`.

Bug: 198146582, 196091467
Test: build_converstion_test.go:TestCommonBp2BuildModuleAttrs
Test: go test
Test: mixed_{libc,droid}.sh
Change-Id: Ib500e40f7e2cb48c459f1ebe3188962fc41ec124
2021-10-04 14:43:04 +00:00
Paul Duffin
b42fa67a47 Insert imageVariantSpecificInfo between arch and link info
Previously, the archTypeSpecificInfo included an array of
*linkTypeSpecificInfo. This change replaces that array with an array of
*imageVariantSpecificInfo which themselves contain an array of
*linkTypeSpecificInfo.

That allows the sdk snapshot to handle image variants correctly, i.e.
collate their properties, optimize their properties and then detect if
there are any image variant specific properties for any image variant
other than the CoreImageVariant ("") and report it as an error.

The latter case is treated as an error because while Soong needs to
handle image specific variants there is currently no requirement to
handle generating a prebuilt with image specific properties. A follow
up change will test the error handling.

Image specific variants are needed because the "jni_headers"
cc_library_headers module provides a number of image variants (e.g.
recovery) that are used outside the ART module. Therefore, the sdk
snapshot needs to do the same.

At the moment image variants like the recovery variant are supported by
copying the property that creates the variant (e.g. recovery_available)
through to the prebuilt but that is not safe for a couple of reasons:
1. It ignores any differences between the recovery variant and the
   other variants which could cause compatibility issues in modules
   that build against the prebuilts.
2. It marks modules in the snapshot with recovery_available even when
   they do not need it.

This change will allow follow up changes to address both those issues.

Bug: 195754365
Test: m nothing
Change-Id: I1c187d814f44b2cb7607cd43a6b215134be0faad
2021-09-24 17:32:03 +01:00
Chih-Hung Hsieh
b8082295b6 Share cFlags, tidyFlags, etc. in a module
* In builder.go, share common flags in a module.
  * This replaces the sharing of cflags/cppflags/asflags in cc.go.
  * A unit test in apex_test.go now fails and is commented out.
    It is a failing test hidden by old optimization in cc.go.
* In module.go, expand the reference variable $someflags<n>,
  or ${someflags<n>} to keep many existing unit tests work as is.
* The build.ninja size was reduced from 8.1GB to 6.2GB,
  for aosp_arm64-eng WITH_TIDY=1 USE_RBE=true,
  and from 7.5GB to 5.6GB when USE_RBE is 0.
  Content of build.ninja is also more readable and searchable.
  Read/write build.ninja times are also reduced,
  depending on disk I/O speed.

Test: make WITH_TIDY=1
Change-Id: I17f96adf4844136d52e5d40f57a19d9e290162b7
2021-09-15 16:05:41 -07:00
Liz Kammer
6eff323206 Expand handling of unconverted deps in bp2build
Support three options for converting modules with unconverted
dependencies
1. (default) Warn when converting a module if it has unconverted deps.
2. Error when encountering a module with unconverted deps. (not hooked
up yet)

Test: build/bazel/ci/bp2build.sh
Test: build/bazel/ci/mixed_libc.sh
Test: BP2BUILD_ERROR_UNCONVERTED=1 build/bazel/ci/bp2build.sh with
      unconverted deps -- get appropriate error
Bug: 181155349
Change-Id: Ifaabf0cd2e43e963366dc137159c705294165c3d
2021-09-14 19:55:55 +00:00
Treehugger Robot
4011ebb12d Merge "Cleanup unused code for bp2build conversion." 2021-09-09 13:12:04 +00:00
Chih-Hung Hsieh
d0f82fee44 Add tidy-soong, tidy-dir-path, module-tidy targets
* When WITH_TIDY=1, these targets allow quick check of C/C++
  source code with clang-tidy, without building C/C++ binaries.
* For each module with tidy rules, add a module-tidy target, e.g.,
  libart-tidy, libartd-tidy, bionic-benchmarks-tidy, libnativehelper-tidy, etc.
* Add a tidy-soong phony target that depends on all module-tidy targets.
* For each directory X/Y add a tidy-X-Y phony target that depends
  on all *-tidy targets in X/Y and tidy-X-Y-Z for all X/Y/Z directories,
  e.g., tidy-bionic, tidy-bionic-benchmarks, tidy-libnativehelper, etc.
* Only soong modules are collected for now.
  Tidy rules in .mk files will be collected later.
* Some comment lines reformatted by gofmt.

Test: WITH_TIDY=1 make <some_module>-tidy tidy-<some_directory>
Test: WITH_TIDY=1 make tidy-soong
Bug: 199169329
Change-Id: I45aef3875f70288a8e070761e5f083dbbdfa6e94
2021-09-07 14:56:44 -07:00
Liz Kammer
7cbf7738f2 Cleanup unused code for bp2build conversion.
This code to support bp2build-specific modules is no longer necessary as
we do not create bp2build modules after https://r.android.com/1792714

Test: build/bazel/ci/bp2build.sh
Change-Id: I20d3c42f7e3516554cfb537fef05ba40d222dbeb
2021-09-07 13:19:21 -04:00
Liz Kammer
8631cc7327 Update HostAndDevice* documentation
Clarify that HostAndDeviceSupported builds _only_ Device by default,
and add information on how to built host variations.
For HostAndDeviceDefault, clarify how to disable different variants.

Change-Id: I20e30175ddf79038117f1df166d9b994237b27f5
2021-08-23 21:12:08 +00:00
Liz Kammer
2ada09a546 Don't create a new module for bp2build conversion.
A performance improvement for bp2build as Blueprint/Soong no longer have
the overhead of additional modules. The creation of these modules
results in:
* traversal of additional modules for each subsequent mutator
* synchronization over a go channel to collect newly created modules:
https://cs.android.com/android/platform/superproject/+/master:build/blueprint/context.go;l=2594,2600;drc=1602226f23181b8c3fbfcaf3358f0297e839d7d3

We avoid both of these by storing the information directly in the
underlying module.

Also as a fringe benefit, removes some necessary boilerplate for
conversion.

For benchmarks, reduces runtime ~1% for 1% converted, ~24% for 100%
converted. See more: go/benchmarks-for-https:-r.android.com-1792714

Test: ran benchmarks/tests in bp2build
Test: build/bazel/ci/bp2build.sh
Change-Id: Ie9273b8cbab5bc6edac1728067ce184382feb211
2021-08-17 15:57:09 -04:00
Treehugger Robot
1e6760fc71 Merge "Update documentation for VisitDirectDeps" 2021-08-12 23:46:36 +00:00
Spandan Das
da7f362a32 Update documentation for VisitDirectDeps
Calling this function for dependencies that are not android.Module
results in a hard error rather than a soft skip. Update the doc to
reflect this

Bug: 195369546
Test: TH
Change-Id: I18a0938c6536cf20f239cf98c601722aaecd51e6
2021-08-04 20:50:04 +00:00
Jooyung Han
8707cd74bf TransitivePackagingSpecs should follow "installable" deps
Gathering packaging items from "SkipInstall" deps doesn't make sense.

Bug: 194403710
Test: soong test
Test: m microdroid # microdroid shouldn't have libandroidicu
Change-Id: If6c3ee82d588e2742c85cef7244c090c93f38b8e
2021-07-27 19:26:10 +09:00
Chris Parsons
a66c0b5900 Skip unnecessary repeititon in validation
Test: Unit tests
Change-Id: I492d3157b1dee358871924071b26a73e8b83a9a5
2021-07-23 17:23:29 +00:00
Christopher Parsons
2f1102fe58 Merge "Remove bp2build deps mutator" 2021-07-23 14:55:40 +00:00
Colin Cross
b8d69871a8 Merge "Remove Fuchsia support from Soong" 2021-07-23 14:54:49 +00:00
Chris Parsons
5a34ffb350 Remove bp2build deps mutator
Refactor bp2build to retrieve modules directly by name, instead of via
DirectDeps. This functions properly as bp2build has no need for variant
information of the blueprint graph.

Test: USE_BAZEL_ANALYSIS=1 m fmtlib
Change-Id: Ief4b67bc56f24929871af772f3a742f07085bf8c
2021-07-22 18:09:34 -04:00
Colin Cross
cb0ac95bde Remove Fuchsia support from Soong
Bug: 194215932
Test: m checkbuild
Change-Id: Id7d3964d9417f8b0938af9b168bb4c00cebe9390
2021-07-21 20:37:46 -07:00
Kiyoung Kim
ae11c233b5 Update prebuilt_etc available for snapshot
Make prebuilt_etc module available for the snapshot. This change
includes implementing snapshot interface for the prebuilt_etc module so
it can be added to the snapshot from the fake snapshot, or when the
module is specified in the list.

Bug: 192430376
Test: m nothing passed
Test: Checked if the module is included in the snapshot properly
Change-Id: I3574d2a1b8f8f4e5f083f3913e8768f5088d0c46
2021-07-20 11:24:03 +09:00
Paul Duffin
9e3e9c905b Merge "Support fully qualified names in android:"path" properties" 2021-07-15 16:02:34 +00:00
Yi-Yo Chiang
ba9ea32f73 Update comment text of SrcIsModuleWithTag()
The actual behavior of the method is slightly different from its text
right now. Update the text to describe the actual behavior.

Bug: 193228441
Test: m nothing (change is noop)
Change-Id: I755829af6aa1b3f95ac71f33d75751b94e71b54b
2021-07-15 17:18:21 +08:00
Paul Duffin
40131a3f9e Support fully qualified names in android:"path" properties
Previously, a module reference in a path property would be parsed into
two parts, the module name and the optional output tag, which defaults
to an empty string if not specified. The output tag would be stored in
a sourceOrOutputDependencyTag which would then be used, along with the
module name to add a dependency on the module.

Later, when the paths were processed the same module reference would be
parsed into the same two parts again and the module name used to find a
matching Module by comparing it against the name returned by either
Module.Name(), ctx.OtherModuleName() or ModuleBase.BaseModuleName().
Once the module had been found then if it supported OutputFilesProducer
then the tag would be passed to its OutputFiles(tag) method. Otherwise,
it would fall back to treating it as SourceFilesProducer.

The problem with that is the module name retrieved from the module in
some way (either directly or through a context name) could be different
to that originally supplied when adding the dependency. e.g.
1. If the original dependency was added onto a source module but there
   existed a suitable and preferred prebuilt module then the dependency
   onto the source module would have been replaced by the prebuilt
   module which has a different name.
2. If the path property included a fully qualified name that included
   a qualifying path then it would not match the name retrieved from
   the module which would not include the qualifying path.

This change circumvents that whole issue by adding the module name that
was originally used to add the dependency into the DependencyTag. Now
the DependencyTag uniquely identifies the original module/outputTag
pair parsed from the module reference. The pathDepsMutator guarantees
that they are unique as it dedups them before adding the dependencies.

It is possible that calling ExtractSource(s)Deps() would add some
duplicate but if they did they would be identical, i.e. the same
sourceOrOutputDependencyTag would be used to add a dependency onto the
exact same module. In that case it would not matter which of the
dependencies was found as it would still return the same module.

Bug: 193228441
Test: m nothing
Change-Id: I661514a2984818e5c26577411cede53eb57bcd02
2021-07-14 23:58:49 +01:00
Paul Duffin
73c7755ac9 Merge "Use bazel syntax for fully qualified name in path property" 2021-07-13 13:31:04 +00:00
Treehugger Robot
b9386b703e Merge "Share EffectiveLicenseFiles for snapshot modules" 2021-07-12 22:06:59 +00:00
Paul Duffin
e6ba0723b1 Use bazel syntax for fully qualified name in path property
A module reference to a fully qualified module in a path property looks
like:
  //path:module
And with a tag:
  //path:module{tag}

At the moment the checking is quite lax but some follow up changes will
make it much stricter.

Bug: 193228441
Test: m nothing
Change-Id: Ie42edcfa33ec66fda5d75b3df1da73f56f147afd
2021-07-12 20:15:06 +01:00
Paul Duffin
d5cf92e298 Support customizing behavior around sourceOrOutputDependencyTag
Previously, modules customized behavior around the handling of
sourceOrOutputDependencyTag by comparing them to android.SourceDepTag
and retrieving the module using something like this:
    ctx.GetDirectDepWithTag(m, android.SourceDepTag)

The problem with that is it does not allow an output tag to be
specified and does not handle fully qualified names properly.

This adds the following:
* IsSourceDepTag and IsSourceDepTagWithOutputTag to check whether a
  blueprint.DependencyTag is a sourceOrOutputDependencyTag. The latter
  also checks that it has the correct output tag.
* GetModuleFromPathDep(ctx, moduleName, outputTag) as a replacement for
  ctx.GetDirectDepWithTag(m, android.SourceDepTag).

Replaces usages of:
* t == SourceDepTag with IsSourceDepTagWithOutputTag(t, "")
* ctx.GetDirectDepWithTag(m, android.SourceDepTag) with
  GetModuleFromPathDep(ctx, m, "")

It also deprecates the following:
* android.SourcDepTag - as a follow up change needs to modify the
  sourceOrOutputDependencyTag will make this useless.
* ExpandSources, ExpandsSources - copies existing deprecated messages
  from the implementation to the interface so that they can be seen
  by users of that interface.

Bug: 193228441
Test: m nothing
Change-Id: I8c397232b8d7dc1f9702c04ad45ea7819d4631ae
2021-07-09 23:54:01 +01:00
Justin Yun
885a7dea68 Share EffectiveLicenseFiles for snapshot modules
License files must be captured with the snapshot modules. NoticeFiles
does not have the information provided by the `license` module.
Reading the `Effective_license_text`, snapshot includes the required
license files.

Bug: 190690041
Test: build
      check the NOTICE files built from snapshots
Change-Id: I96c4579b4bef484cbb39fc06c707742a02a2b90b
2021-07-08 00:02:48 +00:00
Lukacs T. Berki
d18d8cab73 Dump extra JSON data for C++ modules and ApexInfo.
Test: Presubmits.
Change-Id: I96cf67c6f1338aed9d2ab5834a14b8a40a9e5b45
2021-06-25 11:15:40 +02:00
Martin Stjernholm
408ffd8cca Plumb through OtherModuleFarDependencyVariantExists from blueprint.
Test: m nothing
Bug: 188398129
Change-Id: I64147293b6c51b437219e76e9e372fe56b977722
2021-05-20 16:43:04 +00:00
Martin Stjernholm
0e4ccebb16 Don't fail if the target module is disabled in dex2oat tool
dependencies.

dexpreopt.RegisterToolDeps runs late after prebuilt dependencies have
been resolved, and there's special code in dex2oatPathFromDep to
resolve the prebuilt from the source module. However, if the source
module is disabled then the dependencies check in validateAndroidModule
will complain, so we need to disable that check in this particular
situation.

Also add a comment to explain why dexpreopt.RegisterToolDeps needs to
run so late.

Test: m nothing
Bug: 145934348
Bug: 172480615
Change-Id: Ibc673303d0336768fa23261a2068e91a08f46a30
2021-05-18 21:58:38 +01:00
Treehugger Robot
015a0afe07 Merge changes I2729001d,Ife5d2193
* changes:
  packaging: install/package deps if not marked IsHideFromMake
  Generate linker config with packaged items.
2021-05-12 22:08:54 +00:00
Jooyung Han
77f7c44246 packaging: install/package deps if not marked IsHideFromMake
TransitivePackagingSpecs() gathers transitive "install/package"
dependencies.

Previously, IsInstallDepNeeded(depTag) was checked. But, in this way,
some stub libraries which are marked as "HideFromMake()" to avoid
install/package can be gathered.

For example, libdexfile is not installed even if it is one of
libdexfile_support's runtime_libs because it is a stub library and the
impl is provided by "art" apex.

So when gathering transitive deps "IsHideFromMake()" is checked and if
the dep is hidden (so, not supposed to be installed) then the dep
(and its deps) is ignored.

Bug: 187686926
Test: m nothing
Test: m microdroid (libdexfile shouldn't be included in system/lib)
Test: m hosttar (no changes)
Change-Id: I2729001d4c64985cf0f2b37440c2082fe912e6c5
2021-05-11 19:03:25 +00:00
Paul Duffin
ec0836af3a Switch Effective_license_text from []string to Paths
Effective_license_text contains paths to files that are copied from
one module to another and so need to be converted to Paths within the
context of the owning module as the paths are relative to the owning
module's directory.

The previous code did convert the license_text property to paths but
converted it back to strings again which was confusing and does not
follow the normal pattern.

Bug: 181569894
Test: m nothing
Change-Id: Iea09ee7f3de1187a2c3e41455ca83b0233d904b2
2021-05-11 08:24:59 +01:00
Inseob Kim
08758f08e9 Add debug ramdisk variant.
A module will be installed to /debug_ramdisk if debug_ramdisk is set to
true.

This is a reland of f84e9c05e2, with a fix
that removes /first_stage_ramdisk.

Bug: 184004542
Test: soong test
Change-Id: I739de63cfec6b0fec5a90f7c4741fc4d884d209c
2021-04-29 22:58:17 +09:00
Liz Kammer
2b50ce669c Make GetDirectDep implementation match comment
The comment on the interface of GetDirectDep states if there are
multiple deps with different tags, the first will be returned; however,
the current behavior is to panic if there are multiple deps. The
behavior now:
* a single dep, return the module and tag
* a single module with different tags: return module with first tag
* multiple modules: panic
* no module: return nil, nil

Bug: 186488405
Test: ~/aosp/build/bazel/ci/bp2build.sh
Test: m nothing
Change-Id: Id1e7315e7874b4a683ad7357ed2793822315821f
2021-04-27 15:53:51 -04:00
Inseob Kim
aeb6bad073 Revert^3 "Add debug ramdisk variant"
836a8f3d61

Change-Id: If59529238e26a197bc33b10245b88f538f280ed0
2021-04-22 23:14:58 +00:00
Florian Mayer
836a8f3d61 Revert^2 "Add debug ramdisk variant"
78ea2f5eac

Change-Id: I6a6a2ee82e2807045364bab105ec03a1934b411f
2021-04-22 16:38:47 +00:00
Bowgo Tsai
78ea2f5eac Revert "Add debug ramdisk variant"
This reverts commit f84e9c05e2.

Because this breaks the usage of boot-debug.img and
vendor_boot-debug.img

Bug: 185970130
Bug: 185990198
Test: make bootimage_debug
Change-Id: I7886c971982faae1d5bc34688643de8d94d6e201
2021-04-22 09:49:24 +08:00
Inseob Kim
f84e9c05e2 Add debug ramdisk variant
A module will be installed to debug_ramdisk (or
debug_ramdisk/first_stage_ramdisk if recovery as boot is true) if
debug_ramdisk is set to true.

Bug: 184004542
Test: soong test
Change-Id: Ic5a4d27407e506fffa462de2149e0785f11b2ac7
2021-04-15 00:56:30 +00:00