aboutsummaryrefslogtreecommitdiff
path: root/rust/compiler_test.go
Commit message (Collapse)AuthorAgeFilesLines
* rust: internalize srcPathFromModuleSrcsMatthew Maurer2023-11-221-1/+2
| | | | | | | | | | | | This was frequently misused (for example, in the prebuilts module, it was used as a complex "assert(len(srcs))==1"), and can be superceded by getCrateRoot anywhere it was used. It's now only called from compiler.go, and can drop the second return parameter, as it was only actually used by the prebuilt assert misuse. Bug: 309943184 Test: m nothing Change-Id: I6c92580bc8f0ecb7586c544056b5409e6dd280e7
* Revert "support sandboxed rust rules"Wen-yi Chu2023-09-221-15/+15
| | | | | | | | | | Revert submission 2629131-sandbox-rust-inputs Reason for revert: Fail on android build. Reverted changes: /q/submissionid:2629131-sandbox-rust-inputs Change-Id: Ifd9aa46e80a12d8f4ffa0a2daa74b96727cbb7e6
* support sandboxed rust rulesSam Delmerico2023-09-151-15/+15
| | | | | | | | | | | This commit adds support for compiling rust rules inside the sbox sandbox. To compile a rust module with sandboxing enabled, the entry point to the crate must be specified via the `crate_root` property, and all input sources and compile-time data must be specified via the `srcs` and `compile_data` properties. Bug: 286077158 Change-Id: I8c9dc5cf7578037a583b4be2e2f73cf20ffd4408
* Flag an error on empty rust module srcsSeth Moore2021-10-141-0/+35
| | | | | | | | | | | It's an error if a rust module's srcs is empty. Prior to this change the output was a panic that complains loudly about a slice error and nothing else. This change doesn't stop the panic, but at least adds a bit of context so devs who make a simple mistake can more easily fix it. Test: SOONG_GEN_RUST_PROJECT=1 m nothing Change-Id: Id7d8465d533413c3000699661222a53a7c8678f3
* rust: Add support to emit certain Cargo env vars.Ivan Lozano2021-08-121-0/+24
| | | | | | | | | | | Some crates expect Cargo to provide certain environment variables. This CL adds a compatability flag that emulates the behavior of Cargo by setting these environment variables when building. Bug: 171011485 Test: New soong tests pass Test: quiche no longer requires patch removing CARGO_PKG_VERSION Change-Id: I4c95c284846f6075428c6f61fe8c260f2e35fbd9
* rust: Prevent manually defined lib link flags.Ivan Lozano2021-07-271-0/+70
| | | | | | | | | | Adds a filter to prevent modules from manually defining certain linkage flags. These flags should only be automatically generated based on listed dependencies. Bug: 161942165 Test: Soong tests pass Change-Id: Ibc014391ef1de10188c2d139d41d0241d6c68b5f
* rust: Add cfgs propertyThiƩbaud Weksteen2021-04-071-0/+21
| | | | | | | | | | 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
* Convert remaining rust tests to use test fixturesPaul Duffin2021-03-301-32/+13
| | | | | | | | | | Removes now unused CreateTestContext and stops exporting the RegisterRequiredBuildComponentsForTest() method as it is only used locally. Bug: 181070625 Test: m nothing Change-Id: Ia2fd3e090f975ee4c807da2c6c162ef3cf7ac446
* Support test fixtures in rust packagePaul Duffin2021-03-231-1/+1
| | | | | | | | | | | | 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
* rust modules can be included in apexJiyong Park2020-11-301-0/+2
| | | | | | | | | | | | | | 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
* Pass Config to NewTestContext instead of ctx.RegisterColin Cross2020-11-121-2/+2
| | | | | | | | | | | 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
* Revert "Make lots of tests run in parallel"Colin Cross2020-10-091-5/+0
| | | | | | | | | | This reverts commit 323dc60712491c71ccdc5363c42df61f0a192487. Reason for revert: Possible cause of test instability Bug: 170513220 Test: soong tests Change-Id: Iee168e9fbb4210569e6cffcc23e60d111403abb8
* Make lots of tests run in parallelColin Cross2020-10-061-0/+5
| | | | | | | | | | 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
* rust: Add libstd linkage mutator for rlibs.Ivan Lozano2020-09-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | The current state of linkage is that device targets always link libstd dynamically except for rust_ffi_static which requires a static libstd linkage. However this prevents producing rust_ffi_static modules which depend on other Rust libraries as those dependencies will link libstd dynamically and cause a collision. We also want our rust_test modules to statically link in libstd as well. This adds a linkage mutator for rlibs that creates a variant for each libstd linkage. Dependent modules can then select the variant that matches their linkage of libstd. Also fixes an issue where installation paths were being generated for rlibs and static libs even though they weren't being installed. This broke when adding the linkage mutator as Make would complain about multiple targets producing the same output. Bug: 168729404 Test: rust_ffi_static module with other rustlib dependency can be built. Change-Id: I955b484bf5809e8fc5517750c7f8df82d3ca8895
* Link device binaries dynamically by default.Ivan Lozano2020-08-251-0/+27
| | | | | | | | | | | | | | | Device binaries currently are linked statically by default. Instead we should be linking these dynamic by default. To avoid conflicts when manually specifying rlib dependencies on modules, we always link libstd dynamically for all device modules except static libraries. This removes the "prefer_dynamic" property entirely to avoid confusion. Bug: 165161105 Test: m profcollectd is built dynamically. Test: cd external/rust/; mma Test: cd external/crosvm/; mma Change-Id: I25ac897040acbcc2d97c791a33e8e01610632272
* rust: modify linting propertiesThiƩbaud Weksteen2020-08-131-0/+73
| | | | | | | | | | | | Move the linting properties to an enum with 4 possible options: "default", "android", "vendor" or "none". The previous logic for default, based on the module's location, is kept. It is now possible to force the upgrade to a certain lint level for some modules (e.g. external/[...]/android). Update the unit tests and documentation. Bug: 163400111 Test: m Change-Id: I8e464b04401158ed2d3c518a9b72f145a9835c99
* Allow rust module dependency on SourceProviders.Ivan Lozano2020-07-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Allow rust modules to depend on and use generated source code provided by SourceProvider modules and genrule modules without resorting to hardcoded output paths. All generated sources are now copied to a dependent module's intermediates directory, then OUT_DIR is set to point to that path when calling rustc. This matches the common convention used in most rust crates to include generated source code from the path defined in the OUT_DIR environment variable. A couple other small notable changes are included in this CL: * prebuiltLibraries can no longer include generated source files as they should be prebuilt. * srcPathFromModuleSrcs now excludes the main source file from the second return value so its a list of only the generated sources. Bug: 159064919 Test: Local example rust_library compiles with rust_bindgen dependency. Test: Local example rust_library compiles with genrule dependency. Test: Collision detected when multiple providers produce similar output. Test: New Soong tests pass. Change-Id: I59f54a25368c680b9086420c47ec24ab8cd1de6b
* Specify module dependency in the srcs listChih-Hung Hsieh2020-07-081-1/+1
| | | | | | | | | | | | * "srcs" list contains one main Rust source file, followed by optional dependent modules. * A dependent module included in the "srcs" list is the module name prefixed with ":". * Add a simple test. Bug: 160331255 Test: make and manual test build dependencies on genrule modules Change-Id: I4f079138c2599158810b6412fce81b612a3f64a4
* Test for rust install path regressions.Ivan Lozano2020-04-291-0/+30
| | | | | | Bug: 153423714 Test: Soong tests pass. Change-Id: Ica4d2c7e47f1c325fa387a91f6c476dfa4f93710
* Fix proc_macro dependency handling.Ivan Lozano2019-09-241-1/+0
| | | | | | | | | | | | | Currently proc_macros don't pull in the correct arch dependencies when the host arch differs from the target arch. This fixes how proc_macro dependencies are handled by defining them as always being host-only and including them as dependencies for device-modules by using AddFarVariationDependencies. Bug: 141491501 Test: Example device rust module builds with proc_macro dependency. Change-Id: Ic037dc406ce90526f8b68c92fffc0d93a498a4ff
* Add Rust support to Soong.Ivan Lozano2019-08-281-0/+77
Adds support to Soong for building rust modules. This currently only supports x86_64 device and x86 linux host targets. The functionality is sufficient to build crosvm. Bug: 136189233 Test: Test module builds. Test: crosvm builds. Change-Id: I6ea04615834a6d673578ab10ea1a2eb04259fe09