You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: crates/cargo-gpu/src/toml.rs
+47-25Lines changed: 47 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -75,43 +75,20 @@ impl Toml {
75
75
}else{
76
76
anyhow::bail!("toml file '{}' must describe a workspace containing [workspace.metadata.rust-gpu.build] or a describe a crate with [package.metadata.rust-gpu.build]", path.display());
77
77
};
78
+
78
79
log::info!(
79
80
"building with [{toml_type}.metadata.rust-gpu.build] section of the toml file at '{}'",
80
81
path.display()
81
82
);
82
83
log::debug!("table: {table:#?}");
83
84
84
-
letmut parameters:Vec<String> = table
85
-
.get("build")
86
-
.with_context(|| "toml is missing the 'build' table")?
87
-
.as_table()
88
-
.with_context(|| {
89
-
format!("toml file's '{toml_type}.metadata.rust-gpu.build' property is not a table")
90
-
})?
91
-
.into_iter()
92
-
.map(|(key, val)| -> anyhow::Result<Vec<String>>{
93
-
Ok(iflet toml::Value::String(string) = val {
94
-
[format!("--{key}"), string.clone()].into()
95
-
}else{
96
-
letmut value = String::new();
97
-
let ser = toml::ser::ValueSerializer::new(&mut value);
98
-
serde::Serialize::serialize(val, ser)?;
99
-
[format!("--{key}"), value].into()
100
-
})
101
-
})
102
-
.collect::<anyhow::Result<Vec<Vec<String>>>>()?
103
-
.into_iter()
104
-
.flatten()
105
-
.collect();
106
-
parameters.insert(0,"cargo-gpu".to_owned());
107
-
parameters.insert(1,"build".to_owned());
108
-
109
85
log::info!(
110
86
"issuing cargo commands from the working directory '{}'",
111
87
working_directory.display()
112
88
);
113
89
std::env::set_current_dir(working_directory)?;
114
90
91
+
let parameters = construct_build_parameters_from_toml_table(toml_type,&table)?;
115
92
log::debug!("build parameters: {parameters:#?}");
116
93
ifletCli{
117
94
command:Command::Build(mut build),
@@ -162,3 +139,48 @@ impl Toml {
162
139
metadata.get("rust-gpu")?.as_table()
163
140
}
164
141
}
142
+
143
+
/// Construct the cli parameters to run a `cargo gpu build` command from a TOML table.
144
+
fnconstruct_build_parameters_from_toml_table(
145
+
toml_type:&str,
146
+
table:&toml::map::Map<String, toml::Value>,
147
+
) -> Result<Vec<String>, anyhow::Error>{
148
+
let build_table = table
149
+
.get("build")
150
+
.with_context(|| "toml is missing the 'build' table")?
151
+
.as_table()
152
+
.with_context(|| {
153
+
format!("toml file's '{toml_type}.metadata.rust-gpu.build' property is not a table")
0 commit comments