From 6dd21ac5b94b9829d39152b0f617b61aa1ef70c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ritzl?= Date: Tue, 24 Oct 2023 16:59:24 +0200 Subject: [PATCH] Moved swift commands to yml --- .../java/com/defold/extender/Extender.java | 81 ++----------------- .../com/defold/extender/PlatformConfig.java | 5 ++ 2 files changed, 10 insertions(+), 76 deletions(-) diff --git a/server/src/main/java/com/defold/extender/Extender.java b/server/src/main/java/com/defold/extender/Extender.java index ac95f8f3..97e7971c 100644 --- a/server/src/main/java/com/defold/extender/Extender.java +++ b/server/src/main/java/com/defold/extender/Extender.java @@ -539,39 +539,8 @@ private List getIncludeDirs(File extDir) { } - private String getSwiftTargetFromPlatform(String platform) { - switch (platform) { - case "arm64-ios": - return "arm64-apple-ios11.0"; - case "x86_64-ios": - return "x86_64-apple-ios11.0-simulator"; - case "osx": - case "x86-osx": - case "x86_64-osx": - return "x86_64-apple-darwin19"; - case "arm64-osx": - return "arm-apple-darwin19"; - default: - return null; - } - } - - private static final String EMIT_SWIFT_HEADER_COMMAND = "swiftc" - + " -emit-object" // Emit object file(s) (-c) - + " -emit-objc-header" // Emit an Objective-C header file - + " -emit-objc-header-path {{swiftHeaderPath}}" - + " -module-name {{moduleName}}" // Name of the module to build - + " -enforce-exclusivity=checked" // Enforce law of exclusivity - + " {{#swiftSourceFiles}}{{{.}}} {{/swiftSourceFiles}}" - + " -sdk {{env.SYSROOT}}" // Compile against - + " -target {{swiftTarget}}" // Generate code for the given target , such as x86_64-apple-macos10.9 - + " -enable-bare-slash-regex" // Enable the use of forward slash regular-expression literal syntax (https://developer.apple.com/documentation/xcode/build-settings-reference#Enable-Bare-Slash-Regex-Literals) - + " -swift-version {{swiftVersion}}" // Interpret input according to a specific Swift language version number - + " -DCOCOAPODS" - + " -DSWIFT_PACKAGE" - + " {{#includes}}-I{{{.}}} {{/includes}}" - + " {{#platformIncludes}}-I{{.}} {{/platformIncludes}}" - + " {{#ext.includes}}-I{{{.}}} {{/ext.includes}}"; + // swiftc: https://gist.github.com/enomoto/7f11d57e4add7e702f9f84f34d3a0f8c + // swift-frontend: https://gist.github.com/palaniraja/b4de1e64e874b68bda9e5236829cd8a6 private void emitSwiftHeaders(PodSpec pod, Map manifestContext, List commands) throws IOException, InterruptedException, ExtenderException { List includes = getIncludeDirs(pod.dir); @@ -588,32 +557,13 @@ private void emitSwiftHeaders(PodSpec pod, Map manifestContext, context.put("moduleName", pod.moduleName); context.put("swiftSourceFiles", pod.swiftSourceFilePaths); context.put("swiftHeaderPath", pod.swiftModuleHeader); - context.put("swiftTarget", getSwiftTargetFromPlatform(platform)); context.put("swiftVersion", "5"); - String command = templateExecutor.execute(EMIT_SWIFT_HEADER_COMMAND, context); + String command = templateExecutor.execute(this.platformConfig.emitSwiftHeaderCmd, context); // LOGGER.info("swiftc command to emot header: " + command); commands.add(command); } - - private static final String EMIT_SWIFT_MODULE_COMMAND = "swiftc" - + " -emit-object" // Emit object file(s) (-c) - + " -emit-module" // Emit a swift module - + " -emit-module-path {{swiftModulePath}}" - + " -module-name {{moduleName}}" // Name of the module to build - + " -enforce-exclusivity=checked" // Enforce law of exclusivity - + " {{#swiftSourceFiles}}{{{.}}} {{/swiftSourceFiles}}" - + " -sdk {{env.SYSROOT}}" // Compile against - + " -target {{swiftTarget}}" // Generate code for the given target , such as x86_64-apple-macos10.9 - + " -enable-bare-slash-regex" // Enable the use of forward slash regular-expression literal syntax (https://developer.apple.com/documentation/xcode/build-settings-reference#Enable-Bare-Slash-Regex-Literals) - + " -swift-version {{swiftVersion}}" // Interpret input according to a specific Swift language version number - + " -DCOCOAPODS" - + " -DSWIFT_PACKAGE" - + " {{#includes}}-I{{{.}}} {{/includes}}" - + " {{#platformIncludes}}-I{{.}} {{/platformIncludes}}" - + " {{#ext.includes}}-I{{{.}}} {{/ext.includes}}"; - private void emitSwiftModule(PodSpec pod, Map manifestContext, List commands) throws IOException, InterruptedException, ExtenderException { List includes = getIncludeDirs(pod.dir); @@ -629,32 +579,12 @@ private void emitSwiftModule(PodSpec pod, Map manifestContext, L context.put("moduleName", pod.moduleName); context.put("swiftSourceFiles", pod.swiftSourceFilePaths); context.put("swiftModulePath", new File(pod.generatedDir, pod.moduleName + ".swiftmodule")); - context.put("swiftTarget", getSwiftTargetFromPlatform(platform)); context.put("swiftVersion", "5"); - String command = templateExecutor.execute(EMIT_SWIFT_MODULE_COMMAND, context); + String command = templateExecutor.execute(this.platformConfig.emitSwiftModuleCmd, context); // LOGGER.info("swiftc command to emit module: " + command); commands.add(command); } - private static final String COMPILE_SWIFT_COMMAND = "{{env.PLATFORMSDK_DIR}}/XcodeDefault{{env.XCODE_VERSION}}.xctoolchain/usr/bin/swift-frontend" - + " -emit-object" // Emit object file(s) (-c) - + " -module-name {{moduleName}}" // Name of the module to build - + " -enforce-exclusivity=checked" // Enforce law of exclusivity - + " -primary-file {{swiftPrimarySourceFile}}" // Primary source file - + " {{#swiftSourceFiles}}{{{.}}} {{/swiftSourceFiles}}" - + " -import-underlying-module" // Implicitly imports the Objective-C half of a module - + " -enable-objc-interop" - + " -sdk {{env.SYSROOT}}" // Compile against - + " -target {{swiftTarget}}" // Generate code for the given target , such as x86_64-apple-macos10.9 - + " -enable-bare-slash-regex" // Enable the use of forward slash regular-expression literal syntax (https://developer.apple.com/documentation/xcode/build-settings-reference#Enable-Bare-Slash-Regex-Literals) - + " -swift-version {{swiftVersion}}" // Interpret input according to a specific Swift language version number - + " -o{{tgt}}" // Write output to - + " -DCOCOAPODS" - + " -DSWIFT_PACKAGE" - + " {{#includes}}-I{{{.}}} {{/includes}}" - + " {{#platformIncludes}}-I{{.}} {{/platformIncludes}}" - + " {{#ext.includes}}-I{{{.}}} {{/ext.includes}}"; - private File addCompileFileSwift(PodSpec pod, int index, File src, Map manifestContext, List commands) throws IOException, InterruptedException, ExtenderException { File o = new File(buildDirectory, String.format("%s_%d.o", src.getName(), index)); @@ -678,9 +608,8 @@ private File addCompileFileSwift(PodSpec pod, int index, File src, Map