@@ -94,7 +94,7 @@ impl BuildScriptOutput {
94
94
}
95
95
96
96
/// Converts a [BufReader] into a vector of [BuildScriptOutput] enums.
97
- fn from_reader < T : Read > ( mut reader : BufReader < T > ) -> Vec < BuildScriptOutput > {
97
+ fn outputs_from_reader < T : Read > ( mut reader : BufReader < T > ) -> Vec < BuildScriptOutput > {
98
98
let mut result = Vec :: < BuildScriptOutput > :: new ( ) ;
99
99
let mut line = String :: new ( ) ;
100
100
while reader. read_line ( & mut line) . expect ( "Cannot read line" ) != 0 {
@@ -107,20 +107,23 @@ impl BuildScriptOutput {
107
107
}
108
108
109
109
/// Take a [Command], execute it and converts its input into a vector of [BuildScriptOutput]
110
- pub fn from_command ( cmd : & mut Command ) -> Result < ( Vec < BuildScriptOutput > , Output ) , Output > {
110
+ pub fn outputs_from_command (
111
+ cmd : & mut Command ,
112
+ ) -> Result < ( Vec < BuildScriptOutput > , Output ) , Output > {
111
113
let child_output = cmd. output ( ) . expect ( "Unable to start binary" ) ;
112
114
if child_output. status . success ( ) {
113
115
let reader = BufReader :: new ( child_output. stdout . as_slice ( ) ) ;
114
- let output = Self :: from_reader ( reader) ;
116
+ let output = Self :: outputs_from_reader ( reader) ;
115
117
Ok ( ( output, child_output) )
116
118
} else {
117
119
Err ( child_output)
118
120
}
119
121
}
120
122
121
123
/// Convert a vector of [BuildScriptOutput] into a list of environment variables.
122
- pub fn to_env ( v : & Vec < BuildScriptOutput > , exec_root : & str ) -> String {
123
- v. iter ( )
124
+ pub fn outputs_to_env ( outputs : & [ BuildScriptOutput ] , exec_root : & str ) -> String {
125
+ outputs
126
+ . iter ( )
124
127
. filter_map ( |x| {
125
128
if let BuildScriptOutput :: Env ( env) = x {
126
129
Some ( Self :: escape_for_serializing ( Self :: redact_exec_root (
@@ -135,9 +138,14 @@ impl BuildScriptOutput {
135
138
}
136
139
137
140
/// Convert a vector of [BuildScriptOutput] into a list of dependencies environment variables.
138
- pub fn to_dep_env ( v : & Vec < BuildScriptOutput > , crate_links : & str , exec_root : & str ) -> String {
141
+ pub fn outputs_to_dep_env (
142
+ outputs : & [ BuildScriptOutput ] ,
143
+ crate_links : & str ,
144
+ exec_root : & str ,
145
+ ) -> String {
139
146
let prefix = format ! ( "DEP_{}_" , crate_links. replace( "-" , "_" ) . to_uppercase( ) ) ;
140
- v. iter ( )
147
+ outputs
148
+ . iter ( )
141
149
. filter_map ( |x| {
142
150
if let BuildScriptOutput :: DepEnv ( env) = x {
143
151
Some ( format ! (
@@ -154,11 +162,11 @@ impl BuildScriptOutput {
154
162
}
155
163
156
164
/// Convert a vector of [BuildScriptOutput] into a flagfile.
157
- pub fn to_flags ( v : & Vec < BuildScriptOutput > , exec_root : & str ) -> CompileAndLinkFlags {
165
+ pub fn outputs_to_flags ( outputs : & [ BuildScriptOutput ] , exec_root : & str ) -> CompileAndLinkFlags {
158
166
let mut compile_flags = Vec :: new ( ) ;
159
167
let mut link_flags = Vec :: new ( ) ;
160
168
161
- for flag in v {
169
+ for flag in outputs {
162
170
match flag {
163
171
BuildScriptOutput :: Cfg ( e) => compile_flags. push ( format ! ( "--cfg={}" , e) ) ,
164
172
BuildScriptOutput :: Flags ( e) => compile_flags. push ( e. to_owned ( ) ) ,
@@ -214,7 +222,7 @@ cargo:rustc-env=SOME_PATH=/some/absolute/path/beep
214
222
" ,
215
223
) ;
216
224
let reader = BufReader :: new ( buff) ;
217
- let result = BuildScriptOutput :: from_reader ( reader) ;
225
+ let result = BuildScriptOutput :: outputs_from_reader ( reader) ;
218
226
assert_eq ! ( result. len( ) , 10 ) ;
219
227
assert_eq ! ( result[ 0 ] , BuildScriptOutput :: LinkLib ( "sdfsdf" . to_owned( ) ) ) ;
220
228
assert_eq ! ( result[ 1 ] , BuildScriptOutput :: Env ( "FOO=BAR" . to_owned( ) ) ) ;
@@ -242,15 +250,15 @@ cargo:rustc-env=SOME_PATH=/some/absolute/path/beep
242
250
) ;
243
251
244
252
assert_eq ! (
245
- BuildScriptOutput :: to_dep_env ( & result, "ssh2" , "/some/absolute/path" ) ,
253
+ BuildScriptOutput :: outputs_to_dep_env ( & result, "ssh2" , "/some/absolute/path" ) ,
246
254
"DEP_SSH2_VERSION=123\n DEP_SSH2_VERSION_NUMBER=1010107f\n DEP_SSH2_INCLUDE_PATH=${pwd}/include" . to_owned( )
247
255
) ;
248
256
assert_eq ! (
249
- BuildScriptOutput :: to_env ( & result, "/some/absolute/path" ) ,
257
+ BuildScriptOutput :: outputs_to_env ( & result, "/some/absolute/path" ) ,
250
258
"FOO=BAR\n BAR=FOO\n SOME_PATH=${pwd}/beep" . to_owned( )
251
259
) ;
252
260
assert_eq ! (
253
- BuildScriptOutput :: to_flags ( & result, "/some/absolute/path" ) ,
261
+ BuildScriptOutput :: outputs_to_flags ( & result, "/some/absolute/path" ) ,
254
262
CompileAndLinkFlags {
255
263
// -Lblah was output as a rustc-flags, so even though it probably _should_ be a link
256
264
// flag, we don't treat it like one.
0 commit comments