Skip to content

Commit 8b6507c

Browse files
Add mod.json GD version check (#120)
1 parent 9ff4dae commit 8b6507c

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

src/project.rs

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::logging::ask_value;
22
use crate::mod_file::{PlatformName, ToGeodeString};
3-
use crate::util::mod_file::DependencyImportance;
3+
use crate::util::mod_file::{DependencyImportance, GDVersion};
44
use crate::{done, fail, fatal, index, info, warn, NiceUnwrap};
55
use crate::{
66
file::read_dir_recursive,
@@ -270,6 +270,39 @@ pub fn check_dependencies(
270270

271271
let mod_info = parse_mod_info(&input);
272272

273+
let platform = platform.unwrap_or_else(|| {
274+
PlatformName::current().nice_unwrap("Unknown platform, please specify one with --platform")
275+
});
276+
277+
// Check if platform is supported
278+
match mod_info.gd {
279+
GDVersion::Simple(_) => {}
280+
GDVersion::Detailed(gd) => {
281+
match platform {
282+
PlatformName::Windows => {
283+
if gd.win.is_none() {
284+
fatal!("Geometry Dash version not specified for Windows, please specify one in mod.json");
285+
}
286+
}
287+
PlatformName::MacOS | PlatformName::MacArm | PlatformName::MacIntel => {
288+
if gd.mac.is_none() {
289+
fatal!("Geometry Dash version not specified for macOS, please specify one in mod.json");
290+
}
291+
}
292+
PlatformName::Android | PlatformName::Android32 | PlatformName::Android64 => {
293+
if gd.android.is_none() {
294+
fatal!("Geometry Dash version not specified for Android, please specify one in mod.json");
295+
}
296+
}
297+
PlatformName::IOS => {
298+
if gd.ios.is_none() {
299+
fatal!("Geometry Dash version not specified for iOS, please specify one in mod.json");
300+
}
301+
}
302+
}
303+
}
304+
}
305+
273306
// If no dependencies, skippy wippy
274307
if mod_info.dependencies.is_empty() {
275308
return;
@@ -300,10 +333,6 @@ pub fn check_dependencies(
300333
let dep_dir = output.join("geode-deps");
301334
fs::create_dir_all(&dep_dir).nice_unwrap("Unable to create dependency directory");
302335

303-
let platform = platform.unwrap_or_else(|| {
304-
PlatformName::current().nice_unwrap("Unknown platform, please specify one with --platform")
305-
});
306-
307336
// check all dependencies
308337
for dep in &mod_info.dependencies {
309338
let mut platforms = dep.platforms.clone();

0 commit comments

Comments
 (0)