xref: /aosp_15_r20/external/bazelbuild-rules_rust/test/dep_env/BUILD.bazel (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1*d4726bddSHONG Yifan"""Tests for passing configuration to cargo_build_script rules"""
2*d4726bddSHONG Yifan
3*d4726bddSHONG Yifanload("//cargo:defs.bzl", "cargo_build_script", "cargo_dep_env")
4*d4726bddSHONG Yifanload("//rust:defs.bzl", "rust_library", "rust_test")
5*d4726bddSHONG Yifanload(":dep_env.bzl", "create_dep_dir")
6*d4726bddSHONG Yifan
7*d4726bddSHONG Yifancargo_build_script(
8*d4726bddSHONG Yifan    name = "set_a_build",
9*d4726bddSHONG Yifan    srcs = ["set_a.rs"],
10*d4726bddSHONG Yifan    edition = "2018",
11*d4726bddSHONG Yifan    links = "X",
12*d4726bddSHONG Yifan)
13*d4726bddSHONG Yifan
14*d4726bddSHONG Yifancargo_build_script(
15*d4726bddSHONG Yifan    name = "set_c_build",
16*d4726bddSHONG Yifan    srcs = ["set_c.rs"],
17*d4726bddSHONG Yifan    edition = "2018",
18*d4726bddSHONG Yifan    link_deps = [":set_a"],
19*d4726bddSHONG Yifan    links = "Y",
20*d4726bddSHONG Yifan)
21*d4726bddSHONG Yifan
22*d4726bddSHONG Yifanrust_library(
23*d4726bddSHONG Yifan    name = "set_a",
24*d4726bddSHONG Yifan    srcs = ["empty.rs"],
25*d4726bddSHONG Yifan    edition = "2018",
26*d4726bddSHONG Yifan    deps = [":set_a_build"],
27*d4726bddSHONG Yifan)
28*d4726bddSHONG Yifan
29*d4726bddSHONG Yifancargo_dep_env(
30*d4726bddSHONG Yifan    name = "set_b",
31*d4726bddSHONG Yifan    src = "set_b.env",
32*d4726bddSHONG Yifan)
33*d4726bddSHONG Yifan
34*d4726bddSHONG Yifanrust_library(
35*d4726bddSHONG Yifan    name = "set_c",
36*d4726bddSHONG Yifan    srcs = ["empty.rs"],
37*d4726bddSHONG Yifan    edition = "2018",
38*d4726bddSHONG Yifan    deps = [
39*d4726bddSHONG Yifan        ":set_a",
40*d4726bddSHONG Yifan        ":set_c_build",
41*d4726bddSHONG Yifan    ],
42*d4726bddSHONG Yifan)
43*d4726bddSHONG Yifan
44*d4726bddSHONG Yifancargo_build_script(
45*d4726bddSHONG Yifan    name = "read_a",
46*d4726bddSHONG Yifan    srcs = ["read_a.rs"],
47*d4726bddSHONG Yifan    edition = "2018",
48*d4726bddSHONG Yifan    link_deps = [":set_a"],
49*d4726bddSHONG Yifan)
50*d4726bddSHONG Yifan
51*d4726bddSHONG Yifancargo_build_script(
52*d4726bddSHONG Yifan    name = "read_b",
53*d4726bddSHONG Yifan    srcs = ["read_b.rs"],
54*d4726bddSHONG Yifan    edition = "2018",
55*d4726bddSHONG Yifan    link_deps = [":set_b"],
56*d4726bddSHONG Yifan)
57*d4726bddSHONG Yifan
58*d4726bddSHONG Yifancargo_build_script(
59*d4726bddSHONG Yifan    name = "read_c",
60*d4726bddSHONG Yifan    srcs = ["read_c.rs"],
61*d4726bddSHONG Yifan    edition = "2018",
62*d4726bddSHONG Yifan    link_deps = [":set_c"],
63*d4726bddSHONG Yifan    deps = [":set_a"],
64*d4726bddSHONG Yifan)
65*d4726bddSHONG Yifan
66*d4726bddSHONG Yifancargo_build_script(
67*d4726bddSHONG Yifan    name = "read_dep_dir",
68*d4726bddSHONG Yifan    srcs = ["read_dep_dir.rs"],
69*d4726bddSHONG Yifan    edition = "2018",
70*d4726bddSHONG Yifan    link_deps = [":set_dep_dir"],
71*d4726bddSHONG Yifan)
72*d4726bddSHONG Yifan
73*d4726bddSHONG Yifanrust_test(
74*d4726bddSHONG Yifan    name = "build_read_a",
75*d4726bddSHONG Yifan    srcs = ["read_a.rs"],
76*d4726bddSHONG Yifan    edition = "2018",
77*d4726bddSHONG Yifan    deps = [":read_a"],
78*d4726bddSHONG Yifan)
79*d4726bddSHONG Yifan
80*d4726bddSHONG Yifanrust_test(
81*d4726bddSHONG Yifan    name = "build_read_b",
82*d4726bddSHONG Yifan    srcs = ["read_b.rs"],
83*d4726bddSHONG Yifan    edition = "2018",
84*d4726bddSHONG Yifan    deps = [":read_b"],
85*d4726bddSHONG Yifan)
86*d4726bddSHONG Yifan
87*d4726bddSHONG Yifanrust_test(
88*d4726bddSHONG Yifan    name = "build_read_c",
89*d4726bddSHONG Yifan    srcs = ["read_c.rs"],
90*d4726bddSHONG Yifan    edition = "2018",
91*d4726bddSHONG Yifan    deps = [":read_c"],
92*d4726bddSHONG Yifan)
93*d4726bddSHONG Yifan
94*d4726bddSHONG Yifanrust_test(
95*d4726bddSHONG Yifan    name = "build_read_dep_dir",
96*d4726bddSHONG Yifan    srcs = ["read_dep_dir.rs"],
97*d4726bddSHONG Yifan    edition = "2018",
98*d4726bddSHONG Yifan    deps = [":read_dep_dir"],
99*d4726bddSHONG Yifan)
100*d4726bddSHONG Yifan
101*d4726bddSHONG Yifancreate_dep_dir(
102*d4726bddSHONG Yifan    name = "dep_dir",
103*d4726bddSHONG Yifan)
104*d4726bddSHONG Yifan
105*d4726bddSHONG Yifancargo_dep_env(
106*d4726bddSHONG Yifan    name = "set_dep_dir",
107*d4726bddSHONG Yifan    src = "set_dep_dir.env",
108*d4726bddSHONG Yifan    out_dir = "dep_dir",
109*d4726bddSHONG Yifan)
110*d4726bddSHONG Yifan
111*d4726bddSHONG Yifangenrule(
112*d4726bddSHONG Yifan    name = "gen_set_dep_dir",
113*d4726bddSHONG Yifan    srcs = ["dep_dir"],
114*d4726bddSHONG Yifan    outs = ["set_dep_dir.env"],
115*d4726bddSHONG Yifan    cmd = "echo DEP_DIR=\\$${pwd}/$(execpath dep_dir) > $@",
116*d4726bddSHONG Yifan)
117