From c37367a893935bc6b92c2c54dd7e04570e383ac5 Mon Sep 17 00:00:00 2001 From: Antonius Naumann Date: Sat, 3 Aug 2024 00:59:31 +0200 Subject: [PATCH 1/6] Make macro-mode the default --- src/main.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 105dbff..63035bf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,7 +62,14 @@ enum Action { // Initialize the project without any explanatory boilerplate code plain: bool, + #[arg(long = "udl")] + // Use .udl files instead of macros to declare which types and functions should be exported + // for use in Swift + udl: bool, + #[arg(long = "macro")] + // (Deprecated) This flag is no longer neccessary, as this is the default mode. This flag + // is ignored now and will be removed in future releases // Initialize the project as a macro-only crate without .udl files macro_only: bool, }, @@ -117,8 +124,9 @@ fn main() -> ExitCode { vcs, lib_type, plain, - macro_only, - } => init::run(crate_name, config, vcs, lib_type, plain, macro_only), + macro_only: _, + udl + } => init::run(crate_name, config, vcs, lib_type, plain, !udl), Action::Package { platforms, From 6c8ebe37fd7bb465b316c49fa7c5949d9fa6247a Mon Sep 17 00:00:00 2001 From: Antonius Naumann Date: Fri, 9 Aug 2024 19:31:31 +0200 Subject: [PATCH 2/6] Update init tests --- testing/end-to-end/init.swift | 37 ++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/testing/end-to-end/init.swift b/testing/end-to-end/init.swift index 425074a..3d3ae7f 100755 --- a/testing/end-to-end/init.swift +++ b/testing/end-to-end/init.swift @@ -13,7 +13,7 @@ func fileExists(atPath path: String) -> Bool { return exists && !isDirectory.boolValue } -print("Running tests for cargo swift init...") +print("Running tests for cargo swift init in macro mode...") let cargoSwiftInit = Process() let projectName = "ExampleProject" @@ -23,6 +23,37 @@ cargoSwiftInit.arguments = ["cargo", "swift", "init", projectName, "-y", "--sile try! cargoSwiftInit.run() cargoSwiftInit.waitUntilExit() +guard dirExists(atPath: projectName) else { + error("Project directory does not exist") + exit(1) +} +guard fileExists(atPath: "\(projectName)/Cargo.toml") else { + error("No Cargo.toml found in project directory") + exit(1) +} +guard fileExists(atPath: "\(projectName)/.gitignore") else { + error("No .gitignore found in project directory") + exit(1) +} +guard dirExists(atPath: "\(projectName)/src") else { + error("No src-directory found in project directory") + exit(1) +} +guard fileExists(atPath: "\(projectName)/src/lib.rs") else { + error("No lib.rs file found in src directory") + exit(1) +} + +print("Running tests for cargo swift init in udl mode...") + +let cargoSwiftInit = Process() +let projectName = "ExampleProject" +cargoSwiftInit.executableURL = URL(fileURLWithPath: "/usr/bin/env") +cargoSwiftInit.arguments = ["cargo", "swift", "init", projectName, "-y", "--silent", "--udl"] + +try! cargoSwiftInit.run() +cargoSwiftInit.waitUntilExit() + guard dirExists(atPath: projectName) else { error("Project directory does not exist") exit(1) @@ -47,5 +78,9 @@ guard fileExists(atPath: "\(projectName)/src/lib.rs") else { error("No lib.rs file found in src directory") exit(1) } +guard fileExists(atPath: "\(projectName)/src/lib.udl") else { + error("No lib.udl file found in src directory") + exit(1) +} print("Tests for cargo swift init passed!") From 1a5e2cc0c2d6e28ed8453b498a7249eb64ec0169 Mon Sep 17 00:00:00 2001 From: Antonius Naumann Date: Fri, 9 Aug 2024 19:40:30 +0200 Subject: [PATCH 3/6] Unselect experimental platforms when building with --accept-all --- src/commands/package.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/commands/package.rs b/src/commands/package.rs index 624beb1..1318254 100644 --- a/src/commands/package.rs +++ b/src/commands/package.rs @@ -268,7 +268,10 @@ fn prompt_platforms(accept_all: bool) -> Vec { let items = platforms.map(|p| p.display_name()); if accept_all { - return platforms.to_vec(); + return platforms + .into_iter() + .filter(|p| !p.is_experimental()) + .collect(); } let theme = prompt_theme(); From 74eb5bc153bf745f51b8d7743a87457a10d15b59 Mon Sep 17 00:00:00 2001 From: Antonius Naumann Date: Fri, 9 Aug 2024 19:53:27 +0200 Subject: [PATCH 4/6] Fix end-to-end tests --- testing/end-to-end/init.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/testing/end-to-end/init.swift b/testing/end-to-end/init.swift index 3d3ae7f..a8450ea 100755 --- a/testing/end-to-end/init.swift +++ b/testing/end-to-end/init.swift @@ -46,13 +46,12 @@ guard fileExists(atPath: "\(projectName)/src/lib.rs") else { print("Running tests for cargo swift init in udl mode...") -let cargoSwiftInit = Process() -let projectName = "ExampleProject" +let cargoSwiftInitUdl = Process() cargoSwiftInit.executableURL = URL(fileURLWithPath: "/usr/bin/env") cargoSwiftInit.arguments = ["cargo", "swift", "init", projectName, "-y", "--silent", "--udl"] -try! cargoSwiftInit.run() -cargoSwiftInit.waitUntilExit() +try! cargoSwiftInitUdl.run() +cargoSwiftInitUdl.waitUntilExit() guard dirExists(atPath: projectName) else { error("Project directory does not exist") From 47d5a9d6c92390fe537fdcae0c7551e33ab3c3a2 Mon Sep 17 00:00:00 2001 From: Antonius Naumann Date: Fri, 9 Aug 2024 20:00:01 +0200 Subject: [PATCH 5/6] Update dependencies --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e5c5e57..0f2f0e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -199,9 +199,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.13" +version = "4.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" +checksum = "c937d4061031a6d0c8da4b9a4f98a172fc2976dfb1c19213a9cf7d0d3c837e36" dependencies = [ "clap_builder", "clap_derive", @@ -209,9 +209,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.13" +version = "4.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" +checksum = "85379ba512b21a328adf887e85f7742d12e96eb31f3ef077df4ffc26b506ffed" dependencies = [ "anstream", "anstyle", @@ -586,18 +586,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.204" +version = "1.0.205" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.205" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1" dependencies = [ "proc-macro2", "quote", From a867a9548383306f77b83bafeda85c6ee164dee5 Mon Sep 17 00:00:00 2001 From: Antonius Naumann Date: Sat, 10 Aug 2024 22:00:09 +0200 Subject: [PATCH 6/6] Fix end-to-end tests --- testing/end-to-end/init.swift | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/testing/end-to-end/init.swift b/testing/end-to-end/init.swift index a8450ea..b00fba2 100755 --- a/testing/end-to-end/init.swift +++ b/testing/end-to-end/init.swift @@ -47,37 +47,38 @@ guard fileExists(atPath: "\(projectName)/src/lib.rs") else { print("Running tests for cargo swift init in udl mode...") let cargoSwiftInitUdl = Process() -cargoSwiftInit.executableURL = URL(fileURLWithPath: "/usr/bin/env") -cargoSwiftInit.arguments = ["cargo", "swift", "init", projectName, "-y", "--silent", "--udl"] +let projectNameUdl = "\(projectName)_udl" +cargoSwiftInitUdl.executableURL = URL(fileURLWithPath: "/usr/bin/env") +cargoSwiftInitUdl.arguments = ["cargo", "swift", "init", projectNameUdl, "-y", "--silent", "--udl"] try! cargoSwiftInitUdl.run() cargoSwiftInitUdl.waitUntilExit() -guard dirExists(atPath: projectName) else { +guard dirExists(atPath: projectNameUdl) else { error("Project directory does not exist") exit(1) } -guard fileExists(atPath: "\(projectName)/Cargo.toml") else { +guard fileExists(atPath: "\(projectNameUdl)/Cargo.toml") else { error("No Cargo.toml found in project directory") exit(1) } -guard fileExists(atPath: "\(projectName)/build.rs") else { +guard fileExists(atPath: "\(projectNameUdl)/build.rs") else { error("No build.rs file found in project directory") exit(1) } -guard fileExists(atPath: "\(projectName)/.gitignore") else { +guard fileExists(atPath: "\(projectNameUdl)/.gitignore") else { error("No .gitignore found in project directory") exit(1) } -guard dirExists(atPath: "\(projectName)/src") else { +guard dirExists(atPath: "\(projectNameUdl)/src") else { error("No src-directory found in project directory") exit(1) } -guard fileExists(atPath: "\(projectName)/src/lib.rs") else { +guard fileExists(atPath: "\(projectNameUdl)/src/lib.rs") else { error("No lib.rs file found in src directory") exit(1) } -guard fileExists(atPath: "\(projectName)/src/lib.udl") else { +guard fileExists(atPath: "\(projectNameUdl)/src/lib.udl") else { error("No lib.udl file found in src directory") exit(1) }