Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make macro-mode the default #61

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion src/commands/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,10 @@ fn prompt_platforms(accept_all: bool) -> Vec<Platform> {
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();
Expand Down
12 changes: 10 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
Expand Down
45 changes: 40 additions & 5 deletions testing/end-to-end/init.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -31,10 +31,6 @@ guard fileExists(atPath: "\(projectName)/Cargo.toml") else {
error("No Cargo.toml found in project directory")
exit(1)
}
guard fileExists(atPath: "\(projectName)/build.rs") else {
error("No build.rs file found in project directory")
exit(1)
}
guard fileExists(atPath: "\(projectName)/.gitignore") else {
error("No .gitignore found in project directory")
exit(1)
Expand All @@ -48,4 +44,43 @@ guard fileExists(atPath: "\(projectName)/src/lib.rs") else {
exit(1)
}

print("Running tests for cargo swift init in udl mode...")

let cargoSwiftInitUdl = Process()
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: projectNameUdl) else {
error("Project directory does not exist")
exit(1)
}
guard fileExists(atPath: "\(projectNameUdl)/Cargo.toml") else {
error("No Cargo.toml found in project directory")
exit(1)
}
guard fileExists(atPath: "\(projectNameUdl)/build.rs") else {
error("No build.rs file found in project directory")
exit(1)
}
guard fileExists(atPath: "\(projectNameUdl)/.gitignore") else {
error("No .gitignore found in project directory")
exit(1)
}
guard dirExists(atPath: "\(projectNameUdl)/src") else {
error("No src-directory found in project directory")
exit(1)
}
guard fileExists(atPath: "\(projectNameUdl)/src/lib.rs") else {
error("No lib.rs file found in src directory")
exit(1)
}
guard fileExists(atPath: "\(projectNameUdl)/src/lib.udl") else {
error("No lib.udl file found in src directory")
exit(1)
}

print("Tests for cargo swift init passed!")
Loading