Skip to content

Commit

Permalink
Don't automatically enable std and alloc features of dependencies
Browse files Browse the repository at this point in the history
Part of #656.
  • Loading branch information
madsmtm committed Dec 25, 2024
1 parent 321d4cb commit e000fea
Show file tree
Hide file tree
Showing 99 changed files with 204 additions and 218 deletions.
6 changes: 3 additions & 3 deletions crates/block2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ workspace = true
default = ["std"]

# Currently not possible to turn off, put here for forwards compatibility.
std = ["alloc", "objc2/std"]
alloc = ["objc2/alloc"]
std = ["alloc"]
alloc = []

# Deprecated; this is the default on Apple platforms, and not applicable on other platforms.
apple = []
Expand Down Expand Up @@ -53,7 +53,7 @@ objc2 = { path = "../objc2", version = "0.5.2", default-features = false }
[dev-dependencies.objc2-foundation]
path = "../../framework-crates/objc2-foundation"
default-features = false
features = ["NSError"]
features = ["alloc", "NSError"]

[package.metadata.docs.rs]
default-target = "aarch64-apple-darwin"
Expand Down
4 changes: 2 additions & 2 deletions crates/dispatch2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ targets = [
default = ["std"]

# Currently not possible to turn off, put here for forwards compatibility.
std = ["alloc", "bitflags/std", "block2?/std", "libc?/std", "objc2?/std"]
alloc = ["block2?/alloc", "objc2?/alloc"]
std = ["alloc"]
alloc = []
block2 = ["dep:block2"]
libc = ["dep:libc"]
objc2 = ["dep:objc2"]
Expand Down
2 changes: 0 additions & 2 deletions crates/header-translator/src/default_cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,5 @@ targets = [

[features]
default = ["std"]

# Currently not possible to turn off, put here for forwards compatibility.
std = ["alloc"]
alloc = []
17 changes: 0 additions & 17 deletions crates/header-translator/src/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,23 +326,6 @@ see that for related crates.", self.data.krate)?;
dependency_table
.entry(krate)
.or_insert(Item::Value(Value::InlineTable(table)));

cargo_toml["features"]["std"]
.as_array_mut()
.unwrap()
.push(Value::from(format!(
"{krate}{}/std",
if *required { "" } else { "?" },
)));
if *krate != "bitflags" && *krate != "libc" {
cargo_toml["features"]["alloc"]
.as_array_mut()
.unwrap()
.push(Value::from(format!(
"{krate}{}/alloc",
if *required { "" } else { "?" },
)));
}
}

match fs::read_to_string(crate_dir.join("Cargo.modified.toml")) {
Expand Down
7 changes: 4 additions & 3 deletions crates/objc2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ workspace = true
default = ["std"]

# Currently not possible to turn off, put here for forwards compatibility.
std = ["alloc", "objc2-encode/std", "block2/std", "objc2-foundation/std", "objc2-exception-helper?/std"]
alloc = ["objc2-encode/alloc", "block2/alloc", "objc2-foundation/alloc", "objc2-exception-helper?/alloc"]
std = ["alloc", "objc2-encode/std"]
alloc = ["objc2-encode/alloc"]

# Enables `objc2::exception::throw` and `objc2::exception::catch`
exception = ["dep:objc2-exception-helper"]
Expand Down Expand Up @@ -125,11 +125,12 @@ objc2-exception-helper = { path = "../objc2-exception-helper", version = "0.1.0"
iai = { version = "0.1", git = "https://github.com/madsmtm/iai", branch = "callgrind" }
static_assertions = "1.1.0"
memoffset = "0.9.0"
block2 = { path = "../block2", default-features = false }
block2 = { path = "../block2" }
objc2-core-foundation = { path = "../../framework-crates/objc2-core-foundation", default-features = false, features = [
"CFCGTypes",
] }
objc2-foundation = { path = "../../framework-crates/objc2-foundation", default-features = false, features = [
"std",
"NSArray",
"NSDate",
"NSDictionary",
Expand Down
3 changes: 3 additions & 0 deletions crates/objc2/src/topics/about_generated/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* **BREAKING**: The feature flag guarding `SCSensitivityAnalysis` changed.
* **BREAKING**: `-[NSSavePanel beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector:contextInfo:]`
now takes an optional value as the file path.
* **BREAKING**: No longer automatically enable `std` and `alloc` features of
dependencies. If you want a certain framework crate to use `std` or `alloc`
features, you cannot rely on a higher-level crate to enable that for you.

### Deprecated
* Moved `MainThreadMarker` from `objc2-foundation` to `objc2`.
Expand Down
20 changes: 10 additions & 10 deletions crates/test-assembly/crates/test_define_class/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ publish = false
path = "lib.rs"

[dependencies]
objc2 = { path = "../../../objc2", optional = true }
objc2-foundation = { path = "../../../../framework-crates/objc2-foundation", optional = true }
objc2 = { path = "../../../objc2" }
objc2-foundation = { path = "../../../../framework-crates/objc2-foundation" }

[features]
default = ["all", "objc2", "objc2-foundation"]
default = ["all"]
# Runtime
gnustep-1-7 = ["objc2?/gnustep-1-7", "objc2-foundation?/gnustep-1-7"]
gnustep-1-8 = ["gnustep-1-7", "objc2?/gnustep-1-8", "objc2-foundation?/gnustep-1-8"]
gnustep-1-9 = ["gnustep-1-8", "objc2?/gnustep-1-9", "objc2-foundation?/gnustep-1-9"]
gnustep-2-0 = ["gnustep-1-9", "objc2?/gnustep-2-0", "objc2-foundation?/gnustep-2-0"]
gnustep-2-1 = ["gnustep-2-0", "objc2?/gnustep-2-1", "objc2-foundation?/gnustep-2-1"]
gnustep-1-7 = ["objc2/gnustep-1-7", "objc2-foundation/gnustep-1-7"]
gnustep-1-8 = ["gnustep-1-7", "objc2/gnustep-1-8", "objc2-foundation/gnustep-1-8"]
gnustep-1-9 = ["gnustep-1-8", "objc2/gnustep-1-9", "objc2-foundation/gnustep-1-9"]
gnustep-2-0 = ["gnustep-1-9", "objc2/gnustep-2-0", "objc2-foundation/gnustep-2-0"]
gnustep-2-1 = ["gnustep-2-0", "objc2/gnustep-2-1", "objc2-foundation/gnustep-2-1"]

all = ["objc2-foundation?/block2", "objc2-foundation?/NSObject", "objc2-foundation?/NSZone"]
all = ["objc2-foundation/block2", "objc2-foundation/NSObject", "objc2-foundation/NSZone"]

# Hack to prevent the feature flag from being enabled in the entire project
assembly-features = ["all", "objc2?/unstable-static-sel-inlined", "objc2?/unstable-static-class-inlined"]
assembly-features = ["all", "objc2/unstable-static-sel-inlined", "objc2/unstable-static-class-inlined"]

[package.metadata.release]
release = false
4 changes: 2 additions & 2 deletions crates/test-ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ gnustep-2-1 = ["gnustep-2-0", "block2/gnustep-2-1", "objc2/gnustep-2-1", "objc2-
trybuild = { version = "1.0.72", optional = true }
block2 = { path = "../block2" }
objc2 = { path = "../objc2" }
objc2-foundation = { path = "../../framework-crates/objc2-foundation" }
objc2-foundation = { path = "../../framework-crates/objc2-foundation", default-features = false, features = ["std"] }

# To make CI work
[target.'cfg(not(target_vendor = "apple"))'.dependencies]
block2 = { path = "../block2", features = ["gnustep-1-7"] }
objc2 = { path = "../objc2", features = ["gnustep-1-7"] }
objc2-foundation = { path = "../../framework-crates/objc2-foundation", features = ["gnustep-1-7"] }
objc2-foundation = { path = "../../framework-crates/objc2-foundation", default-features = false, features = ["std", "gnustep-1-7"] }

[[bin]]
name = "test-ui"
Expand Down
2 changes: 1 addition & 1 deletion crates/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ unstable-objfw = ["block2/unstable-objfw", "objc2/unstable-objfw"]
[dependencies]
block2 = { path = "../block2" }
objc2 = { path = "../objc2" }
objc2-foundation = { path = "../../framework-crates/objc2-foundation" }
objc2-foundation = { path = "../../framework-crates/objc2-foundation", default-features = false, features = ["std"] }

[build-dependencies]
cc = "1.0"
Expand Down
4 changes: 2 additions & 2 deletions framework-crates/objc2-accessibility/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-accounts/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-ad-services/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-ad-support/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-app-kit/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-app-tracking-transparency/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-audio-toolbox/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-authentication-services/Cargo.toml

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

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-automator/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-av-foundation/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-av-kit/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-avf-audio/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-background-assets/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-background-tasks/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-business-chat/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-call-kit/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-class-kit/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-cloud-kit/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-contacts-ui/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-contacts/Cargo.toml

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

4 changes: 2 additions & 2 deletions framework-crates/objc2-core-audio-types/Cargo.toml

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

Loading

0 comments on commit e000fea

Please sign in to comment.