Skip to content

Commit 01d3ac0

Browse files
committed
Improve cargo build warning messages
Prefix with shaderc to make it clear and also make them consistent.
1 parent 164ed9c commit 01d3ac0

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

shaderc-sys/build/build.rs

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fn main() {
130130
// Initialize explicit libshaderc search directory first
131131
let mut search_dir = if let Ok(lib_dir) = env::var("SHADERC_LIB_DIR") {
132132
println!(
133-
"cargo:warning=Specified {} to search for shaderc libraries",
133+
"cargo:warning=shaderc: searching native shaderc libraries in '{}'",
134134
lib_dir
135135
);
136136
Some(lib_dir)
@@ -142,8 +142,8 @@ fn main() {
142142
// source, check known locations before falling back to from-source-build
143143
if search_dir.is_none() && target_os == "linux" && !config_build_from_source {
144144
println!(
145-
"cargo:warning=Checking for system installed libraries. \
146-
Use --features = build-from-source to disable this behavior"
145+
"cargo:warning=shaderc: searching for native shaderc libraries on system; \
146+
use '--features build-from-source' to force building from source code"
147147
);
148148

149149
// https://wiki.ubuntu.com/MultiarchSpec
@@ -174,18 +174,21 @@ fn main() {
174174
let cannonical = fs::canonicalize(&path);
175175
if path.is_relative() {
176176
println!(
177-
"cargo:warning=Provided path {:?} is relative. Path must be \
178-
relative to shaderc-sys crate, possibly not your current \
179-
working directory",
177+
"cargo:warning=shaderc: the given search path '{:?}' is relative; \
178+
path must be relative to shaderc-sys crate, \
179+
likely not your current working directory",
180180
&path
181181
);
182182
} else if !path.is_dir() {
183-
println!("cargo:warning=Provided path {:?} is not a directory", &path);
183+
println!(
184+
"cargo:warning=shaderc: the given search path '{:?}' is not a directory",
185+
&path
186+
);
184187
}
185188
if (cannonical.is_err()) && explicit_lib_dir_set {
186-
println!("cargo:warning={:?}", cannonical.err().unwrap());
189+
println!("cargo:warning=shaderc: {:?}", cannonical.err().unwrap());
187190
println!(
188-
"cargo:warning=Provided path {:?} could not be canonicallized",
191+
"cargo:warning=shaderc: failed to canonicalize the given search path '{:?}'",
189192
&path
190193
);
191194
None
@@ -236,17 +239,19 @@ fn main() {
236239

237240
match (spirv_tools_lib, spirv_tools_opt_lib, spirv_lib, glslang_lib) {
238241
(Some(spirv_tools), Some(spirv_tools_opt), Some(spirv), Some(glslang)) => {
239-
println!("cargo:warning=Found and linking system installed Glslang and SPIRV-Tools libraries.");
242+
println!(
243+
"cargo:warning=shaderc: found and linking glslang and spirv-tools \
244+
libraries installed on system"
245+
);
240246
println!("cargo:rustc-link-lib={}=glslang", glslang);
241247
println!("cargo:rustc-link-lib={}=SPIRV", spirv);
242248
println!("cargo:rustc-link-lib={}=SPIRV-Tools", spirv_tools);
243249
println!("cargo:rustc-link-lib={}=SPIRV-Tools-opt", spirv_tools_opt);
244250
}
245251
_ => {
246252
println!(
247-
"cargo:warning=Only shaderc library found. \
248-
Assuming libraries it depends on are built into \
249-
the shaderc library."
253+
"cargo:warning=shaderc: only found the shaderc library; \
254+
assuming libraries it depends on are built into the shaderc library."
250255
);
251256
}
252257
}
@@ -255,45 +260,48 @@ fn main() {
255260
return;
256261
}
257262
("windows", "msvc") => {
258-
println!("cargo:warning=Windows MSVC static builds experimental");
263+
println!("cargo:warning=shaderc: Windows MSVC static build is experimental");
259264
println!("cargo:rustc-link-search=native={}", search_dir_str);
260265
println!("cargo:rustc-link-lib={}={}", kind, lib_name);
261266
return;
262267
}
263268
("windows", "gnu") => {
264-
println!("cargo:warning=Windows MinGW static builds experimental");
269+
println!("cargo:warning=shaderc: Windows MinGW static build is experimental");
265270
println!("cargo:rustc-link-search=native={}", search_dir_str);
266271
println!("cargo:rustc-link-lib={}={}", kind, lib_name);
267272
println!("cargo:rustc-link-lib=dylib=stdc++");
268273
return;
269274
}
270275
("macos", _) => {
271-
println!("cargo:warning=MacOS static builds experimental");
276+
println!("cargo:warning=shaderc: macOS static build is experimental");
272277
println!("cargo:rustc-link-search=native={}", search_dir_str);
273278
println!("cargo:rustc-link-lib={}={}", kind, lib_name);
274279
println!("cargo:rustc-link-lib=dylib=c++");
275280
return;
276281
}
277282
("ios", _) => {
278-
println!("cargo:warning=MacOS static builds experimental");
283+
println!("cargo:warning=shaderc: macOS static build is experimental");
279284
println!("cargo:rustc-link-search=native={}", search_dir_str);
280285
println!("cargo:rustc-link-lib={}={}", kind, lib_name);
281286
println!("cargo:rustc-link-lib=dylib=c++");
282287
return;
283288
}
284289
(_, _) => {
285-
println!("cargo:warning=Platform unsupported for linking against system installed shaderc libraries");
290+
println!(
291+
"cargo:warning=shaderc: unsupported platform for linking against \
292+
native shaderc libraries installed on system"
293+
);
286294
}
287295
}
288296
}
289297
}
290298

291299
if config_build_from_source {
292-
println!("cargo:warning=Requested to build from source");
300+
println!("cargo:warning=shaderc: requested to build from source");
293301
} else {
294302
println!(
295-
"cargo:warning=System installed library not found. Falling back \
296-
to build from source"
303+
"cargo:warning=shaderc: cannot find native shaderc library on system; \
304+
falling back to build from source"
297305
);
298306
}
299307

0 commit comments

Comments
 (0)