Skip to content

Commit 099cdb3

Browse files
committed
chore: disable default features for cargo commands in xtask, move unsafe_lua_modules into a conditional default feature
1 parent f77f246 commit 099cdb3

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ path = "src/lib.rs"
2020
features = ["lua54"]
2121

2222
[features]
23-
default = ["core_functions", "bevy_bindings"]
23+
default = ["core_functions", "bevy_bindings", "unsafe_lua_modules"]
2424

2525
## lua
26-
lua = ["bevy_mod_scripting_lua", "unsafe_lua_modules"]
26+
lua = ["bevy_mod_scripting_lua"]
2727
# one of these must be selected
2828
lua51 = ["bevy_mod_scripting_lua/lua51", "lua"]
2929
lua52 = ["bevy_mod_scripting_lua/lua52", "lua"]
@@ -38,7 +38,7 @@ core_functions = ["bevy_mod_scripting_functions/core_functions"]
3838
bevy_bindings = ["bevy_mod_scripting_functions/bevy_bindings"]
3939

4040
# optional
41-
unsafe_lua_modules = ["bevy_mod_scripting_lua/unsafe_lua_modules"]
41+
unsafe_lua_modules = ["bevy_mod_scripting_lua?/unsafe_lua_modules"]
4242
mlua_serialize = ["bevy_mod_scripting_lua/mlua_serialize"]
4343
mlua_macros = ["bevy_mod_scripting_lua/mlua_macros"]
4444
mlua_async = ["bevy_mod_scripting_lua/mlua_async"]

crates/xtask/src/main.rs

+29-8
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,12 @@ struct Features(HashSet<Feature>);
109109

110110
impl Default for Features {
111111
fn default() -> Self {
112-
Features::new(vec![Feature::Lua54])
112+
// should be kept up to date with the default feature + lua54
113+
Features::new(vec![
114+
Feature::Lua54,
115+
Feature::CoreFunctions,
116+
Feature::BevyBindings,
117+
])
113118
}
114119
}
115120

@@ -147,7 +152,11 @@ impl Features {
147152
if self.0.is_empty() {
148153
vec![]
149154
} else {
150-
vec!["--features".to_owned(), self.to_string()]
155+
vec![
156+
"--no-default-features".to_owned(),
157+
"--features".to_owned(),
158+
self.to_string(),
159+
]
151160
}
152161
}
153162

@@ -574,14 +583,21 @@ impl Xtasks {
574583

575584
let mut args = vec![];
576585
args.push(command.to_owned());
577-
args.push("--workspace".to_owned());
586+
587+
if command != "fmt" {
588+
args.push("--workspace".to_owned());
589+
}
578590

579591
if let Some(profile) = app_settings.profile.as_ref() {
580592
args.push("--profile".to_owned());
581593
args.push(profile.clone());
582594
}
583595

584-
args.extend(app_settings.features.to_cargo_args());
596+
if command != "fmt" {
597+
// fmt doesn't care about features
598+
args.extend(app_settings.features.to_cargo_args());
599+
}
600+
585601
args.extend(add_args.into_iter().map(|s| {
586602
s.as_ref()
587603
.to_str()
@@ -647,10 +663,11 @@ impl Xtasks {
647663
}
648664

649665
// run cargo fmt checks
650-
Self::run_system_command(
651-
"cargo",
666+
Self::run_workspace_command(
667+
&app_settings,
668+
"fmt",
652669
"Failed to run cargo fmt",
653-
vec!["fmt", "--all", "--", "--check"],
670+
vec!["--all", "--", "--check"],
654671
None,
655672
)?;
656673

@@ -730,7 +747,11 @@ impl Xtasks {
730747
.map(|s| Feature::from_str(s).expect("invalid feature"))
731748
.collect::<Vec<_>>();
732749

733-
let features = Features::new(string_list);
750+
// include default features
751+
let default_features = Features::default();
752+
let mut features = Features::new(string_list);
753+
features.0.extend(default_features.0);
754+
734755
app_settings.features = features;
735756

736757
let mut args = Vec::default();

0 commit comments

Comments
 (0)