Skip to content

Commit

Permalink
Merge pull request #1441 from axodotdev/dist-changes
Browse files Browse the repository at this point in the history
feat: disable single-library mode for dist=false
  • Loading branch information
mistydemeo authored Dec 5, 2024
2 parents 38bd411 + f924934 commit 28dde10
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 6 deletions.
16 changes: 10 additions & 6 deletions cargo-dist/src/announce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,16 @@ fn select_packages(
// add that package as a release still, on the assumption it's a Library
if releases.is_empty() {
if let ReleaseType::Package { idx, version: _ } = announcing.release {
releases.push(ReleaseArtifacts {
package_idx: PackageIdx(idx),
executables: vec![],
cdylibs: vec![],
cstaticlibs: vec![],
});
let config = graph.package_config(PackageIdx(idx));

if config.dist != Some(false) {
releases.push(ReleaseArtifacts {
package_idx: PackageIdx(idx),
executables: vec![],
cdylibs: vec![],
cstaticlibs: vec![],
});
}
}
}

Expand Down
15 changes: 15 additions & 0 deletions cargo-dist/tests/gallery/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,21 @@ impl<'a> TestContext<'a, Tools> {
self.load_dist_results(test_name, true)
}

pub fn cargo_dist_build_tag(&self, test_name: &str, tag_name: &str) -> Result<DistResult> {
// If the dist target dir exists, delete it to avoid cross-contamination
let out_path = Utf8Path::new("target/distrib/");
if out_path.exists() {
LocalAsset::remove_dir_all(out_path)?;
}

eprintln!("running dist build --tag={tag_name}...");
self.tools
.cargo_dist
.output_checked(|cmd| cmd.arg("dist").arg("build").arg("--tag").arg(tag_name))?;

self.load_dist_results(test_name, true)
}

/// Run 'dist generate' and return paths to various files that were generated
pub fn cargo_dist_generate(&self, test_name: &str) -> Result<GenerateResult> {
self.cargo_dist_generate_prefixed(test_name, "")
Expand Down
37 changes: 37 additions & 0 deletions cargo-dist/tests/integration-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,43 @@ targets = ["x86_64-pc-windows-msvc"]
.unwrap();
}

#[test]
// Should produce an error on `build` because the requested tag matches a package with dist=false
#[should_panic(expected = r#"This workspace doesn't have anything for dist to Release!"#)]
fn axolotlsay_dist_false() {
let test_name = _function_name!();
AXOLOTLSAY.run_test(|ctx| {
let dist_version = ctx.tools.cargo_dist.version().unwrap();
ctx.patch_cargo_toml(format!(r#"
[workspace.metadata.dist]
cargo-dist-version = "{dist_version}"
installers = ["shell", "powershell", "homebrew", "npm", "msi", "pkg"]
tap = "axodotdev/homebrew-packages"
publish-jobs = ["homebrew", "npm"]
targets = ["x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "aarch64-apple-darwin"]
install-success-msg = ">o_o< everything's installed!"
ci = ["github"]
unix-archive = ".tar.gz"
windows-archive = ".tar.gz"
npm-scope = "@axodotdev"
dist = false
[package.metadata.wix]
upgrade-guid = "B36177BE-EA4D-44FB-B05C-EDDABDAA95CA"
path-guid = "BFD25009-65A4-4D1E-97F1-0030465D90D6"
[package.metadata.dist.mac-pkg-config]
identifier = "dev.axo.axolotsay"
"#
))?;

ctx.cargo_dist_build_tag(test_name, "axolotlsay-v0.2.2")?;

Ok(())
}).unwrap()
}

#[test]
fn axolotlsay_disable_source_tarball() -> Result<(), miette::Report> {
let test_name = _function_name!();
Expand Down

0 comments on commit 28dde10

Please sign in to comment.