Commit graph

23 commits

Author SHA1 Message Date
LaMont Jones
0c10e4dcc0 Parallelize singleton execution
Bug: 281536768
Test: manual, presubmits
Change-Id: I57fdc76ba6b277e88e196b506af87127a530fd37
2023-05-19 20:31:32 +00:00
Thiébaud Weksteen
566eb80d3c Support rust_toolchain_library for rust-project
Bug: 209678277
Test: SOONG_GEN_RUST_PROJECT=1 m nothing; check that libstd is included
Change-Id: Ic197e00bc4695aa6dcd46b8c704a82a2e5e90460
2021-12-08 17:54:19 +11:00
Seth Moore
af96f99d83 Include proc macro crates in rust-project.json
These crates were skipped before, leaving dependencies missing in
rust-project.json. Include them and mark them as `"is_proc_macro": true`
so that rust-analyzer can process them.

Fixes: 202290038
Test: SOONG_GEN_RUST_PROJECT=1 m nothing
Change-Id: Ia80e6f5e2f56a76608ba057075600e6b4424281b
2021-10-06 19:39:06 +00:00
Chris Wailes
90c4b14a30 Removed commented out code
A previous CL commented out code instead of removing it.  This CL fixes
this grave error.

Test: TH
Change-Id: I1daeaaa1ad90230aec639d603e7cdb9b61af251a
2021-08-10 10:21:02 -07:00
Chris Wailes
353405d9fb Clean up generated rust-project.json files
This CL removes the roots section from the rust-projects.json file as it
is no longer required by the rust-analyzer tool.

Bug: 162055556
Test: prebuilts/rust/tests/rust-analyzer-integration-test.sh
Change-Id: I85c3277632c88394bc52e709ecce83f6aa1f2e0e
2021-08-09 15:50:39 -07: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
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
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
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
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
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
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
Thiébaud Weksteen
83ee52f4cd rust: validate existence of library source
While rust_bindgen modules may be interpreted as libraries, they do not
have a reference to the generated source until bindgen has been
executed. For now, ignore these modules.

Update the unit tests to cover the rust_bindgen case.

Test: SOONG_GEN_RUST_PROJECT=1 m nothing
Bug: 162881856
Change-Id: I329d0fe3d94b77d395c3684f55ab01544ff7c18f
2020-08-06 15:17:46 +02:00
Thiébaud Weksteen
2f628baeae rust: handle modules with same crate_name
crate_name do not need to be unique. A library may depend on two
different versions of the same crate. Use the module name instead of the
crate name when indexing the modules for rust-project.json.

Test: SOONG_GEN_RUST_PROJECT=1 m nothing
Bug: 162896400
Change-Id: I8af9115b106fda2bed5b9fe96059cc29a33ac247
2020-08-06 15:17:42 +02:00
Thiébaud Weksteen
c810510898 Revert "rust: validate existence of library source"
Revert submission 1391076

Reason for revert: Broken downstream Darwin build (b/162975597)
Reverted Changes:
I275f04639:rust: handle modules with same crate_name
Ie736d7ebb:rust: validate existence of library source

Change-Id: I1732d50a08546864f17cd826c8af574c1064c670
2020-08-06 12:28:08 +00:00
Thiébaud Weksteen
246e69c586 Revert "rust: handle modules with same crate_name"
Revert submission 1391076

Reason for revert: Broken downstream Darwin build (b/162975597)
Reverted Changes:
I275f04639:rust: handle modules with same crate_name
Ie736d7ebb:rust: validate existence of library source

Change-Id: I995923153c11db26b4af985f2eabe94912fb04d3
2020-08-06 12:27:56 +00:00
Thiébaud Weksteen
ad8ac53581 rust: handle modules with same crate_name
crate_name do not need to be unique. A library may depend on two
different versions of the same crate. Use the module name instead of the
crate name when indexing the modules for rust-project.json.

Test: SOONG_GEN_RUST_PROJECT=1 m nothing
Bug: 162896400
Change-Id: I275f04639ef05f2b649c30168046e13b2efcacb9
2020-08-05 16:34:38 +02:00
Thiébaud Weksteen
891cd578c7 rust: validate existence of library source
While rust_bindgen modules may be interpreted as libraries, they do not
have a reference to the generated source until bindgen has been
executed. For now, ignore these modules.

Update the unit tests to cover the rust_bindgen case.

Test: SOONG_GEN_RUST_PROJECT=1 m nothing
Bug: 162881856
Change-Id: Ie736d7ebb115f2c1f9a90be006c972ce24265c6a
2020-08-05 11:29:33 +02:00
Thiébaud Weksteen
9b7b8f169a Fix dependency merging for rust-project.json
Test: SOONG_GEN_RUST_PROJECT=1 m nothing; inspect rust-project.json
Bug: 159591910
Change-Id: I95beb2e75f2306ae2bf2be02ab5f1a348d134b56
2020-08-04 06:36:20 +00:00
Thiébaud Weksteen
e81c924f0c Move getEdition to a baseCompiler method
Test: cd build/soong; mma
Test: cd external/rust/; mma
Change-Id: Ide63b2e633e7c4345c6338e107f5d66688e4cf58
2020-08-03 11:00:43 +02:00
Ivan Lozano
8a23fa4819 [Rust] Remove unused variables and deduplicate.
Bug: 158731826
Test: cd external/rust/crates; mma
Change-Id: I8c9e5cfeaf941b9676b92451b227c15db9a41bbc
2020-06-16 10:28:25 -04:00
Thiébaud Weksteen
e4d12a0468 Add rust-project.json generator
Because we are not relying on Cargo.toml for our crate dependencies,
we need to provide a structured file to rust-analyzer which describes
the locations of the crates. Add a generator for that purpose, similarly
to cc/compdb and cc/ccdeps.

Bug: 156395307
Test: SOONG_GEN_RUST_PROJECT=1 m nothing && \
      cat ${ANDROID_BUILD_TOP}/out/soong/rust-project.json
Change-Id: I46efe0adeddae281eaf86707504c3aa15b5e80b8
2020-06-11 11:22:31 +02:00