@@ -27,25 +27,25 @@ pub struct CrateDependency {
27
27
28
28
#[ derive( Debug , Default , PartialEq , Eq , PartialOrd , Ord , Serialize , Deserialize , Clone ) ]
29
29
#[ serde( default ) ]
30
- pub struct TargetAttributes {
30
+ pub ( crate ) struct TargetAttributes {
31
31
/// The module name of the crate (notably, not the package name).
32
32
//
33
33
// This must be the first field of `TargetAttributes` to make it the
34
34
// lexicographically first thing the derived `Ord` implementation will sort
35
35
// by. The `Ord` impl controls the order of multiple rules of the same type
36
36
// in the same BUILD file. In particular, this makes packages with multiple
37
37
// bin crates generate those `rust_binary` targets in alphanumeric order.
38
- pub crate_name : String ,
38
+ pub ( crate ) crate_name : String ,
39
39
40
40
/// The path to the crate's root source file, relative to the manifest.
41
- pub crate_root : Option < String > ,
41
+ pub ( crate ) crate_root : Option < String > ,
42
42
43
43
/// A glob pattern of all source files required by the target
44
- pub srcs : Glob ,
44
+ pub ( crate ) srcs : Glob ,
45
45
}
46
46
47
47
#[ derive( Debug , PartialEq , Eq , PartialOrd , Ord , Serialize , Deserialize , Clone ) ]
48
- pub enum Rule {
48
+ pub ( crate ) enum Rule {
49
49
/// `rust_library`
50
50
Library ( TargetAttributes ) ,
51
51
@@ -63,58 +63,58 @@ pub enum Rule {
63
63
/// [core rules of `rules_rust`](https://bazelbuild.github.io/rules_rust/defs.html).
64
64
#[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize ) ]
65
65
#[ serde( default ) ]
66
- pub struct CommonAttributes {
66
+ pub ( crate ) struct CommonAttributes {
67
67
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
68
- pub compile_data : Select < BTreeSet < Label > > ,
68
+ pub ( crate ) compile_data : Select < BTreeSet < Label > > ,
69
69
70
70
#[ serde( skip_serializing_if = "BTreeSet::is_empty" ) ]
71
- pub compile_data_glob : BTreeSet < String > ,
71
+ pub ( crate ) compile_data_glob : BTreeSet < String > ,
72
72
73
73
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
74
- pub crate_features : Select < BTreeSet < String > > ,
74
+ pub ( crate ) crate_features : Select < BTreeSet < String > > ,
75
75
76
76
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
77
- pub data : Select < BTreeSet < Label > > ,
77
+ pub ( crate ) data : Select < BTreeSet < Label > > ,
78
78
79
79
#[ serde( skip_serializing_if = "BTreeSet::is_empty" ) ]
80
- pub data_glob : BTreeSet < String > ,
80
+ pub ( crate ) data_glob : BTreeSet < String > ,
81
81
82
82
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
83
- pub deps : Select < BTreeSet < CrateDependency > > ,
83
+ pub ( crate ) deps : Select < BTreeSet < CrateDependency > > ,
84
84
85
85
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
86
- pub extra_deps : Select < BTreeSet < Label > > ,
86
+ pub ( crate ) extra_deps : Select < BTreeSet < Label > > ,
87
87
88
88
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
89
- pub deps_dev : Select < BTreeSet < CrateDependency > > ,
89
+ pub ( crate ) deps_dev : Select < BTreeSet < CrateDependency > > ,
90
90
91
- pub edition : String ,
91
+ pub ( crate ) edition : String ,
92
92
93
93
#[ serde( skip_serializing_if = "Option::is_none" ) ]
94
- pub linker_script : Option < String > ,
94
+ pub ( crate ) linker_script : Option < String > ,
95
95
96
96
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
97
- pub proc_macro_deps : Select < BTreeSet < CrateDependency > > ,
97
+ pub ( crate ) proc_macro_deps : Select < BTreeSet < CrateDependency > > ,
98
98
99
99
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
100
- pub extra_proc_macro_deps : Select < BTreeSet < Label > > ,
100
+ pub ( crate ) extra_proc_macro_deps : Select < BTreeSet < Label > > ,
101
101
102
102
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
103
- pub proc_macro_deps_dev : Select < BTreeSet < CrateDependency > > ,
103
+ pub ( crate ) proc_macro_deps_dev : Select < BTreeSet < CrateDependency > > ,
104
104
105
105
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
106
- pub rustc_env : Select < BTreeMap < String , String > > ,
106
+ pub ( crate ) rustc_env : Select < BTreeMap < String , String > > ,
107
107
108
108
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
109
- pub rustc_env_files : Select < BTreeSet < String > > ,
109
+ pub ( crate ) rustc_env_files : Select < BTreeSet < String > > ,
110
110
111
111
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
112
- pub rustc_flags : Select < Vec < String > > ,
112
+ pub ( crate ) rustc_flags : Select < Vec < String > > ,
113
113
114
- pub version : String ,
114
+ pub ( crate ) version : String ,
115
115
116
116
#[ serde( skip_serializing_if = "Vec::is_empty" ) ]
117
- pub tags : Vec < String > ,
117
+ pub ( crate ) tags : Vec < String > ,
118
118
}
119
119
120
120
impl Default for CommonAttributes {
@@ -147,21 +147,21 @@ impl Default for CommonAttributes {
147
147
// https://bazelbuild.github.io/rules_rust/cargo.html#cargo_build_script
148
148
#[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize ) ]
149
149
#[ serde( default ) ]
150
- pub struct BuildScriptAttributes {
150
+ pub ( crate ) struct BuildScriptAttributes {
151
151
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
152
- pub compile_data : Select < BTreeSet < Label > > ,
152
+ pub ( crate ) compile_data : Select < BTreeSet < Label > > ,
153
153
154
154
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
155
- pub data : Select < BTreeSet < Label > > ,
155
+ pub ( crate ) data : Select < BTreeSet < Label > > ,
156
156
157
157
#[ serde( skip_serializing_if = "BTreeSet::is_empty" ) ]
158
- pub data_glob : BTreeSet < String > ,
158
+ pub ( crate ) data_glob : BTreeSet < String > ,
159
159
160
160
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
161
- pub deps : Select < BTreeSet < CrateDependency > > ,
161
+ pub ( crate ) deps : Select < BTreeSet < CrateDependency > > ,
162
162
163
163
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
164
- pub extra_deps : Select < BTreeSet < Label > > ,
164
+ pub ( crate ) extra_deps : Select < BTreeSet < Label > > ,
165
165
166
166
// TODO: refactor a crate with a build.rs file from two into three bazel
167
167
// rules in order to deduplicate link_dep information. Currently as the
@@ -181,40 +181,40 @@ pub struct BuildScriptAttributes {
181
181
// normal dependencies. This could be handled a special rule, or just using
182
182
// a `filegroup`.
183
183
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
184
- pub link_deps : Select < BTreeSet < CrateDependency > > ,
184
+ pub ( crate ) link_deps : Select < BTreeSet < CrateDependency > > ,
185
185
186
186
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
187
- pub extra_link_deps : Select < BTreeSet < Label > > ,
187
+ pub ( crate ) extra_link_deps : Select < BTreeSet < Label > > ,
188
188
189
189
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
190
- pub build_script_env : Select < BTreeMap < String , String > > ,
190
+ pub ( crate ) build_script_env : Select < BTreeMap < String , String > > ,
191
191
192
192
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
193
- pub rundir : Select < String > ,
193
+ pub ( crate ) rundir : Select < String > ,
194
194
195
195
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
196
- pub extra_proc_macro_deps : Select < BTreeSet < Label > > ,
196
+ pub ( crate ) extra_proc_macro_deps : Select < BTreeSet < Label > > ,
197
197
198
198
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
199
- pub proc_macro_deps : Select < BTreeSet < CrateDependency > > ,
199
+ pub ( crate ) proc_macro_deps : Select < BTreeSet < CrateDependency > > ,
200
200
201
201
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
202
- pub rustc_env : Select < BTreeMap < String , String > > ,
202
+ pub ( crate ) rustc_env : Select < BTreeMap < String , String > > ,
203
203
204
204
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
205
- pub rustc_flags : Select < Vec < String > > ,
205
+ pub ( crate ) rustc_flags : Select < Vec < String > > ,
206
206
207
207
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
208
- pub rustc_env_files : Select < BTreeSet < String > > ,
208
+ pub ( crate ) rustc_env_files : Select < BTreeSet < String > > ,
209
209
210
210
#[ serde( skip_serializing_if = "Select::is_empty" ) ]
211
- pub tools : Select < BTreeSet < Label > > ,
211
+ pub ( crate ) tools : Select < BTreeSet < Label > > ,
212
212
213
213
#[ serde( skip_serializing_if = "Option::is_none" ) ]
214
- pub links : Option < String > ,
214
+ pub ( crate ) links : Option < String > ,
215
215
216
216
#[ serde( skip_serializing_if = "BTreeSet::is_empty" ) ]
217
- pub toolchains : BTreeSet < Label > ,
217
+ pub ( crate ) toolchains : BTreeSet < Label > ,
218
218
}
219
219
220
220
impl Default for BuildScriptAttributes {
@@ -243,77 +243,77 @@ impl Default for BuildScriptAttributes {
243
243
}
244
244
245
245
#[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize ) ]
246
- pub struct CrateContext {
246
+ pub ( crate ) struct CrateContext {
247
247
/// The package name of the current crate
248
- pub name : String ,
248
+ pub ( crate ) name : String ,
249
249
250
250
/// The full version of the current crate
251
- pub version : semver:: Version ,
251
+ pub ( crate ) version : semver:: Version ,
252
252
253
253
/// The package URL of the current crate
254
254
#[ serde( default ) ]
255
- pub package_url : Option < String > ,
255
+ pub ( crate ) package_url : Option < String > ,
256
256
257
257
/// Optional source annotations if they were discoverable in the
258
258
/// lockfile. Workspace Members will not have source annotations and
259
259
/// potentially others.
260
260
#[ serde( default ) ]
261
- pub repository : Option < SourceAnnotation > ,
261
+ pub ( crate ) repository : Option < SourceAnnotation > ,
262
262
263
263
/// A list of all targets (lib, proc-macro, bin) associated with this package
264
264
#[ serde( default ) ]
265
- pub targets : BTreeSet < Rule > ,
265
+ pub ( crate ) targets : BTreeSet < Rule > ,
266
266
267
267
/// The name of the crate's root library target. This is the target that a dependent
268
268
/// would get if they were to depend on `{crate_name}`.
269
269
#[ serde( default ) ]
270
- pub library_target_name : Option < String > ,
270
+ pub ( crate ) library_target_name : Option < String > ,
271
271
272
272
/// A set of attributes common to most [Rule] types or target types.
273
273
#[ serde( default ) ]
274
- pub common_attrs : CommonAttributes ,
274
+ pub ( crate ) common_attrs : CommonAttributes ,
275
275
276
276
/// Optional attributes for build scripts. This field is only populated if
277
277
/// a build script (`custom-build`) target is defined for the crate.
278
278
#[ serde( skip_serializing_if = "Option::is_none" ) ]
279
279
#[ serde( default ) ]
280
- pub build_script_attrs : Option < BuildScriptAttributes > ,
280
+ pub ( crate ) build_script_attrs : Option < BuildScriptAttributes > ,
281
281
282
282
/// The license used by the crate
283
283
#[ serde( default ) ]
284
- pub license : Option < String > ,
284
+ pub ( crate ) license : Option < String > ,
285
285
286
286
/// The SPDX licence IDs
287
287
/// #[serde(default)]
288
- pub license_ids : BTreeSet < String > ,
288
+ pub ( crate ) license_ids : BTreeSet < String > ,
289
289
290
290
/// The license file
291
291
#[ serde( default ) ]
292
- pub license_file : Option < String > ,
292
+ pub ( crate ) license_file : Option < String > ,
293
293
294
294
/// Additional text to add to the generated BUILD file.
295
295
#[ serde( skip_serializing_if = "Option::is_none" ) ]
296
296
#[ serde( default ) ]
297
- pub additive_build_file_content : Option < String > ,
297
+ pub ( crate ) additive_build_file_content : Option < String > ,
298
298
299
299
/// If true, disables pipelining for library targets generated for this crate
300
300
#[ serde( skip_serializing_if = "std::ops::Not::not" ) ]
301
301
#[ serde( default ) ]
302
- pub disable_pipelining : bool ,
302
+ pub ( crate ) disable_pipelining : bool ,
303
303
304
304
/// Extra targets that should be aliased.
305
305
#[ serde( skip_serializing_if = "BTreeMap::is_empty" ) ]
306
306
#[ serde( default ) ]
307
- pub extra_aliased_targets : BTreeMap < String , String > ,
307
+ pub ( crate ) extra_aliased_targets : BTreeMap < String , String > ,
308
308
309
309
/// Transition rule to use instead of `alias`.
310
310
#[ serde( skip_serializing_if = "Option::is_none" ) ]
311
311
#[ serde( default ) ]
312
- pub alias_rule : Option < AliasRule > ,
312
+ pub ( crate ) alias_rule : Option < AliasRule > ,
313
313
}
314
314
315
315
impl CrateContext {
316
- pub fn new (
316
+ pub ( crate ) fn new (
317
317
annotation : & CrateAnnotation ,
318
318
packages : & BTreeMap < PackageId , Package > ,
319
319
source_annotations : & BTreeMap < PackageId , SourceAnnotation > ,
0 commit comments