@@ -53,44 +53,19 @@ struct SwiftJava: SwiftJavaBaseAsyncParsableCommand, HasCommonJVMOptions { // FI
53
53
" UnknownSwiftModule "
54
54
}
55
55
}
56
- //
57
- // @Option(
58
- // help:
59
- // "A Java2Swift configuration file for a given Swift module name on which this module depends, e.g., JavaKitJar=Sources/JavaKitJar/Java2Swift.config. There should be one of these options for each Swift module that this module depends on (transitively) that contains wrapped Java sources."
60
- // )
61
- // var dependsOn: [String] = []
62
- //
63
- // @Option(
64
- // help: "The names of Java classes whose declared native methods will be implemented in Swift."
65
- // )
66
- // var swiftNativeImplementation: [String] = []
67
56
68
57
@Option ( help: " The directory where generated Swift files should be written. Generally used with jextract mode. " )
69
58
var outputSwift : String ? = nil
70
59
71
60
@Option ( help: " The directory where generated Java files should be written. Generally used with jextract mode. " )
72
61
var outputJava : String ? = nil
73
62
74
- // @Option(help: "The Java package the generated Java code should be emitted into.")
75
- // var javaPackage: String? = nil
76
-
77
63
@Option ( help: " The mode of generation to use for the output files. Used with jextract mode. " )
78
64
var mode : GenerationMode = . ffm
79
65
80
- // @Option(name: .shortAndLong, help: "Directory where to write cached values (e.g. swift-java.classpath files)")
81
- // var cacheDirectory: String? = nil
82
-
83
66
@OptionGroup var commonOptions : SwiftJava . CommonOptions
84
67
@OptionGroup var commonJVMOptions : SwiftJava . CommonJVMOptions
85
68
86
- // var effectiveCacheDirectory: String? {
87
- // if let cacheDirectory {
88
- // return cacheDirectory
89
- // } else {
90
- // return nil
91
- // }
92
- // }
93
-
94
69
// @Argument(
95
70
// help: "The input file, which is either a Java2Swift configuration file or (if '-jar' was specified) a Jar file."
96
71
// )
@@ -99,9 +74,6 @@ struct SwiftJava: SwiftJavaBaseAsyncParsableCommand, HasCommonJVMOptions { // FI
99
74
// FIXME: this is subcommands
100
75
/// Describes what kind of generation action is being performed by swift-java.
101
76
enum ToolMode {
102
- // /// Generate Swift wrappers for Java classes based on the given
103
- // /// configuration.
104
- // case classWrappers
105
77
106
78
/// Extract Java bindings from provided Swift sources.
107
79
case jextract // TODO: carry jextract specific config here?
@@ -114,10 +86,6 @@ struct SwiftJava: SwiftJavaBaseAsyncParsableCommand, HasCommonJVMOptions { // FI
114
86
return
115
87
}
116
88
117
- // if let javaPackage {
118
- // config.javaPackage = javaPackage
119
- // }
120
-
121
89
// Determine the mode in which we'll execute.
122
90
let toolMode : ToolMode = . jextract
123
91
@@ -140,49 +108,10 @@ struct SwiftJava: SwiftJavaBaseAsyncParsableCommand, HasCommonJVMOptions { // FI
140
108
config. outputSwiftDirectory = outputSwift
141
109
config. outputJavaDirectory = outputJava
142
110
143
- // toolMode = .jextract
144
- // } else if fetch {
145
- // guard let input else {
146
- // fatalError("Mode 'fetch' requires <input> path\n\(Self.helpMessage())")
147
- // }
148
- // config = try JavaTranslator.readConfiguration(from: URL(fileURLWithPath: input))
149
- // guard let dependencies = config.dependencies else {
150
- // print("[swift-java] Running in 'fetch dependencies' mode but dependencies list was empty!")
151
- // print("[swift-java] Nothing to do: done.")
152
- // return
153
- // }
154
- // toolMode = .fetchDependencies
155
- }
156
- // else {
157
- // guard let input else {
158
- // fatalError("Mode -jar requires <input> path\n\(Self.helpMessage())")
159
- // }
160
- // config = try JavaTranslator.readConfiguration(from: URL(fileURLWithPath: input))
161
- // toolMode = .classWrappers
162
- // }
163
-
164
111
print ( " [debug][swift-java] Running swift-java in mode: " + " \( toolMode. prettyName) " . bold)
165
112
166
113
let swiftModule : String =
167
114
self . effectiveSwiftModule
168
- // ??
169
- // self.effectiveSwiftModule.split(separator: "/").dropLast().last.map(String.init) ?? "__UnknownModule"
170
-
171
- // // Load all of the dependent configurations and associate them with Swift
172
- // // modules.
173
- // let dependentConfigs = try dependsOn.map { dependentConfig in
174
- // guard let equalLoc = dependentConfig.firstIndex(of: "=") else {
175
- // throw JavaToSwiftError.badConfigOption(dependentConfig)
176
- // }
177
- //
178
- // let afterEqual = dependentConfig.index(after: equalLoc)
179
- // let swiftModuleName = String(dependentConfig[..<equalLoc])
180
- // let configFileName = String(dependentConfig[afterEqual...])
181
- //
182
- // let config = try readConfiguration(from: URL(fileURLWithPath: configFileName))
183
- //
184
- // return (swiftModuleName, config)
185
- // }
186
115
187
116
// Form a class path from all of our input sources:
188
117
// * Command-line option --classpath
@@ -193,11 +122,6 @@ struct SwiftJava: SwiftJavaBaseAsyncParsableCommand, HasCommonJVMOptions { // FI
193
122
194
123
var classpathEntries : [ String ] = classpathFromConfig
195
124
196
- // let swiftJavaCachedModuleClasspath = findSwiftJavaClasspaths(
197
- // in: self.effectiveCacheDirectory ?? FileManager.default.currentDirectoryPath)
198
- // print("[debug][swift-java] Classpath from *.swift-java.classpath files: \(swiftJavaCachedModuleClasspath)")
199
- // classpathEntries += swiftJavaCachedModuleClasspath
200
-
201
125
if !classpathOptionEntries. isEmpty {
202
126
print ( " [debug][swift-java] Classpath from options: \( classpathOptionEntries) " )
203
127
classpathEntries += classpathOptionEntries
@@ -207,56 +131,7 @@ struct SwiftJava: SwiftJavaBaseAsyncParsableCommand, HasCommonJVMOptions { // FI
207
131
classpathEntries += classpathFromEnv
208
132
}
209
133
210
- // switch toolMode {
211
- // case .fetchDependencies:
212
- // // if we have already fetched dependencies for the dependency loader,
213
- // // let's use them so we can in-process resolve rather than forking a new
214
- // // gradle process.
215
- // print("[debug][swift-java] Add classpath from .classpath files")
216
- //// if let dependencyResolverClasspath = fetchDependenciesCachedClasspath() {
217
- //// print("[debug][swift-java] Found cached dependency resolver classpath: \(dependencyResolverClasspath)")
218
- //// classpathEntries += dependencyResolverClasspath
219
- //// }
220
- // case .classWrappers, .jextract:
221
- // break;
222
- // }
223
-
224
- // Bring up the Java VM when necessary
225
- // // TODO: print only in verbose mode
226
- // let classpath = classpathEntries.joined(separator: ":")
227
-
228
- // let jvm: JavaVirtualMachine! = nil
229
- // switch toolMode {
230
- // case .classWrappers:
231
- // print("[debug][swift-java] Initialize JVM with classpath: \(classpath)")
232
- // jvm = try JavaVirtualMachine.shared(classpath: classpathEntries)
233
- // default:
234
- // jvm = nil
235
- // }
236
-
237
- // // * Classpaths from all dependent configuration files
238
- // for (_, config) in dependentConfigs {
239
- // // TODO: may need to resolve the dependent configs rather than just get their configs
240
- // // TODO: We should cache the resolved classpaths as well so we don't do it many times
241
- // config.classpath.map { entry in
242
- // print("[swift-java] Add dependent config classpath element: \(entry)")
243
- // classpathEntries.append(entry)
244
- // }
245
- // }
246
-
247
- // Run the task.
248
- // switch toolMode {
249
- //// case .classWrappers:
250
- //// try generateWrappers(
251
- //// config: config,
252
- //// classpath: classpath,
253
- //// dependentConfigs: dependentConfigs,
254
- //// environment: jvm.environment()
255
- //// )
256
- //
257
- // case .jextract:
258
- try jextractSwift ( config: config)
259
- // }
134
+ try jextractSwift ( config: config)
260
135
}
261
136
262
137
private func names( from javaClassNameOpt: String ) -> ( javaClassName: String , swiftName: String ) {
0 commit comments