Commit graph

214 commits

Author SHA1 Message Date
Cole Faust
68305164c3 Merge "Revert^2 "Make embedded_launcher true by default"" into main 2024-04-22 17:40:11 +00:00
Cole Faust
f09101e78d Revert^2 "Make embedded_launcher true by default"
This reverts commit 578066be90.

Reason for revert: Relanding

Change-Id: I63f01362cc11c02c4800ae1c21652c7cf4b8a799
2024-04-18 18:33:15 +00:00
Ronald Braunstein
c4cd7a11a1 Implement test-only for python_ rules
Similar to: aosp/3040036 and aosp/3035329, implements a test-only
property for python_library and sets it for python_host.

This combined with aosp/3045317 produces:
	gqui from  "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto ~/aosp-main-with-phones/build/soong/android/team_proto/team.proto:AllTeams 'select teams.kind, count(*) total, sum(teams.test_only) as test_only, sum(teams.top_level_target) as top_level, where teams.kind like "%py%"  group by teams.kind'
	+-----------------------------+-------+-----------+-----------+
	|         teams.kind          | total | test_only | top_level |
	+-----------------------------+-------+-----------+-----------+
	| cpython3_cc_defaults        |     1 |         0 |         0 |
	| cpython3_cc_prebuilt_binary |     4 |         0 |         0 |
	| python_binary_host          |   222 |         0 |         0 |
	| python_defaults             |    27 |         0 |         0 |
	| python_library              |    38 |         0 |         0 |
	| python_library_host         |   131 |         0 |         0 |
	| python_test                 |     5 |         5 |         5 |
	| python_test_host            |   172 |       172 |       172 |
	+-----------------------------+-------+-----------+-----------+

Change-Id: Iea14fcdbfd782d37ac0a3c780820deeed5f1923d
Test: m blueprint_tests
Test: go test ./python
2024-04-16 17:09:43 -07:00
Charlie Boutier
291a4912d1 Merge "Revert "Make embedded_launcher true by default"" into main 2024-04-11 17:21:35 +00:00
Charlie Boutier
578066be90 Revert "Make embedded_launcher true by default"
This reverts commit 8a038ed871.

Reason for revert: investigate breaking test suits Avatar and BumbleBluetoothTests

Change-Id: I8e4498fb5854bf62df6d161ac0c6cce49d471afe
2024-04-11 16:10:00 +00:00
Cole Faust
e35973bcef Merge "Make embedded_launcher true by default" into main 2024-04-10 22:56:19 +00:00
Treehugger Robot
4fcfd0123c Merge "Improve errors when compiling python code" into main 2024-03-29 02:50:30 +00:00
Cole Faust
5a8f533a29 Improve errors when compiling python code
Now a stacktrace involving precompile_python.py won't be shown,
and it will show all errors instead of just the first one.

Bug: 331488610
Test: Presubmits
Change-Id: I47376ca6764c0f84d1aaf5db329664e20143640a
2024-03-28 17:31:21 -07:00
Haamed Gheibi
54af8e62d9 Remove the mkdir of the parent Directories for protobufs.
Bug: 330794730
Change-Id: I7b221ffc9dde67c27186848727c4a698644507aa
2024-03-28 18:19:18 +00:00
Cole Faust
8a038ed871 Make embedded_launcher true by default
embedded_launcher causes the python interpreter to be bundled in the
built zip file. This is beneficial because:

- You can export the built executable and run it on systems
  without python or an old version of python. The CI servers have python
  3.7, so it's useful to update that.
- Because the python version is known, the python sources will be
  precompiled.
- It will start running the code directly from the zip file, without
  extracting the binary to a temporary directory like non-embedded
  launcher binaries. This is particuarly useful because some developers
  use the extracted files directly instead of using
  `importlib.resources`, so having the non-extracting implementation
  gives them a nudge in the right direction.

Make embedded_launcher the default so that more developers will do the
right thing when developing python programs.

Bug: 331488610
Test: Presubmits
Change-Id: Ideb113a1d4d3b29ac04d57a48d111a99f77b2dfc
2024-03-26 17:32:48 -07:00
Anas Sulaiman
55a829d74c Merge "Fix non-deterministic python compilation" into main 2024-02-08 14:50:26 +00:00
Anas Sulaiman
c755fdbe8e Fix non-deterministic python compilation
This CL fixes timestamps for zip entries to a hardcoded value to ensure
deterministic zip archives across checkouts, not just for incremental builds.
The value chosen for the fixed date is the same as the one used by soong_zip.

Bug: b/322788229
Test: Ran a few builds and verified that mdate for zipped files are
fixed as well as the generated zip files have identical hashes.

Change-Id: I3cd6fcf559d4d83d8813c93319b46e267ae64a2b
2024-02-07 21:57:41 +00:00
Ziwei Zhang
617b3e288a Merge "Generate ATS 2.0 config for Mobly test." into main 2024-02-07 07:38:39 +00:00
Ziwei Zhang
3dfec5a2c6 Generate ATS 2.0 config for Mobly test.
- Support test_config and test_config_template
- The `config` file extension is widly used by TF. Use `configv2` for
  ATS 2.0 tests to avoid configuration errors in TF.
- Add `mobly` tag to support atest

Test: m CtsBluetoothMultiDevicesTestCases (with `runner = "mobly"`)
Bug: 299850687
Change-Id: Idbed90ab30e35aeed8cdeeb0aa0aa7adb75a3cd9
2024-02-07 10:29:29 +08:00
Anas Sulaiman
55b7ba0645 Fix non-deterministic python compilation
Timestamps in pyc files and zip archives were causing cache misses in RBE.

Bug: b/322788229
Test: Ran a few local builds and verified improved cache hit rate for metalava actions.
Change-Id: I9375694d26a107f5c0c43bbd685bd8e86349d187
2024-02-01 19:41:31 +00:00
LaMont Jones
afe7baf47d Propagate aconfig providers for more modules.
Bug: 308625757
Test: manual
Change-Id: Iaf6d45a4259f1c6c34476c34c431344283ae2830
2024-01-10 14:03:30 +00:00
Colin Cross
402130276c Convert SetProvider to generic providers API
Convert all of the callers of SetProvider to use the type-safe
android.SetProvider API.

Bug: 316410648
Test: builds
Change-Id: If58f4b5355264ddab2045bc3591a4eac19cd58fc
2023-12-14 16:12:20 -08:00
Colin Cross
8ff105860d Remove ConvertWithBp2build implementations
Remove the ConvertWithBp2build implementations from all the module
types, along with the related code.

Bug: 315353489
Test: m blueprint_tests
Change-Id: I212672286686a318893bc7348ddd5a5ec51e77a7
2023-12-08 13:51:05 -08:00
Aditya Choudhary
26df39fe44 Add source file provider for genrule/srcs, python libraries and rust libraries.
Change-Id: I2d7d4684a10c15aeecc27b8db800ab27a807d2e2
2023-12-05 19:56:26 +00:00
Colin Cross
5c1d5fb21b Move test data installation to Soong
To generate module-info.json in Soong for b/309006256 Soong needs to
know the test data paths. Moving test data installation into Soong will
also help later for test suite packaging.

Add ModuleContext.InstallTestData that installs the files listed in a
[]DataPath alongside the test.  The files will also be passed to Make
to allow it to continue packaging them into the test suites for now.

Update the module types that are producing LOCAL_TEST_DATA entries
in their Android.mk files to go through InstallTestData instead.

Bug: 311428265
Test: atest --host toybox-gtests --test-timeout=120000
Change-Id: Ia8b964f86e584ea464667fd86a48d754d118bead
2023-11-30 13:38:49 -08:00
Aditya Choudhary
9b59352a82 Add proto for Test ownership metadata.
This Cl adds a new rule to Soong to generate test spec metadata. Also, this CL adds a provider in various test module to provide test spec related data to the Soong rule.
Will add providers and test code to other Module in the future changes.
Provider added for the following test modules in this change: android_robolectric_test, android_test, bootclasspath_fragment_test, java_test, java_test_host, python_test, python_test_host, sh_test,and sh_test_host.

Bug: 296873595

Change-Id: I5f89f72d5874bb7838ae357efdb8c6ca208e18a7
2023-11-15 09:08:02 +00:00
Chris Parsons
637458d326 Have ConvertWBp2build use Bp2buildMutatorContext
This no-op refactoring facilitates some upcoming functional changes for
"bp2build allowlist v2". The work requires that the bp2build conversion
mutator be changed from a TopDown mutator to a BottomUp mutator.
Refactoring all bp2build-related methods so that they use Bp2buildMutatorContext
makes it easier to make this functional change without touching tens of
files and multiple projects.

Bug: 285631638
Test: m bp2build
Change-Id: I3d1ef3064146e959c6f0dc315350fc9764bf2bd2
2023-09-20 14:49:35 +00:00
Dan Willemsen
1e218403e0 Merge "Revert "Temporarily disable python precompilation for py3.11"" into main 2023-08-31 15:38:39 +00:00
Treehugger Robot
7eb6ffc796 Merge changes from topic "java-proto-include-dir" into main
* changes:
  Handle proto.include_dirs for java
  Translate python_libray.pkg_path to proto.import_prefix
2023-08-28 17:18:29 +00:00
Dan Willemsen
fe2dafc36b Revert "Temporarily disable python precompilation for py3.11"
This reverts commit b1094d602b.

Reason for revert: prebuilts updated in aosp/2726579

Bug: 278602456
Change-Id: I750b0f7e4dd94329a4455499f869a1823e660d77
2023-08-24 22:59:16 +00:00
Spandan Das
234bb3bd8d Merge changes from topic "proto-include-dir-py" into main
* changes:
  Handle proto.include_dirs in bp2build for py
  Add proto.local_include_dirs support in bp2build
  Add manual tag to proto_library at the root package
2023-08-24 20:57:47 +00:00
Spandan Das
4ed3d120c9 Handle proto.include_dirs in bp2build for py
Followup to aosp/2711114 which added proto.include_dirs support for cc

Test: go test ./bp2build
Test: Added an integration test in build/bazel/examples
Bug: 285140726
Change-Id: Ic78dacbe46d9ea67e9441948852a3f94dabbb35e
2023-08-24 19:21:10 +00:00
Spandan Das
cb847638af Translate python_libray.pkg_path to proto.import_prefix
If a python_library uses a pkg_path foo/bar, then the proto srcs in
that libray need to import the dep .proto as foo/bar/proto.proto.

This behavior is restricted to python modules. To implement this is in
bp2build, this CL creates a new interface with a single method
`PkgPath`. Only python module structs implement this interface, and
this method is only available during bp2build

Test: Added a bp2build unit test
Test: TH

Change-Id: If8d207c0b321f75337a053795826b283a5eaaf46
2023-08-24 19:21:10 +00:00
James Farrell
c36312a64d Merge "Temporarily disable python precompilation for py3.11" into main 2023-08-24 14:13:10 +00:00
Dan Willemsen
b1094d602b Temporarily disable python precompilation for py3.11
The precompilation logic assumes that the source tree matches the python
prebuilts, which is not necessarily true. This very much breaks during
major version upgrades, so just disable precompilation temporarily while
we generate new prebuilts.

Bug: 278602456
Test: treehugger
Change-Id: Idb206bb1d971e8c0fa556c75419623c3bc457898
2023-08-22 19:09:44 -04:00
Dan Willemsen
b2d1cf93c7 Skip py2-cmd tests on Mac
Mac no longer builds python2

Test: prebuilt/build-tools/build-prebuilts.sh on Mac
Change-Id: I5857ba7ec023021e660e86df3573e4b6e3d1902b
2023-08-22 18:41:25 -04:00
Dan Willemsen
9f9f77dfc2 Merge "Prepare soong for python 3.11" into main 2023-08-17 19:14:46 +00:00
Dan Willemsen
339a63f044 Prepare soong for python 3.11
Due to upstream changes in python path calculations, I'm simplifying the
python launcher to work more like a standard python distribution. This
is effectively changing the stdlib path from `internal/stdlib` to
`internal/python3.10` (or `3.11`, etc). This allows us to specify the
zip file as PYTHONHOME, set PYTHONPLATLIBDIR to `internal` and use the
default detection after that.

That does mean during upgrades that the stdlib pkg path will change, so
move the source vs prebuilt calculation from the Android.bp into Soong
to choose which stdlib module to pick up (with the corresponding
`pkg_path`)

Bug: 278602456
Test: treehugger with python3.10
Test: a python3.11 source + 3.10 prebuilt build
Test: a python3.11 source+prebuilt build
Change-Id: I8b02e7b22a1f1d1e02819ae1a31a99cdc985542c
2023-08-16 21:47:03 -04:00
Trevor Radcliffe
d3243d5e74 Use relative path instead of base for python proto
We encountered a duplicate sources bug in python proto generation
because we're only using the base name. This CL makes it use the
entire path to avoid this.

Fixes: 295333879
Test: Presubmits
Change-Id: I4ab821508cd5979bd595e327c1ccd3d68110fba6
2023-08-15 18:33:00 +00:00
Spandan Das
09f6b1390c Merge changes I8ca452aa,I437fc890,If9446700 into main
* changes:
  Handle .proto files in different package for filegroups
  Handle .proto files that end up in a different package
  Allow creation of BazelTargets in a different directory
2023-08-08 00:51:52 +00:00
Spandan Das
c53767e434 Handle .proto files that end up in a different package
Bazel poses a strict requirement that .proto files and proto_library
must be in the same package. This CL handles this automatically by
creating the proto_library in a separate dir/package if necessary

Implementation details
- Partition the `srcs` by package. `srcs` has been computed using
  `transformSubpackagePath`, so the information about packages is
  available at this point
- Create a proto_library in each package by using
  `CommonAttributes.Dir`. Collect all these additional libraries
  and put them in `info.Proto_libraries` so that they get added as deps
  of (cc|python|...)_proto_library
- Add an import_prefix to the proto_library in subpackages relative to
  the current directory. This relies on the assumption that every src is
  beneath the current directory (Soong will complain if a path in
  Android.bp contains ../)

filegroup module type uses a separate code-path to create proto_library.
This will be handled in the next CL in stack.

Test: bp2build unit tests
Test: TH
Test: Built the failing internal module mentioned in
b/292583584#comment1

Bug: 292583584

Change-Id: I437fc89092321b26c5f0511387cde9e84084d6f9
2023-08-07 19:18:03 +00:00
yike
1aaeea39da Convert merge_annotation_zips_test to b test
Test: b test //frameworks/base/api:merge_annotation_zips_test
Bug: 293225210
Change-Id: Ia53b4168894b5c70c843ca315d963fa905ef582f
2023-08-01 18:57:59 +00:00
Zi Wang
bbb1b74cbf Add data_device_bins_both properties for python_test_host
Test: presubmits and manual verification

Bug: 274930471
Change-Id: Iafc85526afdb8264526e8a5a33319fa33a23c66b
2023-05-19 10:32:49 -07:00
Colin Cross
e8c70c5bd5 Enable host cross python test builds
Ic37c8db918873ddf324c86b12b5412952b0f2be2 converted python_binary_host
and python_library_host from HostSupportedNoCross to HostSupported,
but left python_test_host.  Do the same for python_test_host.

Fixes dependencies between java_test_host modules that create
host cross variants and python_test_host modules that were missing
host cross variants.

Bug: 282918027
Test: builds
Change-Id: Iae687aa3aa0f0b005f2dd27469f631145247a008
2023-05-18 11:51:56 -07:00
Krzysztof Kosiński
ebb25bd22e Delete Python 2 embedded launcher test.
There are no remaining Python 2 binaries using an embedded
launcher in Android.

Bug: 245854393
Test: m par_test py2-cmd py3-cmd && build/soong/python/tests/runtest.sh
Change-Id: I241bbaa417060b51b4d2883011ccb43e22ace4c8
2023-05-04 17:52:12 +00:00
Cole Faust
d82f036b89 bp2build support for python_test(_host)
There was a request for using b with python tests. bp2build python
tests exactly the same way as python binaries so that they can be
used with `b`.

Bug: None
Test: go test
Change-Id: Id68a6a73572745a4885b3e5bb1b8452e36baa982
2023-04-13 16:10:59 -07:00
Qiao Yang
2a3a42683c stub_template_host redirect SIGINT and SIGTERM to subprocess
Test: manual
Change-Id: I561f581f7413dc18b2d449f4ef338db3b6b9ca47
2023-03-22 00:17:24 +00:00
Ziwei Zhang
e75fcf4ddb Merge "Add python template for mobly tests." 2023-03-20 02:16:04 +00:00
Cole Faust
edc4c505f9 Make using python 2 an error
Except if BUILD_BROKEN_USES_SOONG_PYTHON2_MODULES is set, and except for
some core py2 modules that can't be removed until python2 is fully gone.

Bug: 203436762
Test: m nothing
Change-Id: I62ccb6f5687eab1e79c372ffc234a90ca5b566ac
2023-03-09 11:56:04 -08:00
Ziwei Zhang
c3bb83a57b Add python template for mobly tests.
Mobly is a Python-based test framework that specializes in supporting
test cases that require multiple devices. There are some Mobly based
Android tests, but these tests cannot be added to xTS since they are
not using TF. Currently TF provides a 2-device Mobly test runner.
This change is a short-term solution to help teams (eg. bluetooth) to
add their multi-device Mobly tests to xTS without writing TF configs.
For long-term, device infra team and xTS infra team will provide a
solution for more complex multi-device tests in xTS and deprecate this
TF template.

Test: manually check the generated mobly xml config
Bug: 272239365
Change-Id: I252cc774094eebbd9264243d30023ace4839c2cd
2023-03-08 21:37:58 +08:00
Cole Faust
18994c73f1 Replace SortedStringKeys with SortedKeys
Now that we have generics.

Bug: 193460475
Test: presubmits
Change-Id: I1594fd8feb505175d5c09c03ef397e5ffd5b09cb
2023-02-28 16:51:32 -08:00
Cole Faust
909d237c84 Revert "Dynamically assemble the list of python launcher shared libs for precompiling"
This reverts commit aa5b377ee9.

Reason for revert: this broke musl builds by removing the install dependency from python binaries to the launcher shared libraries: https://android-build.googleplex.com/builds/submitted/9600042/unit_tests_x86_64_musl/latest/view/logs/build_error.log

Change-Id: I4e13f333f287831ba13724f13ab2be789a92b476
2023-02-13 23:17:40 +00:00
Cole Faust
aa5b377ee9 Dynamically assemble the list of python launcher shared libs for precompiling
Still fall back to the hardcoded list for what to put in LOCAL_SHARED_LIBRARIES,
because I couldn't figure out a good way to get those modules at the moment.

Bug: 259718110
Test: Presubmits
Change-Id: Ia992ffea8819d8c67280b08bc45505f77af09de0
2023-02-02 13:47:56 -08:00
Cole Faust
5c503d1c43 Precompile python sources
This signifigantly improves the startup time of soong-built
python binaries. For example, running
`m apexer && time out/host/linux-x86/bin/apexer` gives
0.734s before this cl, and 0.094s after.

Fixes: 259718110
Test: Presubmits
Change-Id: Ib19e83e2c60c39a849525be117279c318de3afa7
2023-01-27 15:43:38 -08:00
Cole Faust
4d247e6f21 Refactor python rules
The goal of this cl is to simplify the python rules,
mostly by removing the "decorator" pattern that they
currently use, and instead making separate module
types for libraries, binaries, and tests that inherit
from each other.

Bug: 259718110
Test: Verified ninja files are unchanged (they only change in the list of soong sources because I added/deleted files)
Change-Id: I1e836e2cc4782c7818f91db7df7895de3b8db7ca
2023-01-25 10:40:59 -08:00