summaryrefslogtreecommitdiff
path: root/python/binary.go
AgeCommit message (Collapse)Author
2025-03-13Merge "Add Shared libraries support for Android python libraries" into main Treehugger Robot
2025-03-12Add Shared libraries support for Android python libraries Brett Brotherton
- New shared_libs property to Python code for specify shared libs that should be packed into the library for modules with compiled code. - Expand shared_lib dependencies when building the python library. - Change python main entrypoint to extract the zip if there are any shared libraries in the executable to workaround linker limitations Bug: 395678202 Change-Id: Id94caebf36f7eb1cfa492b2fa78f8c56623e9a43 Test: m py-grpcio
2025-03-11Expand TestSuiteInfoProvider to all test modules Cole Faust
Test suites have been historically only defined in the AndroidMk functions. But in soong-only builds, we don't run AndroidMk. It appears Colin already started making a TestSuiteInfo provider, but hadn't set it on all test modules yet. Expand it to all the test modules, and add export it to make so that make can check that it matches LOCAL_COMPATIBILITY_SUITES. Bug: 388850000 Test: m nothing Change-Id: Iee8959742117604fd560c95be60f3cb7cf3d9ae4
2025-02-19Convert python_binary_host modules' module-info.json to Soong Bill Yang
Bug: 397158845 Test: m out/target/product/vsoc_x86_64/module-info.json Test: Inspect module-info.json diff, CI Change-Id: I542e9b3d02e989602800199899ba516bad4f94fe
2025-01-31Remove python2 support from soong rules Cole Faust
Python2 has been removed from the android build. Removing the python version transition mutator should lead to some slight analysis time performance improvements. I also made embedded_launcher in base_properties no longer blueprint:"mutated", so that we can migrate usages to the main property struct and remove the `version` property struct. Many python tests were not being run due to a `if d.desc != "module with duplicate runfile path" { continue }` line, I removed that and fixed the tests. I also removed the test for an error when there are no source files, because that check has been relaxed since, and I think it's legitimate to have a python library that only has data files, not source files. And there are some of those libraries in the source tree. Bug: 203436762 Test: m nothing --no-skip-soong-tests Change-Id: Idf18e39233418237ecc83f70f65d83d4ea496633
2025-01-21Convert python modules to use ModuleProxy. Yu Liu
Bug: 377723687 Test: Unit tests and compare the ninja and mk files generated. Change-Id: Ide5bdf2bc1bf41efaf694a66769df907888e51cb
2024-06-18Use OutputFilesProvider on python_binary_host mrziwang
In the context of incremental soong, the output files inter-module-communication will be through OutputFilesProvider. The OutputFileProducer interface will be deprecated. Test: CI Bug: 339477385 Change-Id: I20f619d088503ca482ea55e81639933c88f1286b
2024-05-10Remove duplicated CollectDependencyAconfigFiles() Justin Yun
android.ModuleBase already calls aconfigUpdateAndroidBuildActions() that is the same with CollectDependencyAconfigFiles(). Remove the CollectDependencyAconfigFiles() to avoid duplication with aconfigUpdateAndroidBuildActions(). To make the aconfig information available in GenerateAndroidBuildActions() of all modules, call aconfigUpdateAndroidBuildActions() before calling GenerateAndroidBuildActions() of each module. Also, we don't need SetAconfigFileMkEntries(), which is a duplicate of aconfigUpdateAndroidMkData() Bug: 335363964 Test: diff `adb shell printflags` before and after the change. Change-Id: I52808e442e9fed7db1eae7b7c5ed0b1c5ba74f5d
2024-04-18Revert^2 "Make embedded_launcher true by default" Cole Faust
This reverts commit 578066be90d3e1960c02b5c80c29e92bca70a70b. Reason for revert: Relanding Change-Id: I63f01362cc11c02c4800ae1c21652c7cf4b8a799
2024-04-11Revert "Make embedded_launcher true by default" Charlie Boutier
This reverts commit 8a038ed871230ba6280642b5c0e83a37d076aa79. Reason for revert: investigate breaking test suits Avatar and BumbleBluetoothTests Change-Id: I8e4498fb5854bf62df6d161ac0c6cce49d471afe
2024-03-26Make embedded_launcher true by default Cole Faust
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-01-10Propagate aconfig providers for more modules. LaMont Jones
Bug: 308625757 Test: manual Change-Id: Iaf6d45a4259f1c6c34476c34c431344283ae2830
2023-12-08Remove ConvertWithBp2build implementations Colin Cross
Remove the ConvertWithBp2build implementations from all the module types, along with the related code. Bug: 315353489 Test: m blueprint_tests Change-Id: I212672286686a318893bc7348ddd5a5ec51e77a7
2023-04-13bp2build support for python_test(_host) Cole Faust
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-02-13Revert "Dynamically assemble the list of python launcher shared libs for ↵ Cole Faust
precompiling" This reverts commit aa5b377ee956f2e7ff2e0fb6630f636ecfe15b84. 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-02Dynamically assemble the list of python launcher shared libs for precompiling Cole Faust
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-01-27Precompile python sources Cole Faust
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-25Refactor python rules Cole Faust
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
2022-10-21Remove flags that enable the new python path behavior Cole Faust
The new behavior has been enabled by default, and these flags aren't necessary anymore. Fixes: 245583294 Test: m py_dont_import_folder_of_entrypoint_test && /ssd/aosp-master/out/host/linux-x86/testcases/py_dont_import_folder_of_entrypoint_test/x86_64/py_dont_import_folder_of_entrypoint_test Change-Id: I5b6f98da51791bc5d28662ef799a10c1bb6a35a0
2022-10-13Merge "Fix some issues in bp2build converter for python_binary_host." Wei Li
2022-10-12Fix some issues in bp2build converter for python_binary_host. Wei Li
1) Bp2build convert python_binary_host main attribute as LabelAttribute. Currently "main" attribute in python_binary_host is handled as string but for some modules (e.g certify_bootimg) the "main" attribute points to a file in its subpackage like "subpackage/file.py" and should be converted to "//.../subpackage:file.py". 2) Filter out duplicated labels in the merged list of "required" attributes of python_binary_host and its defaults. Test: b build //system/tools/mkbootimg:certify_bootimg Test: b build //build/make/tools/releasetools:check_target_files_signatures Bug: 253081249 Bug: 253101186 Change-Id: Ic2cb4cadec2c1348da70af9f0730da9914d3a8ca
2022-10-11Revert^2 "Enable new python path behavior by default" Cole Faust
This reverts commit 4d5cc709fa16f5dc78f690369e946fcf66156312. Reason for revert: Acloud issue was fixed in aosp/2243150, make sure the host unit tests are run on this cl via go/abtd before submitting Change-Id: Ie148430d331a01a9877adaf3cb88f1c57af136a0 Bug: 245583294 Bug: 247578564 Bug: 251688241
2022-10-07Revert "Enable new python path behavior by default" Lais Andrade
This reverts commit 5fe655d1c71ee079dd46e93c96b54aae39a10d16. Reason for revert: DroidMonitor: Potential culprit for Bug b/251688241 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted. Change-Id: I1ea4df27557fc891d8f0156ec5681f9b0c601c98
2022-10-05Enable new python path behavior by default Cole Faust
Now that usages have been updated, enable the new behavior by default. If everything goes well with this, we can then remove the flags. Bug: 245583294 Bug: 247578564 Test: Presubmits Change-Id: Idac8d2dc0f96ae750dba4a99b32525676d0d6f25
2022-09-26Add flag to not add directory of entrypoint to sys.path Cole Faust
The python interpreter will by default add the directory of the entrypoint script to the beginning of sys.path. This can be disabled in python 3.11+ (which is not released yet) using the PYTHON_SAFE_PATH environment variable or the -P flag. As a workaround to have this behavior in older python versions, we can make an __soong_entrypoint_redirector__.py file at the root of the zip file that is the entrypoint, and then that file will redirect to the real entrypoint. This brings non-embedded-launcher python modules closer to the embedded launcher version. The embedded launcher binaries already act like this because they start at an __main__.py file at the root of the zip file. Bug: 245583294 Test: m py_dont_import_folder_of_entrypoint_test && out/host/linux-x86/nativetest64/py_dont_import_folder_of_entrypoint_test/py_dont_import_folder_of_entrypoint_test Change-Id: I39aaf04fb19c3ba7f5c9d98220872d6d08abf736
2022-09-23Add flag to not add top-level modules to PYTHONPATH Cole Faust
stub_template_host.txt added all the top-level modules to the PYTHONPATH, which isn't correct, and caused absl.logging to override the built-in logging module. Removing this also makes it more consistent with python binaries built with embedded_launcher: true. embedded_launcher: true binaries don't add the top-level modules. Fixes: 245583294 Test: m py_dont_add_top_level_dirs_test && out/host/linux-x86/testcases/py_dont_add_top_level_dirs_test/x86_64/py_dont_add_top_level_dirs_test Change-Id: Id3069565d2b2c4b2bda0ff5301e757a7b4201751
2022-06-09Allowlist apexer for bp2build Cole Faust
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
2021-12-14Use one mutator for all bp2build conversion. Liz Kammer
Each conversion required defining a separate mutator, which will each operate on _all_ modules and requires each to repeat checks whether the mutator should operator. Instead, we introduce a single mutator and modules can define a ConvertWithBp2build to implement bp2build conversion for that module. Test: bp2build.sh Bug: 183079158 Change-Id: I99d4b51f441c2903879092c5b56313d606d4338d
2021-12-01Support empty strings in bp2build Liz Kammer
Previously, could not set an empty string as a value of an attribute; however, this is necessary in some cases. To not unnecessarily create an empty string, use string pointers for attributes rather than strings. Test: go test bp2build tests Change-Id: I03b3a3567452d455246d22d81f86c317d06b7c39
2021-11-03Revert "Fix python_binary_host module in mixed build." Rupert Shuttleworth
Revert submission 1861755-fix_python_binary_host_in_mixed_build Reason for revert: Broke Bazel CI, please see https://android-build.googleplex.com/builds/submitted/7879108/mixed_droid-clean/latest/view/logs/build_error.log and https://android-build.googleplex.com/builds/submitted/7879108/mixed_droid-incremental/latest/view/logs/build_error.log Reverted Changes: Ica457ee71:Add platform needed by python_binary_host. Ibc8b99a92:Fix python_binary_host module in mixed build. Change-Id: I3d6c4f6edee2d00bdc78efd5cee64f4c915baeaa
2021-11-02Fix python_binary_host module in mixed build. Wei Li
Test: USE_BAZEL_ANALYSIS=1 m genfunctosyscallnrs Test: USE_BAZEL_ANALYSIS=1 m func_to_syscall_nrs Test: USE_BAZEL_ANALYSIS=1 m libseccomp_policy Bug: 201094425, 197135289 Change-Id: Ibc8b99a92149410c8a879b7a4facf6c8961a7b9f
2021-10-04Bp2Build common properties auto-handling Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
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-01Have python_*{,_host} handle arch-variants Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
Bug: 196081778 Test: TestPython*{,Host}ArchVariance Test: go test Test: mixed_{libc,droid}.sh Change-Id: I89304e58f5bacd61534732bade4ad6bb5f2671c0
2021-08-27python_{binary,library}{,_host} handle lib property Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
Have binary and library bp2build convert `libs` to `deps` for bazel Bug: 196083751 Test: python_{binary,library}_conversion_test.go Test: build/bazel/ci/mixed_{libc,droid}.sh Change-Id: I2d5f6ef2e83dd608910edb7adb2eb9a56d25293c
2021-08-17Don't create a new module for bp2build conversion. Liz Kammer
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-03-30bp2build: arch-configurable selects for label list attrs. Jingwen Chen
This CL adds the configurable LabelListAttribute support to bp2build. Test: go test Change-Id: I2ef9e385d9cf1b1845988128eca1d8cda1ecb5e8
2021-03-24bp2build: add allowlist for package-level conversions. Jingwen Chen
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-17Add preparers for python Paul Duffin
Bug: 181070625 Test: m nothing Change-Id: I590ad62db6fd62719c83286780563cf6d55e3e17
2021-03-09bp2build: add python_binary_host converter. Jingwen Chen
This CL adds a simple python_binary_host to native py_binary converter for standalone modules that don't depend on libs. It also adds support for the conditional py2/py3 build target based on the version prop. Test: milestone-2/demo.sh full Test: bazel query 'kind("py_binary rule", //bionic/...)' Test: bazel run //bionic/libc/tools:genfunctosyscallnrs Test: bazel run //bionic/libc/tools:genseccomp Test: go tests Fixes: 182236395 Change-Id: Ibe5ec6cd0dc12a61b3a449a8c723d80b891fae42
2020-12-01Add comments/refactor for python.go Liz Kammer
Test: all soong tests Test: m nothing Change-Id: Ib3b95d7c2831b97026e76a39af515fd51c6cb2c7
2020-09-24HostCross is an attribute of a Target, not OsType Jiyong Park
A host target is considered as being cross-compiled when the target can't run natively on the build machine. For example, linux_glibc/x86_64 is a non-cross target on a standard x86/Linux machine, but is a cross host on Mac. Previously, whether cross or not was a static attribute of an OsType. For example, Windows was always considered as cross host, while linux_bionic was not. This becomes a problem when we support more host targets like linux_bionic/arm64 which should be cross-host on standard x86/Linux machines. This change removes HostCross from the OsClass type and instead adds a property HostCross to the Target type. When a target is being added, it is initialized to true when the target can't run natively on the current build machine. Bug: 168086242 Test: m Change-Id: Ic37c8db918873ddf324c86b12b5412952b0f2be2
2020-07-27Add `data_native_bins` property to java_test_host Liz Kammer
When multiple os/arch variants are supported, java_test_host could not find a matching arch due to java having arch:common, whereas native binaries support a specific architecture. This change adds the property `data_native_bins` in order to support binaries with the appropriate os/arch variants. Test: m FirmwareDtboVerification with data_native_bins Test: forrest Bug: 153848038 Change-Id: I45adebff0fde2811d5ef5620c697b97b768c951f
2019-09-26Allow test to specify whether or not to auto-generate test config Dan Shi
Attribute `auto_gen_config` is added to test modules. Test config will be generated if: the attribute is not set and AndroidTest.xml doesn't exists or the attribute is set to true, whether or not AndroidTest.xml exists. Test config will NOT be auto-generated if: the attribute is not set and AndroidTest.xml exists or the attribute is set to false, whether or not AndroidTest.xml exists. Bug: 141684102 Test: build test module with auto_gen_config set to true Change-Id: I64fb003a83d8c32a967835e5f8d12fe4476043be
2019-02-17Support building a par file that does not automatically run Dan Willemsen
Mainly so that we can build a `python` prebuilt that acts like the normal python install, though you could also build different ones with more packages pre-installed. Bug: 117811537 Test: move built py2-cmd into prebuilts/build-tools/path/linux-x86/python and build Change-Id: I21215f6fd3754d89f8c65e1dfeb3f2deea23239f
2018-09-26Fix invalid memory error for python binary build Nan Zhang
The root cause is we didn't check if the optionalpath is valid or not, the registerbuildation function directly invoke the path var and cause the invalid memory error. We just return if the launcher doesn't exist. The ctx.VisitDirectDepsWithTag() also handles allowmissingdependency so we are ok if launcher doesn't exist. Test: N/A Bug: b/116698229, b/67510844 Change-Id: I40941079a64d7797ab879fc5edaa29e835b493a0
2018-03-09Remove timestamp based filelist file for tracking Python dependencies Nan Zhang
Each Python module will generate a zip file containing source & data files. The Python binary will collect all its dependencies and use merge_zips to merge each zip file to create a final .par file. Test: m -j checkbuild && real examples: Bug: b/70568913 Change-Id: I9ff232d461d33e1c06026e7dcb5b124bf02c3ce5
2018-01-02Add VisitDirectDepsWithTag Colin Cross
Add a method on ModuleContext and TopDownMutatorContext to visit direct dependencies that have a given dependency tag. Test: m checkbuild Change-Id: Ib875563091dcae6b7282b3e3427d0eb07d8c8af5
2017-12-01Revert "Revert "Change Python in Soong to support device side build."" Nan Zhang
This reverts commit 0a32e5936b4c87bc705d06fa2d4f6fed1f58d602. Reason for revert: <libsqlite was missing for darwin_x86_64 before> Change-Id: I2e13e849a503a705ffad425df292380f2f73954e
2017-12-01Revert "Change Python in Soong to support device side build." Nan Zhang
This reverts commit 3bba05962dc4329c6e3d28544775db591574ba7b. Reason for revert: <revert mac builds> Change-Id: I25f1380573d69f7e111287624a2d4a3d95fdd86b
2017-11-30Change Python in Soong to support device side build. Nan Zhang
Add python_test to generate executables for both host and device side. And change python_library_host to python_library. installation for python device test will be under target/product/generic_arm[64]/data/nativetest[64]. Bug: b/69114465 Test: m clean && m -j Device Test: adb root; adb push nan_devicetest /data; adb shell; ./nan_devicetest print(sys.path) ['/data/nan_devicetest/runfiles', '/data/nan_devicetest', '/data/nan_devicetest/internal', '/data/nan_devicetest/internal/stdlib'] Change-Id: If8317070a3aa1b6dab2e84b8df2d037f495d7247