-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(publish): Don't strip non-dev features #14325
Changes from all commits
0ece9b9
691c5a2
9e730ec
53fe2b6
dc9014d
eddf7b7
fb41fc3
7c17862
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2551,15 +2551,16 @@ fn unused_dep_keys( | |||||||||||||||||||||
} | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
/// Make the [`Package`] self-contained so its ready for packaging | ||||||||||||||||||||||
pub fn prepare_for_publish( | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is pretty obscure what the
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm trying a rename of |
||||||||||||||||||||||
me: &Package, | ||||||||||||||||||||||
ws: &Workspace<'_>, | ||||||||||||||||||||||
included: &[PathBuf], | ||||||||||||||||||||||
packaged_files: Option<&[PathBuf]>, | ||||||||||||||||||||||
) -> CargoResult<Package> { | ||||||||||||||||||||||
let contents = me.manifest().contents(); | ||||||||||||||||||||||
let document = me.manifest().document(); | ||||||||||||||||||||||
let original_toml = | ||||||||||||||||||||||
prepare_toml_for_publish(me.manifest().resolved_toml(), ws, me.root(), included)?; | ||||||||||||||||||||||
prepare_toml_for_publish(me.manifest().resolved_toml(), ws, me.root(), packaged_files)?; | ||||||||||||||||||||||
let resolved_toml = original_toml.clone(); | ||||||||||||||||||||||
let features = me.manifest().unstable_features().clone(); | ||||||||||||||||||||||
let workspace_config = me.manifest().workspace_config().clone(); | ||||||||||||||||||||||
|
@@ -2591,7 +2592,7 @@ fn prepare_toml_for_publish( | |||||||||||||||||||||
me: &manifest::TomlManifest, | ||||||||||||||||||||||
ws: &Workspace<'_>, | ||||||||||||||||||||||
package_root: &Path, | ||||||||||||||||||||||
included: &[PathBuf], | ||||||||||||||||||||||
packaged_files: Option<&[PathBuf]>, | ||||||||||||||||||||||
) -> CargoResult<manifest::TomlManifest> { | ||||||||||||||||||||||
let gctx = ws.gctx(); | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
@@ -2608,7 +2609,8 @@ fn prepare_toml_for_publish( | |||||||||||||||||||||
package.workspace = None; | ||||||||||||||||||||||
if let Some(StringOrBool::String(path)) = &package.build { | ||||||||||||||||||||||
let path = paths::normalize_path(Path::new(path)); | ||||||||||||||||||||||
let build = if included.contains(&path) { | ||||||||||||||||||||||
let included = packaged_files.map(|i| i.contains(&path)).unwrap_or(true); | ||||||||||||||||||||||
let build = if included { | ||||||||||||||||||||||
let path = path | ||||||||||||||||||||||
.into_os_string() | ||||||||||||||||||||||
.into_string() | ||||||||||||||||||||||
|
@@ -2712,14 +2714,16 @@ fn prepare_toml_for_publish( | |||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
let lib = if let Some(target) = &me.lib { | ||||||||||||||||||||||
prepare_target_for_publish(target, included, "library", ws.gctx())? | ||||||||||||||||||||||
prepare_target_for_publish(target, packaged_files, "library", ws.gctx())? | ||||||||||||||||||||||
} else { | ||||||||||||||||||||||
None | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
let bin = prepare_targets_for_publish(me.bin.as_ref(), included, "binary", ws.gctx())?; | ||||||||||||||||||||||
let example = prepare_targets_for_publish(me.example.as_ref(), included, "example", ws.gctx())?; | ||||||||||||||||||||||
let test = prepare_targets_for_publish(me.test.as_ref(), included, "test", ws.gctx())?; | ||||||||||||||||||||||
let bench = prepare_targets_for_publish(me.bench.as_ref(), included, "benchmark", ws.gctx())?; | ||||||||||||||||||||||
let bin = prepare_targets_for_publish(me.bin.as_ref(), packaged_files, "binary", ws.gctx())?; | ||||||||||||||||||||||
let example = | ||||||||||||||||||||||
prepare_targets_for_publish(me.example.as_ref(), packaged_files, "example", ws.gctx())?; | ||||||||||||||||||||||
let test = prepare_targets_for_publish(me.test.as_ref(), packaged_files, "test", ws.gctx())?; | ||||||||||||||||||||||
let bench = | ||||||||||||||||||||||
prepare_targets_for_publish(me.bench.as_ref(), packaged_files, "benchmark", ws.gctx())?; | ||||||||||||||||||||||
|
||||||||||||||||||||||
let all = |_d: &manifest::TomlDependency| true; | ||||||||||||||||||||||
let mut manifest = manifest::TomlManifest { | ||||||||||||||||||||||
|
@@ -2877,7 +2881,7 @@ fn prepare_toml_for_publish( | |||||||||||||||||||||
|
||||||||||||||||||||||
fn prepare_targets_for_publish( | ||||||||||||||||||||||
targets: Option<&Vec<manifest::TomlTarget>>, | ||||||||||||||||||||||
included: &[PathBuf], | ||||||||||||||||||||||
packaged_files: Option<&[PathBuf]>, | ||||||||||||||||||||||
context: &str, | ||||||||||||||||||||||
gctx: &GlobalContext, | ||||||||||||||||||||||
) -> CargoResult<Option<Vec<manifest::TomlTarget>>> { | ||||||||||||||||||||||
|
@@ -2887,7 +2891,8 @@ fn prepare_targets_for_publish( | |||||||||||||||||||||
|
||||||||||||||||||||||
let mut prepared = Vec::with_capacity(targets.len()); | ||||||||||||||||||||||
for target in targets { | ||||||||||||||||||||||
let Some(target) = prepare_target_for_publish(target, included, context, gctx)? else { | ||||||||||||||||||||||
let Some(target) = prepare_target_for_publish(target, packaged_files, context, gctx)? | ||||||||||||||||||||||
else { | ||||||||||||||||||||||
continue; | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
prepared.push(target); | ||||||||||||||||||||||
|
@@ -2902,19 +2907,21 @@ fn prepare_targets_for_publish( | |||||||||||||||||||||
|
||||||||||||||||||||||
fn prepare_target_for_publish( | ||||||||||||||||||||||
target: &manifest::TomlTarget, | ||||||||||||||||||||||
included: &[PathBuf], | ||||||||||||||||||||||
packaged_files: Option<&[PathBuf]>, | ||||||||||||||||||||||
context: &str, | ||||||||||||||||||||||
gctx: &GlobalContext, | ||||||||||||||||||||||
) -> CargoResult<Option<manifest::TomlTarget>> { | ||||||||||||||||||||||
let path = target.path.as_ref().expect("previously resolved"); | ||||||||||||||||||||||
let path = normalize_path(&path.0); | ||||||||||||||||||||||
if !included.contains(&path) { | ||||||||||||||||||||||
let name = target.name.as_ref().expect("previously resolved"); | ||||||||||||||||||||||
gctx.shell().warn(format!( | ||||||||||||||||||||||
"ignoring {context} `{name}` as `{}` is not included in the published package", | ||||||||||||||||||||||
path.display() | ||||||||||||||||||||||
))?; | ||||||||||||||||||||||
return Ok(None); | ||||||||||||||||||||||
if let Some(packaged_files) = packaged_files { | ||||||||||||||||||||||
if !packaged_files.contains(&path) { | ||||||||||||||||||||||
let name = target.name.as_ref().expect("previously resolved"); | ||||||||||||||||||||||
gctx.shell().warn(format!( | ||||||||||||||||||||||
"ignoring {context} `{name}` as `{}` is not included in the published package", | ||||||||||||||||||||||
path.display() | ||||||||||||||||||||||
))?; | ||||||||||||||||||||||
return Ok(None); | ||||||||||||||||||||||
} | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
let mut target = target.clone(); | ||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -752,11 +752,11 @@ You may press ctrl-c to skip waiting; the crate should be available shortly. | |
"homepage": "https://www.rust-lang.org", | ||
"keywords": ["cli"], | ||
"license": "MIT", | ||
"license_file": "../LICENSE", | ||
"license_file": "LICENSE", | ||
"links": null, | ||
"name": "bar", | ||
"readme": "README.md", | ||
"readme_file": "../README.md", | ||
"readme_file": "README.md", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a side effect that fixes another bug. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I considered tweaking things to not have this happen but it seemed more correct now. |
||
"repository": "https://github.com/example/example", | ||
"rust_version": "1.60", | ||
"vers": "1.2.3" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is unclear why the argument affects build target filtering.