Skip to content

Commit

Permalink
Update cargo build-script output format (#374)
Browse files Browse the repository at this point in the history
Update cargo build-script output format to new that actual from rust 1.77
  • Loading branch information
boozook authored Jun 5, 2024
1 parent ba4f857 commit 6392370
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 43 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-sys"
version = "0.4.1"
version = "0.4.2"
build = "src/build.rs"
readme = "README.md"
description = "Low-level Playdate API bindings"
Expand Down
42 changes: 21 additions & 21 deletions api/sys/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const USE_BUILT_BINDINGS: &str = "PD_BUILD_BINDINGS_ONCE";


fn main() {
println!("cargo:rerun-if-env-changed={SDK_PATH_ENV_VAR}");
println!("cargo::rerun-if-env-changed={SDK_PATH_ENV_VAR}");

println!("cargo::rustc-check-cfg=cfg(playdate)");
if matches!(Target::from_env_target(), Ok(Target::Playdate)) {
Expand Down Expand Up @@ -60,7 +60,7 @@ fn main() {
let pdbindgen_found = Runner::find_tool(&cfg);
if cfg!(feature = "bindgen") && pdbindgen_found.is_some() {
println!(
"cargo:warning=Playdate bindgen found but also built as dependency of the {} by enabled feature 'bindgen'. You might want to disable that feature to significantly decrease build time.",
"cargo::warning=Playdate bindgen found but also built as dependency of the {} by enabled feature 'bindgen'. You might want to disable that feature to significantly decrease build time.",
pkg_name
);
// better wording: significantly speed up the compilation process?
Expand All @@ -77,7 +77,7 @@ fn main() {
#[cfg(not(feature = "bindgen"))]
{
let rec = format!("Install it or enable feature 'bindgen' for {pkg_name}.");
println!("cargo:warning=Playdate bindgen executable not found. {rec}");
println!("cargo::warning=Playdate bindgen executable not found. {rec}");
panic!("Unable to find Playdate bindgen executable and feature 'bindgen' disabled, so can't generate bindings.");
}
}
Expand All @@ -97,12 +97,12 @@ fn main() {
panic!("Unable to find Playdate SDK and read its version.");
}
let sdk_version = sdk_version.expect("SDK version");
println!("cargo:rustc-env={BINDINGS_VER_ENV}={}", sdk_version);
println!("cargo::rustc-env={BINDINGS_VER_ENV}={}", sdk_version);


// get filename
let filename = Filename::new(sdk_version, &cfg.derive).expect("output filename");
println!("cargo:rustc-env={BINDINGS_NAME_ENV}={}", filename.to_string());
println!("cargo::rustc-env={BINDINGS_NAME_ENV}={}", filename.to_string());


// determine output path (prebuilt or OUT_DIR)
Expand All @@ -120,7 +120,7 @@ fn main() {
} else {
#[cfg(feature = "bindgen")]
{
println!("cargo:warning=Playdate bindgen exited with error. Trying to build without it.");
println!("cargo::warning=Playdate bindgen exited with error. Trying to build without it.");
return with_builtin_bindgen(cfg);
}

Expand All @@ -139,10 +139,10 @@ fn with_builtin_bindgen(mut cfg: Cfg) {
let generator = bindgen::Generator::new(cfg).expect("Couldn't create bindings generator.");

println!(
"cargo:rustc-env={BINDINGS_NAME_ENV}={}",
"cargo::rustc-env={BINDINGS_NAME_ENV}={}",
generator.filename.to_string()
);
println!("cargo:rustc-env={BINDINGS_VER_ENV}={}", generator.filename.sdk);
println!("cargo::rustc-env={BINDINGS_VER_ENV}={}", generator.filename.sdk);

// determine output path, also check cache/prebuilt:
let out_path = out_path_or_finish_with_prebuilt(&generator.filename);
Expand Down Expand Up @@ -179,12 +179,12 @@ fn use_existing_prebuilt(cfg: &Cfg) {
println!("using pre-built {version}");
let filename = Filename::new(version, &cfg.derive).expect("filename");

println!("cargo:rustc-env={BINDINGS_VER_ENV}={version}");
println!("cargo:rustc-env={BINDINGS_NAME_ENV}={}", filename.to_string());
println!("cargo::rustc-env={BINDINGS_VER_ENV}={version}");
println!("cargo::rustc-env={BINDINGS_NAME_ENV}={}", filename.to_string());

let out_path = out_file_prebuilt(&filename);
println!("cargo:rerun-if-changed={}", out_path.display());
println!("cargo:rustc-env={BINDINGS_PATH_ENV}={}", out_path.display());
println!("cargo::rerun-if-changed={}", out_path.display());
println!("cargo::rustc-env={BINDINGS_PATH_ENV}={}", out_path.display());
assert!(out_path.exists(), "pre-built bindings not found.");
}

Expand All @@ -210,12 +210,12 @@ fn out_path_or_finish_with_prebuilt(filename: &Filename) -> PathBuf {
println!("rebuild pre-built bindings requested");
let out_dir = out_dir_prebuilt();
let out_path = out_dir.join(filename.to_string());
println!("cargo:rerun-if-changed={}", out_path.display());
println!("cargo:warning=Rebuilding `pre-built` bindings");
println!("cargo::rerun-if-changed={}", out_path.display());
println!("cargo::warning=Rebuilding `pre-built` bindings");
if !out_dir.exists() {
std::fs::create_dir_all(&out_dir).unwrap();
println!(
"cargo:warning=OUT_DIR for `pre-built` bindings created: {}",
"cargo::warning=OUT_DIR for `pre-built` bindings created: {}",
out_dir.display()
);
}
Expand All @@ -226,8 +226,8 @@ fn out_path_or_finish_with_prebuilt(filename: &Filename) -> PathBuf {

// cache-hit:
if out_path.exists() {
println!("cargo:rerun-if-changed={}", out_path.display());
println!("cargo:rustc-env={BINDINGS_PATH_ENV}={}", out_path.display());
println!("cargo::rerun-if-changed={}", out_path.display());
println!("cargo::rustc-env={BINDINGS_PATH_ENV}={}", out_path.display());
println!("bindings: cache-hit in pre-built directory");
exit(0);
}
Expand All @@ -239,16 +239,16 @@ fn out_path_or_finish_with_prebuilt(filename: &Filename) -> PathBuf {
let out_dir_reuse_allowed = env::var_os(USE_BUILT_BINDINGS).filter(|s| s == "1" || s == "true")
.is_some();
if out_path.exists() && out_dir_reuse_allowed {
println!("cargo:rerun-if-changed={}", out_path.display());
println!("cargo:rustc-env={BINDINGS_PATH_ENV}={}", out_path.display());
println!("cargo::rerun-if-changed={}", out_path.display());
println!("cargo::rustc-env={BINDINGS_PATH_ENV}={}", out_path.display());
println!("bindings: cache-hit in build directory");
exit(0);
}

println!("bindings: cache-miss, continuing");
out_path
};
println!("cargo:rustc-env={BINDINGS_PATH_ENV}={}", out_path.display());
println!("cargo::rustc-env={BINDINGS_PATH_ENV}={}", out_path.display());


out_path
Expand All @@ -265,7 +265,7 @@ fn is_env_without_sdk() -> bool {
}

fn is_rebuild_prebuilt_requested() -> bool {
println!("cargo:rerun-if-env-changed={BINDINGS_BUILD_PREBUILT}");
println!("cargo::rerun-if-env-changed={BINDINGS_BUILD_PREBUILT}");
env::var_os(BINDINGS_BUILD_PREBUILT).is_some()
}

Expand Down
2 changes: 1 addition & 1 deletion support/addr2line/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-symbolize"
version = "0.1.0"
version = "0.1.1"
readme = "README.md"
description = "Tools for symbolise addresses from bin (pdex.elf) and Playdate's trace or crashlog."
keywords = ["playdate", "bin", "elf", "addr2line", "utility"]
Expand Down
4 changes: 2 additions & 2 deletions support/addr2line/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn main() {
use std::path::PathBuf;
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("symbols.db");
let root = root.canonicalize()
.map_err(|err| println!("cargo:warning={err:#}"))
.map_err(|err| println!("cargo::warning={err:#}"))
.unwrap_or(root);

let src = root.join("src");
Expand All @@ -15,7 +15,7 @@ fn main() {
std::env::set_var("DATABASE_URL", &url);
println!("env var DATABASE_URL has been set to '{url}'.");
if !root.exists() {
println!("cargo:warning=env var DATABASE_URL isn't set and db doesn't exist.");
println!("cargo::warning=env var DATABASE_URL isn't set and db doesn't exist.");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion support/bindgen-cfg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-bindgen-cfg"
version = "0.1.6"
version = "0.1.7"
readme = "README.md"
description = "Minimal configuration for playdate-bindgen."
keywords = ["playdate", "bindings", "ffi", "code-generation"]
Expand Down
4 changes: 2 additions & 2 deletions support/bindgen-cfg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl FromStr for Derive {
"partialeq" => this.partialeq = true,
"partialord" => this.partialord = true,
"constparamty" => this.constparamty = true,
_ => println!("cargo:warning=Unknown derive '{word}'."),
_ => println!("cargo::warning=Unknown derive '{word}'."),
}
}

Expand Down Expand Up @@ -305,7 +305,7 @@ impl FromStr for Features {
for word in s.to_ascii_lowercase().split(',') {
match word {
"documentation" => this.documentation = true,
_ => println!("cargo:warning=Unknown feature '{word}'."),
_ => println!("cargo::warning=Unknown feature '{word}'."),
}
}

Expand Down
2 changes: 1 addition & 1 deletion support/bindgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-bindgen"
version = "0.1.10"
version = "0.1.11"
readme = "README.md"
description = "Bindgen configuration for Playdate API and utils."
keywords = ["playdate", "bindings", "ffi", "code-generation"]
Expand Down
2 changes: 1 addition & 1 deletion support/bindgen/src/gen/docs/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn walk_struct(items: &[Cell<Item>],
field.attrs.push(attr);
} else {
#[cfg(feature = "log")]
println!("cargo:warning=Doc not found for '{key}'");
println!("cargo::warning=Doc not found for '{key}'");
}
},
_ => unimplemented!("unexpected ty: '{}'", quote::quote!(#ty)),
Expand Down
2 changes: 1 addition & 1 deletion support/bindgen/src/gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Bindings {
let output = match crate::rustfmt(None, source.clone(), None) {
Ok(output) => output,
Err(err) => {
println!("cargo:warning=Rustfmt error: {err}");
println!("cargo::warning=Rustfmt error: {err}");

let output: String;
#[cfg(feature = "pretty-please")]
Expand Down
16 changes: 8 additions & 8 deletions support/bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ impl Generator {


fn create_generator(cfg: cfg::Cfg) -> Result<Generator, error::Error> {
println!("cargo:rerun-if-env-changed=TARGET");
println!("cargo::rerun-if-env-changed=TARGET");
let cargo_target_triple = env::var("TARGET").expect("TARGET cargo env var");

println!("cargo:rerun-if-env-changed=PROFILE");
println!("cargo::rerun-if-env-changed=PROFILE");
let cargo_profile = env::var("PROFILE").expect("PROFILE cargo env var");
let is_debug = cargo_profile == "debug" || env_cargo_feature("DEBUG");

Expand All @@ -120,13 +120,13 @@ fn create_generator(cfg: cfg::Cfg) -> Result<Generator, error::Error> {
let version_path = sdk.version_file();
let version_raw = sdk.read_version()?;
let version = check_sdk_version(&version_raw)?;
println!("cargo:rerun-if-changed={}", version_path.display());
println!("cargo::rerun-if-changed={}", version_path.display());
let sdk_c_api = sdk.c_api();

let main_header = sdk_c_api.join("pd_api.h");
println!("cargo:rerun-if-changed={}", main_header.display());
println!("cargo:rerun-if-env-changed={SDK_ENV_VAR}");
println!("cargo:include={}", sdk_c_api.display());
println!("cargo::rerun-if-changed={}", main_header.display());
println!("cargo::rerun-if-env-changed={SDK_ENV_VAR}");
println!("cargo::metadata=include={}", sdk_c_api.display());


// builder:
Expand Down Expand Up @@ -287,8 +287,8 @@ fn apply_profile(mut builder: Builder, debug: bool) -> Builder {
fn apply_target(mut builder: Builder, target: &str, gcc: &ArmToolchain) -> Builder {
builder = if DEVICE_TARGET == target {
let arm_eabi_include = gcc.include();
// println!("cargo:rustc-link-search={}", arm_eabi.join("lib").display()); // for executable
println!("cargo:include={}", arm_eabi_include.display());
// println!("cargo::rustc-link-search={}", arm_eabi.join("lib").display()); // for executable
println!("cargo::metadata=include={}", arm_eabi_include.display());

// TODO: prevent build this for other targets:
// builder = builder.raw_line(format!("#![cfg(target = \"{DEVICE_TARGET}\")]\n\n"));
Expand Down

0 comments on commit 6392370

Please sign in to comment.