Skip to content

Commit 76cc48a

Browse files
committed
cleanups, remove dead code, commented code etc
1 parent c509c1f commit 76cc48a

File tree

1 file changed

+1
-126
lines changed

1 file changed

+1
-126
lines changed

Sources/SwiftJavaTool/SwiftJava.swift

Lines changed: 1 addition & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -53,44 +53,19 @@ struct SwiftJava: SwiftJavaBaseAsyncParsableCommand, HasCommonJVMOptions { // FI
5353
"UnknownSwiftModule"
5454
}
5555
}
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] = []
6756

6857
@Option(help: "The directory where generated Swift files should be written. Generally used with jextract mode.")
6958
var outputSwift: String? = nil
7059

7160
@Option(help: "The directory where generated Java files should be written. Generally used with jextract mode.")
7261
var outputJava: String? = nil
7362

74-
// @Option(help: "The Java package the generated Java code should be emitted into.")
75-
// var javaPackage: String? = nil
76-
7763
@Option(help: "The mode of generation to use for the output files. Used with jextract mode.")
7864
var mode: GenerationMode = .ffm
7965

80-
// @Option(name: .shortAndLong, help: "Directory where to write cached values (e.g. swift-java.classpath files)")
81-
// var cacheDirectory: String? = nil
82-
8366
@OptionGroup var commonOptions: SwiftJava.CommonOptions
8467
@OptionGroup var commonJVMOptions: SwiftJava.CommonJVMOptions
8568

86-
// var effectiveCacheDirectory: String? {
87-
// if let cacheDirectory {
88-
// return cacheDirectory
89-
// } else {
90-
// return nil
91-
// }
92-
// }
93-
9469
// @Argument(
9570
// help: "The input file, which is either a Java2Swift configuration file or (if '-jar' was specified) a Jar file."
9671
// )
@@ -99,9 +74,6 @@ struct SwiftJava: SwiftJavaBaseAsyncParsableCommand, HasCommonJVMOptions { // FI
9974
// FIXME: this is subcommands
10075
/// Describes what kind of generation action is being performed by swift-java.
10176
enum ToolMode {
102-
// /// Generate Swift wrappers for Java classes based on the given
103-
// /// configuration.
104-
// case classWrappers
10577

10678
/// Extract Java bindings from provided Swift sources.
10779
case jextract // TODO: carry jextract specific config here?
@@ -114,10 +86,6 @@ struct SwiftJava: SwiftJavaBaseAsyncParsableCommand, HasCommonJVMOptions { // FI
11486
return
11587
}
11688

117-
// if let javaPackage {
118-
// config.javaPackage = javaPackage
119-
// }
120-
12189
// Determine the mode in which we'll execute.
12290
let toolMode: ToolMode = .jextract
12391

@@ -140,49 +108,10 @@ struct SwiftJava: SwiftJavaBaseAsyncParsableCommand, HasCommonJVMOptions { // FI
140108
config.outputSwiftDirectory = outputSwift
141109
config.outputJavaDirectory = outputJava
142110

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-
164111
print("[debug][swift-java] Running swift-java in mode: " + "\(toolMode.prettyName)".bold)
165112

166113
let swiftModule: String =
167114
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-
// }
186115

187116
// Form a class path from all of our input sources:
188117
// * Command-line option --classpath
@@ -193,11 +122,6 @@ struct SwiftJava: SwiftJavaBaseAsyncParsableCommand, HasCommonJVMOptions { // FI
193122

194123
var classpathEntries: [String] = classpathFromConfig
195124

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-
201125
if !classpathOptionEntries.isEmpty {
202126
print("[debug][swift-java] Classpath from options: \(classpathOptionEntries)")
203127
classpathEntries += classpathOptionEntries
@@ -207,56 +131,7 @@ struct SwiftJava: SwiftJavaBaseAsyncParsableCommand, HasCommonJVMOptions { // FI
207131
classpathEntries += classpathFromEnv
208132
}
209133

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)
260135
}
261136

262137
private func names(from javaClassNameOpt: String) -> (javaClassName: String, swiftName: String) {

0 commit comments

Comments
 (0)