diff options
author | ThiƩbaud Weksteen <tweek@google.com> | 2021-04-07 14:53:06 +0200 |
---|---|---|
committer | ThiƩbaud Weksteen <tweek@google.com> | 2021-04-07 15:04:10 +0200 |
commit | c44e7372ed80d334baa0bd51039ccc403e0b7c5b (patch) | |
tree | 60afb0fc91409d552ebc297d241c709556c8ce8e /rust/compiler_test.go | |
parent | da42a5a2096fd2a9800d16b8a0156e629e11034b (diff) |
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
Diffstat (limited to 'rust/compiler_test.go')
-rw-r--r-- | rust/compiler_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/rust/compiler_test.go b/rust/compiler_test.go index c75276239..5ca9e7f35 100644 --- a/rust/compiler_test.go +++ b/rust/compiler_test.go @@ -42,6 +42,27 @@ func TestFeaturesToFlags(t *testing.T) { } } +// Test that cfgs flags are being correctly generated. +func TestCfgsToFlags(t *testing.T) { + ctx := testRust(t, ` + rust_library_host { + name: "libfoo", + srcs: ["foo.rs"], + crate_name: "foo", + cfgs: [ + "std", + "cfg1=\"one\"" + ], + }`) + + libfooDylib := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_dylib").Rule("rustc") + + if !strings.Contains(libfooDylib.Args["rustcFlags"], "cfg 'std'") || + !strings.Contains(libfooDylib.Args["rustcFlags"], "cfg 'cfg1=\"one\"'") { + t.Fatalf("missing std and cfg1 flags for libfoo dylib, rustcFlags: %#v", libfooDylib.Args["rustcFlags"]) + } +} + // Test that we reject multiple source files. func TestEnforceSingleSourceFile(t *testing.T) { |