Skip to content

Commit 5579846

Browse files
committed
propagate build plugin config to command
1 parent 89b2bcc commit 5579846

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

Plugins/JExtractSwiftPlugin/JExtractSwiftPlugin.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ struct JExtractSwiftBuildToolPlugin: SwiftJavaPluginProtocol, BuildToolPlugin {
8989
arguments += ["--java-package", javaPackage]
9090
}
9191

92+
if let unsignedNumbersMode = configuration.unsignedNumbersMode {
93+
arguments += ["--unsigned-numbers", \(unsignedNumbersMode.rawValue.kebabCased)]
94+
}
95+
96+
if let minimumInputAccessLevelMode = configuration.minimumInputAccessLevelMode {
97+
arguments += ["--minimum-input-access-level", \(minimumInputAccessLevelMode.rawValue.kebabCased)]
98+
}
99+
100+
if let memoryManagementMode = configuration.memoryManagementMode {
101+
arguments += ["--memory-management-mode", \(memoryManagementMode.rawValue.kebabCased)]
102+
}
103+
92104
let swiftFiles = sourceModule.sourceFiles.map { $0.url }.filter {
93105
$0.pathExtension == "swift"
94106
}

Plugins/PluginsShared/PluginUtils.swift

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,33 @@ extension PluginContext {
6666
.appending(path: "generated")
6767
.appending(path: "java")
6868
}
69-
69+
7070
var outputSwiftDirectory: URL {
7171
self.pluginWorkDirectoryURL
7272
.appending(path: "Sources")
7373
}
74-
74+
7575
func cachedClasspathFile(swiftModule: String) -> URL {
7676
self.pluginWorkDirectoryURL
7777
.appending(path: "\(swiftModule)", directoryHint: .notDirectory)
7878
}
7979
}
80+
81+
extension String {
82+
var kebabCased: String {
83+
var result = ""
84+
85+
for (index, char) in input.enumerated() {
86+
if char.isUppercase {
87+
if index != 0 {
88+
result.append("-")
89+
}
90+
result.append(char.lowercased())
91+
} else {
92+
result.append(char)
93+
}
94+
}
95+
96+
return result
97+
}
98+
}

Sources/SwiftJavaTool/Commands/JExtractCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ extension SwiftJava {
6767
@Option(help: "The lowest access level of Swift declarations that should be extracted, defaults to 'public'.")
6868
var minimumInputAccessLevel: JExtractMinimumAccessLevelMode = .default
6969

70-
@Option(help: "The memory management mode to use for the generated code. By default, the user must explicitly provide `SwiftArena` to all calls that require it. By choosing `allow-automatic`, user can omit this parameter and a global GC-based arena will be used. `force-automatic` removes all explicit memory management.")
70+
@Option(help: "The memory management mode to use for the generated code. By default, the user must explicitly provide `SwiftArena` to all calls that require it. By choosing `allow-global-automatic`, user can omit this parameter and a global GC-based arena will be used.")
7171
var memoryManagementMode: JExtractMemoryManagementMode = .default
7272

7373
@Option(

0 commit comments

Comments
 (0)