# Copyright 2021 The Chromium Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import("//build/rust/cargo_crate.gni") cargo_crate("target1") { crate_name = "test_rlib_crate" crate_root = "crate/src/lib.rs" sources = [ "crate/src/lib.rs" ] build_sources = [ "crate/build.rs" ] build_root = "crate/build.rs" build_script_inputs = [ "crate/build.rs" ] build_script_outputs = [ "generated/generated.rs" ] epoch = "0.2" features = [ "my-feature_a", "my-feature_b", ] rustflags = [ "--cfg", "test_a_and_b", ] rustenv = [ "ENV_VAR_FOR_BUILD_SCRIPT=42" ] } # Test that we can build the same crate in multiple ways under different GN # rules without conflicts. cargo_crate("target2") { crate_name = "test_rlib_crate" crate_root = "crate/src/lib.rs" sources = [ "crate/src/lib.rs" ] build_sources = [ "crate/build.rs" ] build_root = "crate/build.rs" build_script_inputs = [ "crate/build.rs" ] build_script_outputs = [ "generated/generated.rs" ] epoch = "0.2" features = [ "my-feature_a" ] rustenv = [ "ENV_VAR_FOR_BUILD_SCRIPT=42" ] } # Exists to test the case that a single crate has both a library # and a binary, to ensure that shared build products (e.g. the # build script) don't conflict. cargo_crate("test_rlib_crate_associated_bin") { crate_root = "crate/src/main.rs" crate_type = "bin" sources = [ "crate/src/main.rs" ] build_sources = [ "crate/build.rs" ] build_root = "crate/build.rs" build_script_inputs = [ "crate/build.rs" ] features = [ "my-feature_a", "my-feature_b", ] rustenv = [ "ENV_VAR_FOR_BUILD_SCRIPT=42" ] deps = [ ":target1" ] }