Verify the current tree is publish-able to crates.io. The intention here is that we'll run `cargo package` on everything which verifies the build as-if it were published to crates.io. This requires using an incrementally-built directory registry generated from `cargo vendor` because the versions referenced from `Cargo.toml` may not exist on crates.io.
(crates: &[Crate])
| 490 | // directory registry generated from `cargo vendor` because the versions |
| 491 | // referenced from `Cargo.toml` may not exist on crates.io. |
| 492 | fn verify(crates: &[Crate]) { |
| 493 | verify_capi(); |
| 494 | |
| 495 | if Path::new(".cargo").exists() { |
| 496 | panic!( |
| 497 | "`.cargo` already exists on the file system, remove it and then run the script again" |
| 498 | ); |
| 499 | } |
| 500 | if Path::new("vendor").exists() { |
| 501 | panic!( |
| 502 | "`vendor` already exists on the file system, remove it and then run the script again" |
| 503 | ); |
| 504 | } |
| 505 | |
| 506 | let vendor = cmd_output(Command::new("cargo").arg("vendor").stderr(Stdio::inherit())); |
| 507 | assert!(vendor.status.success()); |
| 508 | |
| 509 | fs::create_dir_all(".cargo").unwrap(); |
| 510 | fs::write(".cargo/config.toml", vendor.stdout).unwrap(); |
| 511 | |
| 512 | for krate in crates { |
| 513 | if !krate.publish { |
| 514 | continue; |
| 515 | } |
| 516 | verify_and_vendor(&krate); |
| 517 | } |
| 518 | |
| 519 | fn verify_and_vendor(krate: &Crate) { |
| 520 | verify_crates_io(krate); |
| 521 | |
| 522 | let mut cmd = Command::new("cargo"); |
| 523 | cmd.arg("package") |
| 524 | .arg("--manifest-path") |
| 525 | .arg(&krate.manifest) |
| 526 | .env("CARGO_TARGET_DIR", "./target"); |
| 527 | if krate.name.contains("wasi-nn") { |
| 528 | cmd.arg("--no-verify"); |
| 529 | } |
| 530 | run_cmd(&mut cmd); |
| 531 | run_cmd( |
| 532 | Command::new("tar") |
| 533 | .arg("xf") |
| 534 | .arg(format!( |
| 535 | "../target/package/{}-{}.crate", |
| 536 | krate.name, krate.version |
| 537 | )) |
| 538 | .current_dir("./vendor"), |
| 539 | ); |
| 540 | fs::write( |
| 541 | format!( |
| 542 | "./vendor/{}-{}/.cargo-checksum.json", |
| 543 | krate.name, krate.version |
| 544 | ), |
| 545 | "{\"files\":{}}", |
| 546 | ) |
| 547 | .unwrap(); |
| 548 | } |
| 549 |
no test coverage detected