Commit Graph

505 Commits

Author SHA1 Message Date
Joel Galenson 77a684e8fb Add stats directory to Rust allowed list.
Bug: 178390804
Test: Build Rust code in that directory.
Change-Id: I3b83fdab4158df8aaf7fed164e5a015cd73772e1
2021-02-17 11:22:38 -08:00
Ivan Lozano 36eb24b3ab Merge "rust: Emit android vndk cfg flag." 2021-02-14 16:20:46 +00:00
Ivan Lozano f76cdf7c20 rust: Emit android vndk cfg flag.
Pass an "android_vndk" cfg flag that indicates this code
targets the vndk. This can be useful in instances where code
might need to behave differently.

This also includes a fix to make sure our vendor Soong tests
are correctly configured.

Bug: 179907868
Test: Soong tests pass.
Test: Example module emits new cfg flags.
Change-Id: I01cdf91f6f9d42cd8a759266d5170479664bf4bc
2021-02-12 12:17:50 -05:00
Ivan Lozano 05ad76b459 Merge "rust: Use prebuilts for x86 host target." 2021-02-11 17:39:11 +00:00
Treehugger Robot b68036f44b Merge "Add LOCAL_LICENSE_KINDS to build/soong" 2021-02-10 07:18:29 +00:00
Julien Desprez 7f11ed7fb4 Merge "Changing default of rust_test_host to unit_tests:true" 2021-02-10 00:07:49 +00:00
Ivan Lozano c5d34ec100 rust: Use prebuilts for x86 host target.
Use prebuilts for x86 host targets to make both x86 and x86_64 builds
more consistent with one another. This fixes building x86 binaries.

Bug: 162063992
Bug: 169347277
Test: Build 32-bit host module.
Change-Id: Id11eb0f3b949439cec090060a33b755af94b5883
2021-02-09 14:22:00 -05:00
Ivan Lozano 4ccfcc2ee4 Merge "rust: Add rust_ffi_static vendor ramdisk Support" 2021-02-09 13:49:28 +00:00
Ivan Lozano e6d3098c1b rust: Add rust_ffi_static vendor ramdisk Support
Similar to our vendor support, this adds support for linking rust static
libraries to vendor ramdisk cc modules.

A bug fix is also included where a restriction against setting rust_ffi
vendor-specific was not being enforced.

Bug: 179397942
Test: Example modules link, Soong tests pass.
Change-Id: I737cdf0c2f49ab349bcea2a0429e6298ebc1313e
2021-02-08 09:36:26 -05:00
Bob Badour 02040de891 Add LOCAL_LICENSE_KINDS to build/soong
Added SPDX-license-identifier-Apache-2.0 to:
  Android.bp
  android/Android.bp
  android/soongconfig/Android.bp
  androidmk/Android.bp
  apex/Android.bp
  bazel/Android.bp
  bp2build/Android.bp
  bpf/Android.bp
  bpfix/Android.bp
  cc/Android.bp
  cc/config/Android.bp
  cc/libbuildversion/Android.bp
  cc/libbuildversion/tests/Android.bp
  cc/ndk_api_coverage_parser/Android.bp
  cc/ndkstubgen/Android.bp
  cc/symbolfile/Android.bp
  cmd/dep_fixer/Android.bp
  cmd/diff_target_files/Android.bp
  cmd/extract_apks/Android.bp
  cmd/extract_jar_packages/Android.bp
  cmd/extract_linker/Android.bp
  cmd/fileslist/Android.bp
  cmd/host_bionic_inject/Android.bp
  cmd/javac_wrapper/Android.bp
  cmd/merge_zips/Android.bp
  cmd/multiproduct_kati/Android.bp
  cmd/path_interposer/Android.bp
  cmd/pom2bp/Android.bp
  cmd/pom2mk/Android.bp
  cmd/sbox/Android.bp
  cmd/soong_build/Android.bp
  cmd/soong_env/Android.bp
  cmd/soong_ui/Android.bp
  cmd/zip2zip/Android.bp
  cmd/zipsync/Android.bp
  cuj/Android.bp
  dexpreopt/Android.bp
  dexpreopt/dexpreopt_gen/Android.bp
  env/Android.bp
  etc/Android.bp
  filesystem/Android.bp
  finder/Android.bp
  finder/cmd/Android.bp
  genrule/Android.bp
  jar/Android.bp
  java/Android.bp
  java/config/Android.bp
  kernel/Android.bp
  linkerconfig/Android.bp
  linkerconfig/proto/Android.bp
  makedeps/Android.bp
  partner/Android.bp
  phony/Android.bp
  python/Android.bp
  python/tests/Android.bp
  remoteexec/Android.bp
  rust/Android.bp
  rust/config/Android.bp
  scripts/Android.bp
  sdk/Android.bp
  sh/Android.bp
  shared/Android.bp
  symbol_inject/Android.bp
  symbol_inject/cmd/Android.bp
  sysprop/Android.bp
  tradefed/Android.bp
  ui/build/Android.bp
  ui/logger/Android.bp
  ui/metrics/Android.bp
  ui/metrics/proc/Android.bp
  ui/status/Android.bp
  ui/terminal/Android.bp
  ui/tracer/Android.bp
  xml/Android.bp
  zip/Android.bp
  zip/cmd/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  finder/fs/Android.bp
  third_party/zip/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work

Change-Id: Ia47ca14f16b8c9f84f9d533a07e5b00e2c04e8d4
2021-02-06 04:23:21 +00:00
Ivan Lozano fb6f36f3e4 rust: Only pass "-lstatic" for rlibs.
Passing '-lstatic' for dylib static dependencies results in some
unexpected bloat as the static libraries are included as
whole-archives.

For now, limit this to rlibs while we investigate.

Bug: 175886967
Bug: 179122837
Test: cd system/bt/; mma
Test: Checked size of dylibs.
Change-Id: Id8328e95771e2ca8503bc8df35248b1c39cabc8e
2021-02-05 12:32:47 -05:00
Julien Desprez 84c9494a5f Changing default of rust_test_host to unit_tests:true
Switch all rust_test_host to unit_tests = true by default.

Test: presubmit trigger
Bug: 177689340
Change-Id: Ie6059f874d8805049d5f6e5de18574050ae431d7
2021-02-05 16:50:03 +00:00
Ivan Lozano 729d5cf097 Merge "rust: Pass cc static libs to rustc." 2021-02-05 15:53:33 +00:00
Liz Kammer b7eab01167 Merge "bp2build: convert paths/module refs to Bazel label" 2021-02-05 13:39:08 +00:00
Ivan Lozano 3dfa12db6c rust: Pass cc static libs to rustc.
Pass static libraries to rustc via the "-lstatic" flag so that rustc can
reason how to handle these libraries. This means that these static
libraries get bundled into rlibs, reducing the need to redeclare these
dependencies in dependent modules.

Additionally, exported depFlags were never used anywhere, so remove this
from flagExporter.

Bug: 175886967
Bug: 179122837
Test: m
Test: Checked that static symbols aren't duplicated in a resulting
      binary when it appears in a dependency graph more than once.
Change-Id: Ifeb3c384e4fad8704206997242a0156ddcb87d2c
2021-02-04 16:29:02 -05:00
Liz Kammer 356f7d45c1 bp2build: convert paths/module refs to Bazel label
This currently expands all globs, still need to support converting glob
syntax.

Test: go build_conversion_test
Test: GENERATE_BAZEL_FILES=true m nothing
Test: m nothing
Bug: 165114590
Change-Id: If7b26e8e663d17566fad9614ca87a8da1f095284
2021-02-04 13:45:56 -05:00
Justin Yun cbca373efa Use target dependent module to update the name suffix
The module names for vendor and product variants have the image
variant suffix to avoid conflict with the core modules. It requires
updating the module names in the dependency tree with the suffixes.

We had a hidden bug that used the original module properties to
update the names of its dependent modules.
Also, it must cover the product variants modules.

Test: updated cc_test.go and build
Change-Id: I6b4ea062d13c8fac1e699138d44376e52e0d7852
2021-02-03 19:42:29 +09:00
Matthew Maurer 20768b8840 rust: Use v0 mangling format globally
By default, rust uses the `legacy` mangling format. Using llvm coverage
switches it to using the new `v0` format. Rather than pushing the llvm
coverage back to `legacy` format, move Android forwards to `v0`. This
also has the added benefit that Rust symbols can be detected in the
codebase by looking for a leading "_R", aiding in demangler selection.

Test: builds, resulting object files have leading _R rather than _Z
Test: atest keystore2_test
Bug: 178565008
Change-Id: I7fcd591535d08260686c62fbfa6f7b61b31ed989
2021-02-02 00:23:26 +00:00
Ivan Lozano 9da4aa8166 rust: Allow rust_tests to include data files.
Adds the ability to define data files that should be installed alongside
the test.

This also fixes a bug wherein rust_test properties were duplicated.

Bug: 171710847
Test: rust_test module with "data" property installs files to device.
Change-Id: I091489afaf7e76b751a33a28049590d9fb39fe5f
2021-01-29 14:31:32 -05:00
Yi Kong 2c9b3e0e25 Add system/extras/simpleperf to Rust allowed paths
This is to allow simpleperf to export rust bindings for use by
profcollect.

Test: build
Change-Id: I187139d6133c144e86cbdb05d20c2515c189718e
2021-01-27 15:48:31 +08:00
Ivan Lozano 0e737626fc Merge "Rust: abort on panic" 2021-01-26 19:54:33 +00:00
Colin Cross 2df8177575 Add Target to cc.SharedLibraryInfo
Dependencies from common arch modules like java libraires to cc modules
may need to retrieve the Target of the library, add it to
SharedLibraryInfo.

Bug: 176593487
Test: cc_test.go
Change-Id: I93ab9da5fab2ccc42c6b483a6d83c071b541d1e6
2021-01-26 11:02:53 -08:00
Treehugger Robot 2a3094c70f Merge "Migrate Rust to LLVM coverage." 2021-01-26 15:28:36 +00:00
Jeff Vander Stoep bf7a902951 Rust: abort on panic
Test: build (test included in build)
Bug: 162266455
Change-Id: I7f53956d3a35f923d0282d511d6360051f945a88
2021-01-26 09:09:06 -05:00
Treehugger Robot 65490b8cf3 Merge "Define odm_available property to install a vendor variant to odm" 2021-01-26 11:32:18 +00:00
Tamas Petz bca786d742 [arm64] Build NDK with PAuth and BTI
This change adds a new arch named "armv8-a-branchprot". The new target
is no different from the usual "armv8-a" variant except it has the
compiler flag "-mbranch-protection=standard" set.

With this flag compiler emits Armv8.3-A Pointer Authentication and
Armv8.5-A Branch Target Identification instructions. All of these
instructions are in the hint space; therefore devices which do not
support any of these extensions would execute them as NOPs.

In terms of directory structure there is no change in the output of
build/soong/scripts/build-ndk-prebuilts.sh script.

Test: build NDK prebuilts

Change-Id: Ie52ccba5653fbf567f0b7ca312d8a8e71602ad06
2021-01-26 08:15:07 +01:00
Ivan Lozano 6cd99e6ab4 Add Rust fuzzing support.
Add a rust_fuzz module which builds a libfuzzer binary that enabes
asan+sancov. This relies on the libfuzzer-sys crate.

Bug: 147140513
Test: Local rust_fuzz example builds, fuzzes with asan+sancov.
Change-Id: I57db3b8d25869791824ccfab768d13b0bb9d42fa
2021-01-25 11:11:10 -05:00
Justin Yun ebcf0c5e15 Define odm_available property to install a vendor variant to odm
'vendor_available: true' creates a vendor variant from a system
module. The vendor variant of the module is installed to /vendor.
However, we may want to install the vendor variant to /odm, instead.

'device_specific: true' does not work for this purpose because
'vendor_available: true' is allowed only for the system or product
modules to create a vendor variant. But 'device_specific: true'
itself creates a vendor variant that may not work with
'vendor_available: true'.

To install the vendor variant to /odm, we define a new property
'odm_available'. 'odm_available' is exactly the same as the
'vendor_available' except the install path of the vendor variant.
By defining 'odm_available: true', the vendor variant of the module
will be installed to /odm or /vendor/odm instead of /vendor.

Bug: 176147321
Bug: 176079978
Test: check if a module with 'odm_available: true' is installed to
      /vendor/odm
Change-Id: I2d16bd2c515796597b2fbd1eb66f7c2736434697
2021-01-25 17:08:44 +09:00
Ivan Lozano ec6e9910e6 rust: Depend on CC a shared library's TOC, not .so
CC libraries generate TOC files which contain the list of exported
symbols. By depending on the TOC file instead of the .so, changes to
shared library dependencies will not result in rebuilding Rust
dependencies as long as the exported symbols remain unchanged. This
should improve incremental build times during development.

This also includes a minor fix where exported linkObjects should be
deduplicated to avoid the same object being included many times.

Bug: 173619911
Test: m libkeystore2; modify a bionic file; m libkeystore2
      doesn't rebuild the rust target.
Change-Id: I6383217c125bf8dd7125a5e013a78754cac4edf2
2021-01-22 11:41:33 -05:00
Joel Galenson fa049385b8 Migrate Rust to LLVM coverage.
Bug: 177675913
Test: Manually compile, run, and see output with llvm-cov.
Change-Id: I66729cff87a848782e9fa1b95cbbc06318c5761a
2021-01-15 19:44:07 +00:00
Thiébaud Weksteen d7e51e0891 Merge "Use 1.49.0 prebuilts" 2021-01-14 18:26:41 +00:00
Ivan Lozano 3968d8f678 Refactor CC to prep for Rust sanitizable modules.
Adds a PlatformSanitizable interface which both CC and Rust can
implement so that the sanitizer mutators in CC can sanitize Rust
shared/static libraries appropriately.

Bug: 147140513
Test: m nothing
Change-Id: Ib31103b6c4902a4d5df2565c0d7c981298d100a3
2021-01-08 08:53:46 -05:00
Thiébaud Weksteen cb738204fa Use 1.49.0 prebuilts
Bug: 176888219
Test: build external/rust/crates
Change-Id: I979720ac75e8546058c23ac86b2b64ac518b115c
2021-01-08 14:20:04 +01:00
Treehugger Robot 86cc40a74c Merge "Do not read 'vendor_available: false'" 2021-01-08 00:57:35 +00:00
Peter Collingbourne b143cd9482 Enable debug info in Rust modules.
This allows tombstones to be symbolized and is consistent with C/C++
where we pass -g.

Bug: 173723155
Change-Id: I597e2bf97517407b428277f1cf7aa19b73371efa
2021-01-07 12:05:04 -08:00
Justin Yun c0d8c49224 Do not read 'vendor_available: false'
In case of VNDK, 'vendor_available: false' had a special meaning that
defines VNDK-private libraries. It is not trivial because not
defining a boolean property means 'false' normally. To avoid the
confusion replace it with the 'vndk.private: true' for VNDK-private
libraries and 'private: true' for LLNDK-private libraries.

All VNDK libraries must define 'vendor_available: true' and may have
'vndk.private: true' if they are VNDK-private.
With this change '(vendor|product)_available: false' is the same as
not defining the property.

LLNDK-private must define 'private: true' instead of
'vendor_available: false'.

Bug: 175768895
Test: build
Change-Id: I57fbca351be317257d95027f3cdcdbbe537eab23
2021-01-07 17:58:55 +09:00
Peter Collingbourne 9a868f1238 Allow the clang version used for bindgen to be configured.
This is useful when experimenting with new compiler flags that the
existing compiler does not support.

Change-Id: I45b8a2980b247d60a7f4e2ba55169267aeceef2b
2020-12-30 21:18:54 -08:00
Jaewoong Jung e794b1e302 Merge "Remove unnecessary snake case variables." 2020-12-23 01:21:28 +00:00
Treehugger Robot 109d9ccdcb Merge "rust modules in APEX don't get installed to the system partition" 2020-12-23 00:42:20 +00:00
Jaewoong Jung 18aefc1977 Remove unnecessary snake case variables.
Test: m nothing + TreeHugger
Change-Id: I99f7162944daa6c57c6ae4763261e108bb5cb6b1
2020-12-22 12:38:35 -08:00
Jiyong Park 459feca5cc rust modules in APEX don't get installed to the system partition
Otherwise, we get duplicated build rules.

Bug: N/A
Test: OUT_DIR=out DIST_DIR=out/dist
build/soong/scripts/build-ndk-prebuilts.sh

Change-Id: I2be0695d284bd72a19e02c8b7509a7f39afade8b
2020-12-22 15:10:00 +09:00
Colin Cross 127bb8b9f6 Don't rewrite LLNDK dependencies with .llndk suffix
Rewriting LLNDK dependencies with .llndk suffix requries referencing
a global data structure to determine if a given library is an LLNDK
library and therefore needs the .llndk suffix.  References to
global data structures from mutators must be removed to support
incremental Soong analysis.  Instead, move the LLNDK stubs rules
into the vendor variant of the implementing cc_library so that
the original name can be used.

As an incremental step, the llndk_library modules are left in
place, and the properties are copied into the cc_library via
the dependency specified by the llndk_stub property.  A followup
will move the LLNDK properties directly into the cc_library and
delete the llndk_library modules.

The global list of LLNDK libraries is kept for now as it is used
to generate the vndk.libraries.txt file.

Bug: 170784825
Test: m checkbuild
Test: compare Soong outputs
Test: all Soong tests
Change-Id: I2a942b21c162541a49e27b2e5833c9aebccff1d0
2020-12-21 17:53:30 -08:00
Colin Cross 97a1be6e7b Merge changes from topic "sbox_tools"
* changes:
  Sandbox genrule tools
  Call ctx.InstallFile for uninstallable cc modules
  Don't copy uninstallable variants of NDK libraries to sysroot
2020-12-17 22:01:06 +00:00
Colin Cross a9c8c9f145 Call ctx.InstallFile for uninstallable cc modules
SkipInstall is actually primarily used to prevent making a module
visible to Make, rename it and add new SkipInstall that actually
skips installation without affecting Make.

Call c.SkipInstall() for uninstallable cc modules to allow calling
c.installer.install, which will collect PackagingSpecs for
uninstallable cc modules, allowing them to be used by genrules.

Bug: 124313442
Test: m checkbuild
Change-Id: I8038ed5c6f05c989ac21ec06c4552fb3136b9a7a
2020-12-17 10:02:18 -08:00
Treehugger Robot 1a74be780b Merge "Assert android.ApexModule interface for types having ApexModuleBase" 2020-12-17 04:14:35 +00:00
Treehugger Robot 4d24e65bbf Merge "Put external/libchromeos-rs in the Rust allowlist" 2020-12-15 23:28:19 +00:00
Jiyong Park 45bf82e953 Assert android.ApexModule interface for types having ApexModuleBase
Bug: 173472337
Test: m nothing
Change-Id: Idf1c6cb9fff6c18e34c4636e38a662ba4ff7d538
2020-12-15 14:31:27 +00:00
Ivan Lozano 6eff900b67 Merge rust_protobuf and rust_grpcio module types.
To allow grpc protobufs to include non-grpc protos in a singular
library, we need to allow them to be defined as part of the same module.

This CL merges the two previously distinct module types into
rust_protobuf, and adds a new property for declaring which protos
contain grpc definitions.

Bug: 172952239
Test: rust_grpcio modules converted to rust_protobuf modules and build.
Test: Example rust_protobuf module with both proto types builds.
Change-Id: I0e627fd97bc6f74de89d309e3344694a1e76586d
2020-12-11 16:19:02 -05:00
Ivan Lozano 30530a9e34 Merge "Rust: WriteFileRule instead of printf for protos" 2020-12-11 19:14:29 +00:00
Ivan Lozano 90f5c1d5d6 Merge "Rust: Vendor support for Rust static libraries." 2020-12-11 13:44:31 +00:00
Ivan Lozano f48c89cd39 Merge "Refactor for preliminary Rust vendor image support" 2020-12-11 13:40:20 +00:00
Jiyong Park 0d399b5915 Merge "Add min_sdk_version to Rust modules." 2020-12-10 23:54:34 +00:00
Ivan Lozano 9d74a52706 Rust: WriteFileRule instead of printf for protos
Use WriteFileRule instead of a rule that calls printf for generating the
module source file for rust_protobuf.

Bug: 171361369
Test: rust_protobuf modules compile
Change-Id: Ie83a30e19d7d09875f3d209662526783862d8ea0
2020-12-10 15:35:05 -05:00
Ivan Lozano 6a88443089 Rust: Vendor support for Rust static libraries.
We don't have Rust VNDK support yet, but static linkage can be
supported in the interim. This adds support for making rust_ffi_static
libraries available to CC vendor modules.

Since rust_ffi_static modules will link against rlibs, we allow rlib
linkage into vendor as well, but only for the variants which use the
rlib libstd.

Bug: 172525289
Test: New Soong tests pass
Test: Example vendor cc_binary links against rust_ffi_static module.
Change-Id: Idf3aeb51e32293866f1ad965e329aa6b9e0bf2ef
2020-12-10 10:29:54 -05:00
Ivan Lozano f9e2172aec Refactor for preliminary Rust vendor image support
Refactors parts of CC to prepare for preliminary support for using Rust
static libraries in vendor images. Some previously private functions are
made public, and additional functions are added to LinkableInterface so
GetMakeLinkType can be passed a LinkableInterface.

Bug: 172525289
Test: m
Change-Id: I5fda48e79532fe9ceab255e18d910af58048a123
2020-12-10 10:29:48 -05:00
Ivan Lozano 366cb49b9f Merge "Move prefer_rlib from binary to base compiler." 2020-12-09 23:02:53 +00:00
Ivan Lozano 3e9f9e47cf Add min_sdk_version to Rust modules.
Add the min_sdk_version property to Rust modules so they can declare
a minimum SDK version they support for use with APEX modules.

Test: New Soong test passes.
Bug: 174862583
Change-Id: I2829053a320f50c218783dee5adbeff9cef81e8e
2020-12-09 11:30:44 -05:00
Ivan Lozano ea08613dd3 Move prefer_rlib from binary to base compiler.
Moves the prefer_rlib property out from being exclusively a binary
property to one thats part of the base compiler properties. This
provides a little more control over the libstd linkage in our libraries.
Specifically, this enables a usecase where rust_ffi_shared needs to link
against libstd statically rather than dynamically.

Bug: 175121262
Test: New Soong tests pass.
Change-Id: If68014c684a75ba70e9d7dacbb01c7d360dc25a1
2020-12-09 09:55:12 -05:00
Ivan Lozano 78b340f375 Merge "Add LinuxBionic toolchain to Rust" 2020-12-08 22:04:49 +00:00
Ivan Lozano bf3b6e9b8d Add LinuxBionic toolchain to Rust
The LinuxBionic toolchain wasn't defined for Rust.

This would lead to build breakage if a CC module that targeted Linux
Bionic linked against a Rust FFI module.

Bug: 174873186
Test: Build breakage no longer occurs if CC module with Rust dependency
      is built for the Linux Bionic target.
Change-Id: I39df7b9a29372986c9beeb1fe5602140d805d731
2020-12-08 09:04:21 -05:00
Thiébaud Weksteen fa5feae43c Add dependencies for source-generated crates
When using SourceProviders, the dependency tree does not include
directly the source variant, only the built variant. For instance:

  liba --> libbingena_rlib --> libbingena_source

However, libbindgena_rlib did not have a source associated with the
module, and was therefore not added as a dependency. Modify the logic so
that a SourceProvider library will find the right variant and always
have a source defined.

Adds display_name fields to the crate description to ease debugging.

Test: rust-analyzer analysis-stats .
Bug: 174158339
Change-Id: Id65708d57cd176f7e1da353f4a5f7ad65b003090
2020-12-07 14:45:09 +01:00
Victor Hsieh 274597b951 Put external/libchromeos-rs in the Rust allowlist
Bug: 174797066
Test: m
Change-Id: Ieef7df3c17e6d6b1223769cfd07301dfe7d91363
2020-12-04 11:21:06 -08:00
Bernie Innocenti 3a710d6bbb Allow rust code in packages/modules/DnsResolver
Test: m com.android.resolv.apex
Change-Id: I6cb5234f51ac6c31440e7cd5aeca4655629a35d6
2020-12-05 02:55:53 +09:00
Thiébaud Weksteen 4bfb2b99f8 Merge "Includes rust_binary in rust-project.json" 2020-12-04 14:37:14 +00:00
Thiébaud Weksteen 064f6e957e Includes rust_binary in rust-project.json
Until now, only rust_library (and their derivatives such as
rust_library_host) were reported in rust-project.json. Adds support for
rust_binary and rust_tests.

Bug: 174743191
Test: Validate auto-completion in keystore2_main.rs
Change-Id: I17b3ec29e233f29b7abd16dc771070ada48d17fb
2020-12-03 20:58:32 +01:00
Colin Cross f1a035e6be Pass pctx and ctx to NewRuleBuilder
Enable the RuleBuilder and RuleBuilderCommand methods to access
the BuilderContext by passing it to NewRuleBuilder instead of
RuleBuilder.Build.

Test: genrule_test.go
Test: rule_builder_test.go
Test: m checkbuild
Change-Id: I63e6597e19167393876dc2259d6f521363b7dabc
2020-12-01 16:22:16 -08:00
Treehugger Robot 464e6c71df Merge "Add test suite handling to central androidmk code" 2020-12-01 22:19:26 +00:00
Liz Kammer 57f5b33ad3 Add test suite handling to central androidmk code
MTS is introducing partial MTS test suites that are per-module, with
names of the format: mts-${MODULE}. By centralizing the code for test
suites, we can automatically add "mts" test suite when an
"mts-${MODULE}" test suite is specified, reducing duplication.

Test: m mts
Bug: 170318013
Change-Id: I8ce9d3c252fcc0a937bb5f2826d21cb6c6932d82
2020-12-01 12:23:56 -08:00
Ivan Lozano 9c3f653207 Merge "rust: Add support for multiple protos per module." 2020-12-01 13:11:57 +00:00
Jiyong Park 493e7ec3ee Merge "Clients of PackagingBase can customize dependency tag to use" 2020-12-01 03:44:38 +00:00
Jiyong Park 65b6224471 Clients of PackagingBase can customize dependency tag to use
Previously, the dep tag used by PackagingBase was fixed, which prevented
some of its clients (e.g. cvd-host-package) from opting in to
android.InstallAlwaysNeededDependencyTag. Now, PackagingBase.AddDeps
accepts the dependency tag to use.

Also, dependencies toward rust dylib, rlib, and proc_macro are
configured to return true on InstallDepNeeded. This is required to
install shared_lib dependencies of the rust modules when they are
depended on by a rust binary.

Exempt-From-Owner-Approval: a trivial change after +2 from the owner.
This has to land ASAP as many users are affected by acloud being
unavailable.

Bug: N/A
Test: m
Test: acloud create --local-instance --local-image
Change-Id: If22aee7c6f314fcb03b9d4fe6901a2557f1e899c
2020-12-01 03:43:05 +00:00
Treehugger Robot 93bfe6bf76 Merge "Allow rust code in device/google/cuttlefish" 2020-12-01 00:16:41 +00:00
Jiyong Park fdea25781f Merge "rust modules can be included in apex" 2020-11-30 15:41:28 +00:00
Jiyong Park 99644e92c8 rust modules can be included in apex
We will have some APEXes having rust binaries and libraries. So, adding
the support for the types of modules.

rust.Module now inherits from android.ApexModuleBase and implements
the android.ApexModule interface.

Bug: 172414324
Test: m

Exempt-From-Owner-Approval: rebased after +2 from the owner
Change-Id: I356ef4c45f782a6460f001e83af96d1710642d80
2020-11-30 15:40:48 +00:00
Ivan Lozano 57f434e858 rust: Add support for multiple protos per module.
This further emulates the rust-protobuf gen_mod_rs flag by providing
support for generating a single module containing multiple protobuf
definitions.

Bug: 171361369
Test: New Soong tests.
Test: Example module containing multiple protos works.
Change-Id: I815f9628a8289ae512758073dac49bc4535abf01
2020-11-30 14:55:00 +00:00
Thiébaud Weksteen c6fe19d637 Use 1.48.0 prebuilts
Bug: 173721343
Test: build external/rust/ and crosvm
Change-Id: Ifde24640fc262c5eebdcd623556e925e7d78ae85
2020-11-27 14:42:57 +01:00
Thiébaud Weksteen 463ab7a27e Merge "Ignore variant dependencies in rust-project.json" 2020-11-26 09:15:09 +00:00
A. Cody Schuffelen 4e5fc3b422 Allow rust code in device/google/cuttlefish
Test: TreeHugger
Change-Id: If7bce48e101bd49389d952556bfdf95d7899f01b
2020-11-25 18:29:39 -08:00
Liz Kammer 0fd0e95e1b Merge "Refactor rust to use AndroidMkEntries" 2020-11-26 00:06:03 +00:00
Thiébaud Weksteen 3c5905b0cb Ignore variant dependencies in rust-project.json
Source-generated library modules will have a dependency on the source
variant. This creates a cycle in the dependency graph which triggers a
warning from rust-analyzer. Ignore this type of dependency.

Test: m nothing
Change-Id: I13365093ebb88b00f6a72734b01114ec3e9a320e
2020-11-25 16:11:49 +01:00
Liz Kammer 4018a8d4d7 Refactor rust to use AndroidMkEntries
This is to facilitate consolidation of compatibility suite logic.

Test: go soong tests
Test: m nothing & compare soong Android mk files -- only diffs are
      elimination of duplicate LOCAL_UNINSTALLABLE_MODULE := true lines
Change-Id: I76211505b2b6afde5d0431586b77d799cf70c6b9
2020-11-24 09:44:51 -08:00
Colin Cross e5218b6be6 Merge "Annotate dependency tags for dependencies of installed files" 2020-11-24 16:01:35 +00:00
Colin Cross e9fe2949b8 Annotate dependency tags for dependencies of installed files
Relands Ic22603a5c0718b5a21686672a7471f952b4d1017 with a minor
change to track libc++ dependencies for python hosts and after
a fix to an internal genrule that depended on transitively
installed java libraries (ag/13068670).

Soong currently assumes that installed files should depend on
installed files of all transitive dependencies, which results
in extra installed file dependencies through genrules, static
libs, etc.

Annotate dependency tags for dependencies for which the
installed files are necessary such as shared libraries
and JNI libraries.

This avoids extra installed files, and is also a first step
towards genrules using their own copy of tools instead of
the installed copy.

Bug: 124313442
Test: m checkbuild
Test: java.TestBinary
Test: cc.TestInstallSharedLibs
Test: deptag_test.go
Change-Id: I725871249d561428e6f67bba6a7c65b580012b72
2020-11-23 18:06:08 -08:00
Thiébaud Weksteen 588ed66364 Add comments to {cc,rust}/strip.go
Bug: 173695621
Test: n/a
Change-Id: If3086aa711507c3be6db23e3691163cdd68710bf
2020-11-19 20:02:34 +01:00
Ivan Lozano 1010f9bd56 Merge "rust: Add header library support to rust_bindgen." 2020-11-18 14:06:09 +00:00
Dan Shi ebb51503a4 Merge "Add unit_test test option in test configs" 2020-11-18 04:40:37 +00:00
Ivan Lozano 9b44383788 rust: Add header library support to rust_bindgen.
Allow rust_bindgen modules to define dependencies that only provide
headers and may not necessarily need to be linked in.

Bug: 161141999
Test: Soong tests pass.
Test: Example module has appropriate include flags when compiling.
Change-Id: Ic9ce8b1204008ad8dcb18766c914e48bb292d485
2020-11-17 13:40:50 -05:00
Ivan Lozano d7ddf051d3 rust: Fix incorrect expected gcno file for dylibs
For Rust dylibs we generate a file suffix of .dylib.so. rustc seems to
split the output filename for the gcno file at the first '.', so instead
of libfoo.dylib.gcno (which our build system expects), it produces
libfoo.gcno.

This fixes the mismatch so the build system can find the gcno file that
gets produced for Rust dylibs.

Bug: 170983066
Test: CLANG_COVERAGE=true NATIVE_COVERAGE_PATHS=external/rust/crates \
      m libandroid_log_sys
Change-Id: Icba48bf10ab06c255bd17053d57feb889b1f9ee5
2020-11-17 08:08:21 -05:00
Dan Shi d79572f73e Add unit_test test option in test configs
This change allows a test (native, java, rust or python) to be included
in host-unit-tests suite when test option `unit_test` is set to true.

Bug: 172006742
Test: m host-unit-tests
Change-Id: I69d3eb5b51198c549e2e6914ceac3a4fc33c3cf2
2020-11-16 11:05:00 -08:00
Colin Cross ae8600b507 Pass Config to NewTestContext instead of ctx.Register
Prepare for using Config when adding singletons by passing
Config to NewTestContext and NewContext instead of to ctx.Register.
This will enable a followup change to store SingletonMakeVarsProviders
registered on the Context in the Config, which is necessary to run
multiple tests in parallel without data races.

Test: all soong tests
Change-Id: Id229629a4e42ff4487d317241673837726c075fc
2020-11-12 10:07:49 -08:00
Ivan Lozano 45e0c95f85 Merge "rust: Fix absolute path OUT_DIR bug" 2020-11-12 15:23:39 +00:00
Zach Johnson c0ea1701cb Merge "rust_grpcio well known types support, default deps" 2020-11-11 23:22:27 +00:00
Zach Johnson 3df4e6364b rust_grpcio well known types support, default deps
The usage of the well known type Empty requires a hack in the module
above the grpc implementation, this is now the generated stem_mod.rs

This also adds additional implicit dependencies that are required by
the grpc protobuf generated code. This includes the addition of a
'header_libs' property for library dependencies which export include
paths required by protos.

We also now include both the protos and the grpcio in the library
variant via the mod_stem.rs.

Bug: 172592789
Bug: 171504899
Test: m nothing
Test: Example rust_grpcio module build command includes dependencies,
      include paths.
Change-Id: I187a13cd5cdea991828a1020314de16727e4f74e
2020-11-11 12:09:26 -08:00
Ivan Lozano 1776a2ac6f rust: Fix absolute path OUT_DIR bug
The OUT_DIR for rustc is incorrectly calculated when Soong's OUT_DIR
is set to an absolute path through OUT_DIR_COMMON_BASE. This breaks
compilation when rustc is unable to find files that have beein included
through the include! macro.

Bug: 172952634
Test: OUT_DIR_COMMON_BASE=/some/abs/path m
Change-Id: Id447630a7774c1dec655f65dd227c144a159e1b1
2020-11-11 11:25:48 -05:00
Stephen Hines a3faafa377 Rust bindgen should use r399163b.
Bug: http://b/155835175
Test: m
Change-Id: Iedccd3c2258fab5f9fb1034aace7d07da833a0ec
2020-11-09 16:28:23 -08:00
Matthew Maurer 40c9798e92 Merge "rust: Fix GRPC generator invocation" 2020-11-06 19:04:16 +00:00
Thiébaud Weksteen 567f46fe63 Merge changes from topic "roll-rust-1.47.0"
* changes:
  Use Rust 1.47.0 prebuilts
  rust: set STD_ENV_ARCH
2020-11-06 07:28:42 +00:00
Matthew Maurer 5819e58fdc rust: Fix GRPC generator invocation
When using the grpc generator, the plugin expects to also have access to
the protobuf generator. This patch ensures that aprotoc will use the
Soong copy of the protobuf generator, rather than trying to use a
locally installed version from PATH.

Test: m nothing
Change-Id: I26da4d18c97017da7d8cd9515a07a2b7b2575342
2020-11-06 01:40:41 +00:00
Treehugger Robot f5b2a5feb7 Merge "rust_bindgen: respect custom OUT_DIR" 2020-11-05 19:54:46 +00:00
Ivan Lozano 86a1db7baf Merge "Add rust_grpcio module type." 2020-11-05 17:47:11 +00:00
Thiébaud Weksteen 3e0d3f6ef5 Use Rust 1.47.0 prebuilts
Bug: 171280890
Test: cd external/rust; mm
Change-Id: I61097821a73a28a383a07b1fdcfe867872397b43
2020-11-05 17:35:34 +01:00
Thiébaud Weksteen 71512f3265 rust: set STD_ENV_ARCH
In 1.47.0, std::env requires the STD_ENV_ARCH environment variable to be
set to the target architecture [1].

[1] 8e8939b804/library/std/src/env.rs (L866)

Bug: 171280890
Test: cd external/rust; mm
Change-Id: If4ddf4b9bad2a1a7518a358a5fb597170a97c67e
2020-11-05 17:35:17 +01:00
Shao-Chuan Lee aa3231cd6b rust_bindgen: respect custom OUT_DIR
Bug: 172551033
Test: m
Change-Id: I1f760de7cb03ec0bcad5c66ac08bb88ca77c26cd
2020-11-06 00:12:02 +09:00
Ivan Lozano 6a3d1e9831 Add rust_grpcio module type.
Adds a new SourceProvider type to generate grpcio code from protos.
Since it's so similar to protobuf, it's basically just a different type
of rust_protobuf.

Bug: 171504899
Test: Example module compiles.
Change-Id: I9882f3ac4d4aeaae0191f2b557e9612b5c7a9ac9
2020-11-05 08:53:52 -05:00
Treehugger Robot 20cf20ba1c Merge changes I0289d866,Ie7363524
* changes:
  Move stubs related methods out of LinkableInterface
  Don't create stubs variants of static libraries
2020-11-02 21:31:11 +00:00
Colin Cross 31076b3185 Move stubs related methods out of LinkableInterface
The stubs methods are very specific to cc for now, move them out
of LinkableInterface so they are not shared with rust.  Instead,
create a cc.Module.library field that contains the libraryInterface
to simplify calling libraryInterface methods on cc modules.

Test: all Soong tests
Test: no change to Soong outputs
Change-Id: I0289d866ce1f7a765631fe3101a62b1b4988ba1c
2020-10-29 14:17:54 -07:00
Qasim Javed d271ada0c9 Add system/bt to Rust allowed paths.
Test: m nothing

Change-Id: Ie467a622dfdb8aea94a06f5fe20183dc9d149254
2020-10-29 11:18:08 -07:00
Yifan Hong b646bc183a Merge changes from topic "vendor_ramdisk_soong"
* changes:
  Vendor ramdisk modules install to correct location
  Add vendor-ramdisk image to Soong.
2020-10-24 01:08:16 +00:00
Yifan Hong 60e0cfb5cb Add vendor-ramdisk image to Soong.
Add vendor_ramdisk_available and vendor_ramdisk attribute to
various rules. When a vendor_ramdisk variant of a module is
generated, it is installed to $OUT/vendor-ramdisk.

It is similar to a ramdisk image.
Test: m nothing -j

Change-Id: Ib2d16459f3094dbe21c3bdb7c016cb4b2bf62765
2020-10-22 10:26:26 -07:00
Alistair Delva 6b07ff2d9d Merge "Add external/vm_tools/p9 to rust allowed paths" 2020-10-22 17:17:03 +00:00
Alistair Delva ebb2901bb0 Merge "Alpha sort rust allowed_list.go" 2020-10-21 17:00:50 +00:00
Ivan Lozano d90bd4a1ed Merge "rust: Add cflag checks against -xc++ and -std." 2020-10-21 14:37:40 +00:00
Alistair Delva ea2974c8b3 Add external/vm_tools/p9 to rust allowed paths
Change-Id: Ifccb7b94a6655524b99d669168c54cf93eed5f89
2020-10-21 06:57:00 -07:00
Alistair Delva e172eaf67b Alpha sort rust allowed_list.go
Change-Id: If0e9938bb776f42037b57680505de19b9cd88771
2020-10-21 06:56:20 -07:00
Ivan Lozano 0a2a115457 rust: Add cflag checks against -xc++ and -std.
If -x c++ is passed through a modules cflags, it will be overridden by a
-x c and -std flag added by the build system if the extension is not
.hpp/.hh and cpp_std is not set. This leads to confusing behavior.

Instead, add a helpful error message to guide developers towards the
correct way to specify when a header is  a C++ header and which std
version should be used.

Bug: 171011490
Test: m nothing
Change-Id: I7e7cba504798d47ce1c753ba8699d7475a95095b
2020-10-16 10:52:46 -04:00
Chih-hung Hsieh f4155dc551 Merge "Use protobuf-codegen default and add mod_stem.rs" 2020-10-15 05:46:18 +00:00
Andrew Scull 251b517222 Merge changes from topic "rust4virt"
* changes:
  Update rustfmt preupload example reference
  Allow packages/modules/Virtualization to use rust
2020-10-14 07:15:02 +00:00
Andrew Scull 5a58bca1f4 Update rustfmt preupload example reference
The arguments passed to rustfmt have changed from those used in the
previously referenced CL so update the comment to reference a CL using
the new arguments.

Bug: 164111102
Test: None
Change-Id: I962d56ed36422709a1fcd07ca95f1c015daa6339
2020-10-13 13:52:37 +01:00
Andrew Scull af2015d7d6 Allow packages/modules/Virtualization to use rust
Rust will be used for a few virtualization related components so allow
it to be used in the directory in which those components will reside.

Test: built a rust binary in the directory
Change-Id: I805d6117201c2144f7ecf21ec38b577c7c21e9c5
2020-10-13 11:43:52 +01:00
Colin Cross 3572cf74f9 Move LLNDK and NDK versionSelectorMutator special cases into versionedInterface
Implement stubsVersions on *llndkStubDecorator and *stubDecorator to
handle the special cases in versionSelectorMutator.

Test: m checkbuild
Change-Id: Idc985c52f91450df42c0275b2b2acef3f2ed8868
2020-10-12 16:55:49 -07:00
Colin Cross 0de8a1e17b Start using Providers instead of direct module access
Export information about static libraries, shared libraries and
exported flags through Providers instead of accessing the module
directly.  Much more is left to be converted, but this significantly
simplifies the dependencies on libraries with stubs by making it easy
for a module to masquerade as another by simply exporting the
providers from the other module.  Instead of depending on all the
versions of a library and then picking which one to use later, it
can depend only on the implementation variant and then select the
right SharedLibraryInfo from the variant.

Test: m checkbuild
Test: only expected changes to build.ninja
Change-Id: I1fd9eb4d251cf96ed8398d586efc3e0817663c76
2020-10-12 16:55:47 -07:00
Jaewoong Jung 19bc60abee Merge "Add config.AndroidFirstDeviceTarget." 2020-10-12 17:30:18 +00:00
Jaewoong Jung 642916f20a Add config.AndroidFirstDeviceTarget.
Targets[Android][0] is not always the first, preferred target. Add a new
field to config to provide the correct target and begin to use it.

Test: m nothing
Test: build/soong/scripts/build-ndk-prebuilts.sh
Fixes: 156980228
Change-Id: Ib56f52424ebf47f3eee6ac62b9fd9eca2919d63a
2020-10-12 14:15:19 +00:00
Colin Cross 405af07859 Revert "Make lots of tests run in parallel"
This reverts commit 323dc60712.

Reason for revert: Possible cause of test instability
Bug: 170513220
Test: soong tests

Change-Id: Iee168e9fbb4210569e6cffcc23e60d111403abb8
2020-10-09 18:34:24 -07:00
Chih-Hung Hsieh c49649c059 Use protobuf-codegen default and add mod_stem.rs
* Upgrade to new protobuf-codegen; use its standard
  default output without local change.
* Allow a sourceProvider to have multiple output files.
  For a stem.proto file, output stem.rs and mod_stem.rs.
* New protobuf-codegen option gen_mod_rs always generates
  output file named "mod.rs". To generate multiple .proto
  files into the same output directory, we need to rename
  mod.rs to mod_<stem>.rs.
* Instead of using the gen_mod_rs option and renaming mod.rs
  to mod_<stem>.rs, we generate the same mod_<stem>.rs
  directly with a simple printf command.

Bug: 170256643
Test: atest -c --host --include-subdirs external/crosvm
Change-Id: Ia09e41029099a6de4d35c96dbabd9ba5514c9019
2020-10-09 13:38:37 -07:00
Thiébaud Weksteen 43977e8d0e Merge "rust: refactor tests setup" 2020-10-09 12:13:15 +00:00
Joe Onorato a80b480eea Refactor OWNERS files in platform/build/soong.
Pulls out all of the per-file rules into their relevant directories
so platform/build/soong:/OWNERS can be included everywhere we need
the list of build system owners.

Test: treehugger
Bug: 170407947
Change-Id: I5a4b2d252bd9b3c280cd9954cf0e65ac21153ede
2020-10-08 16:14:32 -07:00
Thiébaud Weksteen 0a75e52460 rust: refactor tests setup
Move to a builder pattern to increase flexibility when generating the
test configuration. The testRust, testRustCov and testRustError are kept
as main entry points for standard tests. Add documentation.

Test: m nothing
Change-Id: I891bec982ff2d65413f150d2395edf0fb0d68a43
2020-10-08 15:51:10 +02:00
Colin Cross 45fd6ace7e Merge "Make lots of tests run in parallel" 2020-10-07 20:40:38 +00:00
Colin Cross 323dc60712 Make lots of tests run in parallel
Putting t.Parallel() in each test makes them run in parallel.
Additional t.Parallel() could be added to each subtest, although
that requires making a local copy of the loop variable for
table driven tests.

Test: m checkbuild
Change-Id: I5d9869ead441093f4d7c5757f2447385333a95a4
2020-10-06 15:12:22 -07:00
Treehugger Robot 614b06c8ce Merge "Add allow rust rule for android.system.keystore2 vts tests." 2020-10-06 21:03:42 +00:00
Colin Cross ac0cd89283 Merge changes I4c8cd544,I62d4d43d,I0ae667d4,Id357adc0,I1ff87134
* changes:
  Don't create version variations of sdk modules
  Create fewer empty version variants
  Don't make SplitPerApiLevel imply UseSdk
  Remove vendor crt special case
  Fix apex_test.go and add it to Android.bp
2020-10-06 17:33:30 +00:00
Colin Cross 565cafdcb1 Don't create version variations of sdk modules
They are never used, skip creating them.

Test: m checkbuild
Change-Id: I4c8cd544327ae79b781f704be5a9064efdbdf2af
2020-10-05 18:57:26 -07:00
Colin Cross 3146c5cd67 Create fewer empty version variants
Don't create empty version variants for binaries, objects, rust
rlibs or rust dylibs.

Test: no change to build.ninja
Change-Id: I62d4d43da476eafdb258a08b5ada758bb2971a1a
2020-10-05 18:57:21 -07:00
Ivan Lozano 4e7b26a434 Merge "rust: Allow rust_bindgen to use cc_defaults." 2020-10-03 00:22:49 +00:00
Colin Cross 1348ce3f13 Don't make SplitPerApiLevel imply UseSdk
UseSdk was returning true when SplitPerApiLevel returned true,
which was causing the platform variant of SplitPerApiLevel
module to compile against the SDK.  Check SplitPerApiLevel
separately in the sdkMutator instead.

Test: m checkbuild
Change-Id: I0ae667d48a3b7b96709a6cad8e8ea9701659fc2a
2020-10-02 13:00:19 -07:00
Ivan Lozano bf63d00c54 rust: Add static binary support
Adds the "static_executable" property to rust_binary modules which
allows for building fully static executables. This only impacts bionic
targets.

Bug: 169434439
Test: rust_binary module with static_executable true builds, runs on
      device.

Change-Id: I83c19fddd070859b7e56d248237cfd73e1768519
2020-10-02 12:31:23 -04:00
Ivan Lozano 45dda43df0 Merge "rust: Refactor staticStd to stdLinkage" 2020-10-01 12:25:38 +00:00
Janis Danisevskis 1edd039bff Add allow rust rule for android.system.keystore2 vts tests.
Bug: 160623310
Test: N/A
Change-Id: Ie501a56c3ed6c1352fc57b5b956df6ac3f4af39f
2020-09-30 14:43:40 -07:00
Thiébaud Weksteen 996de36d0f Merge "rust: document manual configuration for rustfmt" 2020-09-30 14:41:14 +00:00
Thiébaud Weksteen 4f6c766992 rust: add darwin as host arch
Bug: 169739272
Test: m nothing
Change-Id: I3ef2a3dd7e80b9fe47edb6eb04ed9d37e8d58096
2020-09-30 14:16:12 +02:00
Thiébaud Weksteen 425a542e2b rust: document manual configuration for rustfmt
Currently, rustfmt requires to be enabled per repository. Add a comment
near the current project allowed_list as a reminder.

Test: None
Bug: 160223496
Change-Id: Iecf8d5b693620541a00d8ddc905549652025eed9
2020-09-30 08:37:42 +00:00
Thiébaud Weksteen a6351caf12 rust: Add ref to generated sources (aidl, bindgen)
Test: SOONG_GEN_RUST_PROJECT=1 m nothing; Edit
  system/security/keystore2/selinux/src/lib.rs;
  Check name resolution in IDE.
Bug: 168263887
Change-Id: Icbbf176c4355c3043807ce3fe0c3967c4a1374e2
2020-09-29 20:23:49 +02:00
Thiébaud Weksteen 3805f5cd2e rust: refactor projectGeneratorSingleton
Move the project and knownCrates arguments to attributes of
projectGeneratorSingleton.

Test: SOONG_GEN_RUST_PROJECT=1 m nothing
Change-Id: I52beadc8b3ba68c275ec940a6be51c2645983a6c
2020-09-29 19:08:02 +02:00
Treehugger Robot ca17414206 Merge changes Id412359e,I9c4d3a33,Ic3216235
* changes:
  Fix ChooseSdkVersion after api levels
  Don't export flags from SourceProvider variants
  Simplify missing whole_static_libs checking
2020-09-28 20:27:10 +00:00
Ivan Lozano dd0554722a rust: Refactor staticStd to stdLinkage
Instead of returning a boolean, return an enum value to improve
readability and provide greater flexibility for future modifications.

Bug: 168729404
Test: Soong tests pass
Change-Id: Iddcdae8c34be09e476404382e43d1ea5935bae65
2020-09-28 13:26:05 -04:00
Ivan Lozano 11200870b0 rust: Add prefer_rlib property for static libstd.
Adds the prefer_rlib property to allow linking libstd statically for
device rust binaries. This also changes the default behavior of rustlibs
to also prefer rlib linkage. This is because dylibs do not provide
rlib-libstd variants and always link in libstd dynamically. Thus a
binary requesting libstd rlib linkage should not attempt to link against
dylibs that link libstd dynamically.

Bug: 168729404
Test: New Soong test passes.
Change-Id: Idf8dfbbce8fd936f55a3fb323b17a1a7f0ee954e
2020-09-28 12:01:47 -04:00
Colin Cross d3e05caa47 Don't export flags from SourceProvider variants
There is no need to export the linkdirs from the SourceProvider
variant.  Remove them to reduce differences in build.ninja from
a later patch that moves the flag exporting into compile(), which
isn't called by the SourceProvider variant.

Test: m checkbuild
Change-Id: I9c4d3a336a07cb9074376303bfa277c05d893b98
2020-09-26 00:52:55 +00:00
Ivan Lozano bc9e421215 rust: Allow rust_bindgen to use cc_defaults.
rust_bindgen modules can't inherit properties in cc_defaults that would
be useful for generating bindings (such as cflags). This CL moves these
common properties out into a new struct in cc and adds that struct to
cc_default.

Additionally, Cppflags is added to rust_bindgen to make sure that these
get picked up as well from cc_defaults.

Bug: 163598610
Test: rust_bindgen module uses cflags in cc_defaults.
Test: New Soong test passes
Change-Id: I702442a355244dc01954083f98a2eebbcea12e47
2020-09-25 16:15:26 -04:00
Thiébaud Weksteen e0510d7a69 rust: Fix module name in bindgen_test
Test: m nothing
Change-Id: Ifc1dda4433906f3496e86f5b29b7d9ec694d735c
2020-09-25 15:50:09 +02:00