Commit graph

707 commits

Author SHA1 Message Date
Liz Kammer
ef6dfea679 Only store what's used in SharedLibraryInfo
There was a reference to the static library provider, but only the
transitive static deps were used, so only store that part. Other members
were stored but unused anywhere.

Test: go test soong tests
Test: m nothing
Change-Id: I12a6b94806c052c3f0df3cab0a10f17042af1c38
2021-06-08 16:44:23 -04:00
Ivan Lozano
3149e6ed18 Rust rlib vendor snapshot support.
Adds support for snapshotting Rust rlibs. This allows us
vendor-specific code that uses rlib-only linkage until dylib
snapshot support is added.

Bug: 184042776
Test: m nothing # new Soong tests pass
Test: Example test Rust vendor module builds
Test: m dist vendor-snapshot # includes rlibs
Change-Id: I4976d3e1efec0ee778cc97730d45be471dffb678
2021-06-03 08:36:09 -04:00
Ivan Lozano
1921e8003d Rust cdylib/statliclib support for vendor snapshot.
Adds support for platform vendor_available Rust FFI libraries and
binaries to be included in the vendor snapshot.

Because rlib and dylibs are not yet in snapshots, libstd cannot be
included in a vendor snapshot. As a result, vendor-specific Rust code
can't be guaranteed to work with the platform-provided vendor_available
modules built with a newer toolchain. For now, a check is added
indicating vendor-specific Rust code is unsupported.

This changes the linkage for vendor variants of these modules to default
to rlib linkage since dylibs cannot be included in the snapshot yet.

Bug: 184042776
Test: m nothing # new Soong tests pass
Change-Id: I502eaa4bb962eb87ff868fcf49b435f0d2f982e6
2021-06-03 08:32:05 -04:00
Justin Yun
9e13187f6b Fix ExcludeFromVendorSnapshot check
ExcludeFromVendorSnapshot() must return true if the module must not
be snapshotted and built from the vendor source tree.
The default value must be false because rust modules are provided by
the system source tree.

Bug: 184042776
Bug: 189372652
Test: m nothing
Change-Id: I267c3a5674bea966d1dd831cda73538ae94cf25f
2021-05-27 21:27:52 +09:00
Jiyong Park
bf8147ab66 Don't install rust modules that are never installable
rust modules that return false on EverInstallable don't get installed.
Currently, proc_macro modules are such ones.

Bug: 187810017
Test: m microdroid on aosp_arm64 and inspect that *.dylib.so files
from host x86_64 are not there.

Change-Id: Ia57289a04dbff6e4f2ce2733c60de5338305904c
2021-05-17 13:27:20 +09:00
Ivan Lozano
d7586b6526 Refactor vendor snapshot to use LinkableInterface.
Refactors the vendor snapshot support to use the LinkableInterface
so that support can be extended to Rust. This CL does not add
vendor snapshot support for Rust; that is left for a follow-on CL.

Bug: 184042776
Test: m nothing
Change-Id: Id0c4970ca00053484a52677d182153cbc454c301
2021-05-12 14:01:10 -04:00
Hamzeh Zawawy
0a91eab365 Merge "Add support for packaging rust fuzzers" 2021-05-03 16:43:08 +00:00
Treehugger Robot
cbaef6ff0f Merge "Add debug ramdisk variant." 2021-05-02 23:54:40 +00:00
hamzeh
c651b5295b Add support for packaging rust fuzzers
Test: make haiku-rust
Change-Id: Idd4d836d11e0ae615b59c6648d49348449589787
2021-05-01 00:55:42 -07:00
Colin Cross
e07056af41 Merge "Remove global state from vendor public libraries" 2021-04-29 16:16:42 +00: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
Colin Cross
5423a9c513 Merge "Remove obsolete llndk_library" 2021-04-28 23:25:06 +00:00
Treehugger Robot
c0ec1dd962 Merge "Generate rustdoc index." 2021-04-28 15:42:30 +00:00
Dan Albert
b433bf7bed Generate rustdoc index.
Test: m rustdoc
Bug: http://b/162741284
Change-Id: I6e649cbae5e3ce38b43baed5d9623851e519b8d0
2021-04-27 17:12:02 -07:00
Colin Cross
5271fea26c Remove global state from vendor public libraries
Remove the global list of vendor public library modules used to rewrite
dependencies from the vendor module to the stubs for system modules,
and replace it with building the stubs directly in the system variant
of the vendor module.

Bug: 178231622
Test: vendor_public_library_test.go
Change-Id: I826e69ffd507d7e85fa3d4d85b5157428c642143
2021-04-27 16:26:00 -07:00
Colin Cross
203b421043 Remove obsolete llndk_library
Remove llndk_library in favor of cc_library with llndk.symbol_file.

Bug: 170784825
Test: m checkbuild
Test: TestLlndkLibrary
Change-Id: I43580976589a7a2a176d7442be53fa043c0c8324
2021-04-26 18:41:00 -07:00
Colin Cross
627280f091 Remove llndk_headers
Replace llndk_headers with cc_library_headers with
llndk.llndk_headers: true.

Bug: 170784825
Test: m checkbuild
Test: compare out/soong/build.ninja
Test: TestLlndkHeaders
Change-Id: I33b411cd4d474318796c2073375176b82dd8c216
2021-04-26 18:40:53 -07:00
Colin Cross
1f3f130e29 Add support for cc_library_headers to replace llndk_headers
Set llndk.llndk_headers: true to allow a cc_library_headers
module to be used by a cc_library module with llndk.symbol_file set.

Bug: 170784825
Test: TestLlndkHeaders
Change-Id: Ib65a4b70717dc9a54ae30f2991485bb1bb9b8409
2021-04-26 18:37:44 -07:00
Matthew Maurer
5fa13b8457 Merge "Enable overflow checks in Rust" 2021-04-26 20:46:21 +00:00
Ivan Lozano
e934263d18 Merge "rust: Pass additional Clang C flags from toolchain" 2021-04-23 18:13:10 +00:00
Ivan Lozano
871e34290e rust: Pass additional Clang C flags from toolchain
The set of Clang flags passed to bindgen from the toolchain was
incomplete. In addition to ToolchainClangCflags(), we also need to call
ClangCflags().

Bug: 184081465
Test: m libgrpc_bindgen
Change-Id: I0b62345fee2f55ba18b4a0c4d825f0447c99db06
2021-04-23 10:25:35 -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
Treehugger Robot
f9b3e22293 Merge "Remove unnecessary android:"path" tags in rust" 2021-04-21 15:53:44 +00:00
Liz Kammer
eda9398bbf Remove unnecessary android:"path" tags in rust
Custom_bindgen is handled by adding a relevant dependency tag.
Flags and Ld_flags are not paths/references to other modules.

Test: go test soong tests
Change-Id: Ic6a69521102318b3b9f29b59560bcefbc9aff8fa
2021-04-20 16:06:02 +00:00
Treehugger Robot
62b9c5bd99 Merge "[rust] Update clang version used for bindgen" 2021-04-19 20:18:39 +00:00
Treehugger Robot
9bd39fe80d Merge "Rustdoc support." 2021-04-19 19:40:18 +00:00
Pirama Arumuga Nainar
655a7d50f4 [rust] Update clang version used for bindgen
Bug: http://b/185528062

Test: presubmit
Change-Id: I0060643b0dec998d1d4f8da2c504c79223995f98
2021-04-19 10:10:21 -07:00
Treehugger Robot
aef14db78a Merge changes from topic "tvts-test-host-jni"
* changes:
  Add jni_libs property to java tests
  Add Target to cc.SharedLibraryInfo
2021-04-17 04:35:24 +00:00
Dan Albert
06feee9352 Rustdoc support.
Adds `m rustdoc` which generates documentation for all Rust libraries
to $OUT_DIR/soong/rustdoc.

Follow up work:

* Generate an index page that lists all modules.
* Preserve the artifacts so we can have an always-up-to-date go link.

Test: m rustdoc
Bug: None
Change-Id: Id2d6b9cbab5b02e36b575567563d7cc7606b9401
2021-04-16 13:38:01 -07:00
Thiébaud Weksteen
45c647d4dc Merge changes I59439b77,I7dbaf8be
* changes:
  bloaty: measure stripped Rust binaries
  rust: do not strip static library
2021-04-15 18:46:32 +00:00
Thiébaud Weksteen
e4dd14b25f bloaty: measure stripped Rust binaries
Modify bloaty's MeasureSizeForPath to allow a module to provide multiple
paths. This is used to measure both unstripped and stripped
libraries/binaries. Add unit test to ensure correct measurements are
generated for Rust.

Test: m out/soong/binary_sizes.pb.gz
Change-Id: I59439b77dbf1cf5ad71e1c02996a6a90938536b4
2021-04-15 12:02:51 +02:00
Treehugger Robot
638830a5a0 Merge changes from topic "userdebug_plat_sepolicy.cil_Android.bp"
* changes:
  Add debug ramdisk variant
  Add path tests for ramdisk
2021-04-15 05:22:35 +00: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
Ivan Lozano
d466b4a1f5 Merge changes from topic "rust_vendor_support"
* changes:
  Add more Rust vendor image support.
  rust: Use new common image mutator interface.
2021-04-14 19:02:49 +00:00
Ivan Lozano
e8dfbdfb59 Merge "cc: Create a common image mutator interface" 2021-04-14 18:53:18 +00:00
Thiébaud Weksteen
4fab05a2ad rust: do not strip static library
Test: m
Change-Id: I7dbaf8be625acae89b0a62ea13d0b250c6542a79
2021-04-14 19:20:07 +02:00
Tri Vo
9e7bfdae31 Merge "rust: Switch rust_fuzz to HWASan" 2021-04-14 16:49:27 +00:00
Jeffrey Vander Stoep
d587ec225a Merge changes from topic "rust_benchmark"
* changes:
  Attach rust_benchmark to atest and tradefed.
  Add rust_benchmark module to soong.
2021-04-14 08:02:46 +00:00
Tri Vo
505b0e8991 rust: Switch rust_fuzz to HWASan
Bug: 180495975
Test: example_rust_fuzzer
Change-Id: I26e6f15136ee2d5f4ed1167be5c1c6a14b19421a
2021-04-13 15:58:44 -07:00
Ivan Lozano
c08897c1e4 Add more Rust vendor image support.
This adds Rust vendor image support for all module types except
Rust prebuilts.

Bug: 184042776
Test: New Soong tests.
Test: Example cc_library vendor module can depend on rust_ffi_shared.
Test: Example rust_library vendor-only module compiles.

Change-Id: Iaa30ad51fdaedcbf14687da5472581f6af62ff59
2021-04-13 13:17:12 -04:00
Ivan Lozano
699e218324 rust: Use new common image mutator interface.
Refactor rust to use and implement the new common image mutator
interface to handle future image mutations.

Bug: 184042776
Test: m nothing
Change-Id: If6a85e2b8c6a1969d62264eaea6c6b53cae9c039
2021-04-13 13:15:21 -04:00
Ivan Lozano
3a7d000d12 cc: Create a common image mutator interface
As part of adding Vendor support to Rust, refactor the image mutator in
CC to a new common image mutator interface so this logic can be reused
across both CC and Rust.

Bug: 184042776
Test: m nothing
Change-Id: Ia55d5ad840db7cf1a64d6c65ed86487230cb8742
2021-04-13 11:04:44 -04:00
Liz Kammer
9c2108667b rust_fuzzer: add toolchain libraries if non-empty
Test: bp2build
Test: m nothing
Fixes: 185163319
Change-Id: Id8b8e5b21b71f949fa8fa27f8c8cc4aba00c1f7d
2021-04-12 18:52:29 -04:00
Tri Vo
eed4716def Merge changes I46e851c8,I2c9eb248
* changes:
  rust: Add HWASan build support
  Export CC HWASan sanitizer type
2021-04-09 22:31:09 +00:00
Ivan Lozano
1285766d3b Merge "rust: Remove stack-depth sancov" 2021-04-09 21:56:51 +00:00
Tri Vo
0a74c3e06e rust: Add HWASan build support
HWASan for static Rust executables is not supported yet.

Bug: 180495975
Test: build local test app with HWASan
Change-Id: I46e851c82a16943586ec3a789f09a58651d036e3
2021-04-09 10:59:23 -07:00
Jeffrey Vander Stoep
3e2d4d419b Merge "Disable clippy::upper-case-acronyms" 2021-04-09 17:48:43 +00:00
Jeffrey Vander Stoep
e9fb49b555 Merge "Rust: use 1.51.0 prebuilts" 2021-04-09 17:48:43 +00:00
Ivan Lozano
20fcfdf489 rust: Remove stack-depth sancov
This flag causes a linkage error between rustc and our libclang_rt. We
can remove it for now and look into reintroducing it in the future.

We'd need to define 'thread_local uintptr_t __sancov_lowest_stack' to
support this. See https://reviews.llvm.org/D36839

Bug: 180495975
Test: m <fuzzer>
Change-Id: I95c9392307b5f20a0eda0fc76eb7ef79e27ae4df
2021-04-09 13:22:27 -04:00
Jiyong Park
a417f881bd Merge "Shared lib dependencies from rlib are included in APEX" 2021-04-08 23:31:28 +00:00
Thiébaud Weksteen
a8ccbaf1e8 Merge "rust: collect file dependencies for clippy" 2021-04-08 13:31:34 +00:00
Jiyong Park
94e22fd35e Shared lib dependencies from rlib are included in APEX
This change fixes a bug that shared lib dependencies of an rlib is not
installed to the APEX even when the rlib is part of the APEX.

Bug: N/A
Test: m
Change-Id: I88fe461584499839d8018d6b4292374592e7562b
2021-04-08 18:20:39 +09:00
Thiébaud Weksteen
e54504e19c Merge "rust: Add cfgs property" 2021-04-08 08:57:22 +00:00
Bram Bonné
2b9ee14ce0 Merge "Allow Rust code in system/logging/rust" 2021-04-08 07:47:45 +00:00
Jiyong Park
84894570e5 Merge "Stripped rust bin/libs are included in APEX" 2021-04-07 17:51:32 +00:00
Thiébaud Weksteen
94c8325261 rust: collect file dependencies for clippy
Previously, the clippy rule did not keep track of the source files for
which a modification would require the target to be rebuilt. Similarly
to the rustc rule, ensure that we capture all the dependencies via the
dep-info output.

Bug: 181298002
Test: m libkeystore2; inspect generated .clippy.d
Change-Id: Icfc7074e1fca38f7782544e6c436ffbfc6c9b4e0
2021-04-07 16:07:47 +02:00
Jiyong Park
e54f07e38a Stripped rust bin/libs are included in APEX
Previously, when a rust bin or library is selected for an APEX,
OutputFile() was used to get the file to be used. However, OutputFile()
always returns the unstripped output file even when the stripped output
file is available. As a result, APEX having a rust module was very big
due to the debugging information that exists in the unstripped file.

When a rust module is directly installed to the built-in partitions, we
use the stripped one whenever it's available. To make the same happen
when the rust module is placed in an APEX, OutputFile() is modified to
return the unstripped output if it's available.

Bug: 181751814
Test: TARGET_BUILD_APPS=com.android.virt m
The size is reduced from 180MB to 43MB

Change-Id: I6f8479e6a4794aac8bf94a84afdf65d417c75db0
2021-04-07 22:23:31 +09:00
Thiébaud Weksteen
c44e7372ed rust: Add cfgs property
Rust configuration options ("--cfg") are currently defined using the
"flags" property. Adds a specific property to be able to forward these
to the rust-analyzer configuration (rust-project.json).

Bug: 183727250
Test: m libstd
Change-Id: Ida89097814bcd1a45c02a8a79ec5a8e9e59701bd
2021-04-07 15:04:10 +02:00
Jakub Kotur
546ccd5614 Attach rust_benchmark to atest and tradefed.
Automatically generate required tradefed configs for rust benchmarks so
that they're available in atest.

Test: atest <module with rust_benchmark defined>
Bug: 155309706
Change-Id: I6002100367a66b6b0555614acc6cebb00dbf435d
2021-04-06 12:40:34 +02:00
Jakub Kotur
1d640d0521 Add rust_benchmark module to soong.
This commit adds rust_benchmark and rust_benchmark_host commands to
soong. Respectively running rust benchmarks on device and host. Currently
only criterion based benchmarks are supported and criterion library is
automatically linked.

Test: atest <module with rust_benchmark defined>
Bug: 155309706
Change-Id: I6edfc2b4bf30b1163fe59b8c2ecdcd4e7125e7b9
2021-04-06 12:40:32 +02:00
Treehugger Robot
8c56183fb7 Merge changes Id33bf640,I4d67b9b9
* changes:
  Don't use incorrect version names like VER or BOARD even in tests
  SdkSpec = Scope + ApiLevel
2021-04-06 03:18:16 +00:00
Joel Galenson
1301b5ccad Merge "Add system/core/libstats to the Rust allowed list." 2021-04-05 18:50:47 +00:00
Ivan Lozano
d235269392 Merge "rust: Update libfuzzer flags for rust_fuzz" 2021-04-05 15:05:00 +00:00
Jiyong Park
f58c46e36f Don't use incorrect version names like VER or BOARD even in tests
All version names will go through ApiLevelFromUser which triggers an
error when the name is not a valid one.

Bug: 175678607
Test: m
Change-Id: Id33bf64085603914d45ad7942cb8908a4734493f
2021-04-05 09:32:06 +09:00
Ivan Lozano
c044f5bce8 rust: Update libfuzzer flags for rust_fuzz
libfuzzer-sys uses different flags in the 0.4.0 update, so update the
flags for rust_fuzz modules to align.

Test: m <example_fuzzer>
Change-Id: I0a1eb140a7843fdaf5266c05a1ecf6d3964e0f5e
2021-04-02 12:43:28 -04:00
Paul Duffin
e6165d0f46 Merge "Convert remaining rust tests to use test fixtures" 2021-04-01 18:13:23 +00:00
Jeff Vander Stoep
0f36d16fee Disable clippy::upper-case-acronyms
Bug: 184269635
Test: TH
Change-Id: Ib941f9d625d1b8cfc395fd926ddf301e11fb0c4a
2021-04-01 19:40:37 +02:00
Paul Duffin
79abe57f53 Remove FixturePreparer.Extend()
Use GroupFixturePreparers instead.

Bug: 182885307
Test: m nothing
Change-Id: Idc01d3cc5a57576a4cf417e9105d1ab851126e10
2021-04-01 10:33:20 +01:00
Jeff Vander Stoep
60b2234c8d Rust: use 1.51.0 prebuilts
Test: TH
Change-Id: I11c10eda1e989db5084556ff248ff0d0fa85b98c
2021-03-31 11:35:35 +02:00
Paul Duffin
9e0c3f9993 Convert remaining rust tests to use test fixtures
Removes now unused CreateTestContext and stops exporting the
RegisterRequiredBuildComponentsForTest() method as it is only used
locally.

Bug: 181070625
Test: m nothing
Change-Id: Ia2fd3e090f975ee4c807da2c6c162ef3cf7ac446
2021-03-30 22:45:21 +01:00
Joel Galenson
f4b139abcd Add system/core/libstats to the Rust allowed list.
This is where the Rust statspull API will live.

Test: Build
Change-Id: Ia3cae85c576fa3caacd87395dc76069b26e134de
2021-03-30 13:40:43 -07:00
Matthew Maurer
378bf736ed Enable overflow checks in Rust
Bug: 184063125
Test: Existing Rust Test Suites
Change-Id: I1b8f3cb22a229bfc7da81bf3857f6bf5a9f6c220
2021-03-30 11:49:08 -07:00
Bram Bonné
e45541d825 Allow Rust code in system/logging/rust
Bug: 162454083
Test: make logger
Change-Id: I1116b930af7e06be31c237867fecc6ccd609e4b3
2021-03-29 16:02:53 +02:00
Thiébaud Weksteen
785f378f7d Merge "rust: Add features list to rust_project.json" 2021-03-29 07:58:08 +00:00
Ivan Lozano
352bdf29b3 Merge "rust: Add whole_static_libs, revert static_lib" 2021-03-26 13:01:14 +00:00
Treehugger Robot
10906f5cc6 Merge changes from topic "min_sdk_version"
* changes:
  Versioned CRT objects are built with correct __ANDROID_API__
  Always respect min_sdk_version
2021-03-26 08:07:28 +00:00
Ivan Lozano
63bb7680c9 rust: Add whole_static_libs, revert static_lib
Revert the static_lib behavior to the previous behavior (pass static
libs to the linker rather than via to rustc using `-lstatic=<lib>`). To
bundle static libraries into libraries, provide the whole_static_libs
property which retains the current static_libs behavior.

Passing all static libraries via -lstatic was resulting in odd bloat
where in some cases static symbols were duplicated in binaries and
libraries. This split makes it possible to be explicit about when static
libraries should be bundled.

Bug: 183182230
Test: mma system/bt; mma system/security/keystore2; mma external/rust

Change-Id: Ic2dde5d1542dca5ce145aa3a3fbd9ea54440d991
2021-03-25 13:50:17 -04:00
Thiébaud Weksteen
e8b0ee73f4 rust: Add features list to rust_project.json
Bug: 183679729
Test: SOONG_GEN_RUST_PROJECT=1 m nothing
Test: manually check v1 feature resolution for libprofcollectd
Change-Id: Ib59b63372865f7f4545fe327e92d1642d76ce9c9
2021-03-25 09:59:49 +01:00
Thiébaud Weksteen
70204f9fc9 Merge "rust: Drop libgcc dependency" 2021-03-24 12:44:09 +00:00
Paul Duffin
2c4ca8d73f Support test fixtures in rust package
Replaces the rust specific rustTestCtx mechanism with the general test
fixtures mechanism as converting it to use preparers was not possible.

Also, removes usages of the buildDir variable and removes it as it is
no longer needed.

Bug: 181070625
Test: m nothing
Change-Id: I0176a7b6fb2d390ae23693f1e198da5124b4be63
2021-03-23 18:47:15 +00:00
Thiébaud Weksteen
f1ff54a10b rust: Drop libgcc dependency
Rustc unstable option "link-native-libraries" is used to prevent the
linkage of other libraries via the #[link] directive. Add a dependency
to libclang_rt.builtins, similarly to cc.

Bug: 141331117
Test: lunch aosp_crosshatch-userdebug; m
Change-Id: I5c232291a5dd08a99e6a12a1295e30bb8e4fcaf1
2021-03-23 13:55:40 +01:00
Jiyong Park
fdaa5f7164 Versioned CRT objects are built with correct __ANDROID_API__
Background: `min_sdk_version` of a crt object is the oldest SDK version
that the crt object supports. When it's set to for example 16, Soong
creates a number of versioned variants of the crt object starting from
16 to the latest version. The variant for version X is provided to NDK
clients having `min_sdk_version` set to X.

Problem: all versioned variants of a crt object were built with `-target
<arch>-linux-android16`. Therefore they all have been with `#define __ANDROID_API__
16`.  This is because the mutated variants still have the same
min_sdk_version property and the clang triple follows min_sdk_version,
not sdk_version. This is too conservative and against our intention to
provide the latest crt object that matches with the min_sdk_version of
the client.

In the other hand, the platform(non-sdk) variant of the crt object
doesn't have such a problem. min_sdk_version is completely ignored.
However, this is a bug and will be fixed by aosp/1640364. As a side
effect of the fixing, the platform variant will begin to built with a
very old __ANDROID_API__ which unnecessarily turns off the new platform
features like the TLS segment over-alignment.

This change fixes the problems:

* For the versioned variants of crt objects, we set both
`min_sdk_version` and `sdk_versio` to the version that the variant is
created for.

* For the platform variant of crt objects, `min_sdk_version` is force
reset to "current".

Bug: 183191008
Test: m

Change-Id: I8c9d0fcea816de8cd1532dac4a47eee4f726c037
2021-03-23 01:18:31 +09:00
Tri Vo
0e3758caea Merge "Remove "-C link-dead-code=y" flag" 2021-03-18 21:27:54 +00:00
Tri Vo
7af79fb49b Remove "-C link-dead-code=y" flag
sysroot no longer builds with this flag.

LLVM ERROR: Cannot select: 0x7f7c39be9b48: v8i8 = AArch64ISD::VSLI 0x7f7c39696120, 0x7f7c39693fc8, 0x7f7c39d86528, prebuilts/rust/linux-x86/1.50.0/src/stdlibs/library/core/src/../../stdarch/crates/core_arch/src/aarch64/neon/mod.rs:2324:5
  0x7f7c39696120: v8i8,ch = CopyFromReg 0x7f7c420b1c98, Register:v8i8 %13, prebuilts/rust/linux-x86/1.50.0/src/stdlibs/library/core/src/../../stdarch/crates/core_arch/src/aarch64/neon/mod.rs:2324:5
    0x7f7c39be90e8: v8i8 = Register %13
  0x7f7c39693fc8: v8i8,ch = load<(dereferenceable load 8 from %ir.b)> 0x7f7c420b1c98, 0x7f7c39694510, undef:i64, prebuilts/rust/linux-x86/1.50.0/src/stdlibs/library/core/src/../../stdarch/crates/core_arch/src/aarch64/neon/mod.rs:2324:19
    0x7f7c39694510: i64,ch = CopyFromReg 0x7f7c420b1c98, Register:i64 %17, prebuilts/rust/linux-x86/1.50.0/src/stdlibs/library/core/src/../../stdarch/crates/core_arch/src/aarch64/neon/mod.rs:2324:19
      0x7f7c39be52d8: i64 = Register %17
    0x7f7c39bea230: i64 = undef
  0x7f7c39d86528: i32,ch = CopyFromReg 0x7f7c420b1c98, Register:i32 %18, prebuilts/rust/linux-x86/1.50.0/src/stdlibs/library/core/src/../../stdarch/crates/core_arch/src/aarch64/neon/mod.rs:2324:5
    0x7f7c39be5ea0: i32 = Register %18
In function: _RNvNtNtNtCsfOHkQPwunBC_4core9core_arch7aarch644neon9vsli_n_s8B7_
11:40:52 ninja failed with: exit status 1

Bug: 147140513
Test: build/run local rust_fuzz executable with asan+sancov.
Change-Id: I00c81f25f562bb9f18169a199eaf95ebeb7dbbe6
2021-03-17 18:00:28 -07:00
Pirama Arumuga Nainar
7b33d41170 Update clang used for bindgen to clang-r412851
Test: presubmit
Change-Id: I4883bd3c26a4037d01829c0806fc908b2c8e1c37
2021-03-17 10:37:51 -07:00
Thiébaud Weksteen
ee6a89ba44 Export OUT_DIR variable to rust-project.json
This variable is required by rust-analyzer to correctly process crates
that uses the include!(concat!(env!("OUT_DIR"), ...)) pattern.

Adds an initialize method to baseCompiler to save the computed path for
this directory. It is not possible to use the BeginMutator as the
BaseModuleContext does not contain enough information to use
PathForModuleOut.

Bug: 175004835
Test: SOONG_GEN_RUST_PROJECT=1 m nothing; inspect rust-project.json
Change-Id: If47b3832d3cca5712ae87773c174a61f5ee27bf8
2021-03-15 08:13:20 +00:00
Paul Duffin
db4888966a Add text fixture preparers for rust package
Needed to decouple the integration of test fixtures into apex from the
support of test fixtures in rust tests.

Bug: 181070625
Test: m nothing
Change-Id: I26bdfde58dd75713ece89e631edabf041d40596a
2021-03-11 17:25:29 +00:00
Treehugger Robot
2046a0c1c7 Merge "Add stats directory to Rust allowed list." 2021-03-09 19:13:49 +00:00
Paul Duffin
d6ceb8600c Clean up cc.RegisterRequiredBuildComponentsForTest()
Changes this function so it only registers components from the cc
package by pushing the call to genrule.RegisterGenruleBuildComponents()
down into those packages whose tests need it.

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

Bug: 181070625
Test: m nothing
Change-Id: Ic00c7e480dc738d7a88d038aca6ab95a1502a24a
2021-03-05 18:20:33 +00:00
Ivan Lozano
b6d0d9cec4 rust: Disable Byte Grouping Linter
Disable the byte grouping clippy lint by default. In some cases it makes
sense to group bytes in a protocol-specific fashion, so let's not error
on this lint.

Bug: 181171365
Test: Clippy allows this lint.
Change-Id: I2705dc7fa901b997bcb01f1256d48e85ce35065c
2021-02-25 11:24:35 -05:00
Jeffrey Vander Stoep
22af74eafd Merge "Setup ANDROID_RUST_VERSION env variable" 2021-02-23 10:10:06 +00:00
Treehugger Robot
277303f042 Merge "Add ctx to AndroidMkExtraEntriesFunc" 2021-02-22 22:40:31 +00:00
Thiébaud Weksteen
9997ea73a3 Setup ANDROID_RUST_VERSION env variable
Some crates (i.e. rustversion) probe at build time the version of Rust
to enable features or tests. Pass the version via an environment
variable so it can be used by a patched crate.

Bug: 178357400
Test: m librustversion
Change-Id: If57a6339b71d2188c56e7dc6709075e4537403b4
2021-02-22 10:56:43 +01:00
Jeffrey Vander Stoep
8348e09173 Merge "Disable unnecessary_wraps clippy lint" 2021-02-20 07:06:41 +00:00
Jeffrey Vander Stoep
92c674dc32 Merge "Update Rust toolchain to 1.50.0" 2021-02-20 07:06:41 +00:00
Colin Cross
aa2555387d Add ctx to AndroidMkExtraEntriesFunc
Add a ctx parameter to AndroidMkExtraEntriesFunc to allow them to
access providers.

Test: m checkbuild
Change-Id: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc
Merged-In: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc
2021-02-19 23:05:40 +00:00
Jeff Vander Stoep
41f8157ba7 Disable unnecessary_wraps clippy lint
Bug: 180268112
Test: build
Fixes: 180703142
Change-Id: I13f3de49318a6a9d2141042836a08ba7e300648f
2021-02-19 17:19:39 +01:00
Thiébaud Weksteen
df229cb00a Enable size measurement for Rust binaries
Bug: 172339742
Test: m out/soong/binary_sizes.pb
Change-Id: Ibc9feaa1c806b888d8850303ab7eeaf5e5337e35
2021-02-18 15:46:19 +01:00
Jeff Vander Stoep
dc79fe85e7 Update Rust toolchain to 1.50.0
Bug: 180268112
Test: mm crosvm
Change-Id: Ib36f252a99e06059b413326b8f9d1733534facbc
2021-02-17 23:53:18 +01:00
Dan Albert
a175126009 Merge "[arm64] Build NDK with PAuth and BTI" 2021-02-17 21:37:41 +00:00
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