• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2023 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/ohos.gni")
15
16ohos_cargo_crate("target") {
17  crate_name = "test_rlib_crate"
18  crate_root = "crate/src/lib.rs"
19  sources = [ "crate/src/lib.rs" ]
20
21  #To generate the build_script binary
22  build_root = "crate/build.rs"
23  build_sources = [ "crate/build.rs" ]
24  build_script_outputs = [ "generated/generated.rs" ]
25
26  features = [
27    "my-feature_a",
28    "my-feature_b",
29    "std",
30  ]
31  rustflags = [
32    "--cfg",
33    "test_a_and_b",
34  ]
35  rustenv = [ "ENV_VAR_FOR_BUILD_SCRIPT=45" ]
36}
37
38# Exists to test the case that a single crate has both a library and a binary
39ohos_cargo_crate("test_rlib_crate_associated_bin") {
40  crate_root = "crate/src/main.rs"
41  crate_type = "bin"
42  sources = [ "crate/src/main.rs" ]
43
44  #To generate the build_script binary
45  build_root = "crate/build.rs"
46  build_sources = [ "crate/build.rs" ]
47  features = [
48    "my-feature_a",
49    "my-feature_b",
50    "std",
51  ]
52  rustenv = [ "ENV_VAR_FOR_BUILD_SCRIPT=45" ]
53  deps = [ ":target" ]
54}
55