From 786999f443623d4b6807c5def98d1f73eb64c712 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Thu, 18 Mar 2021 12:13:35 +0100 Subject: [PATCH 1/8] Update for new binaries --- flank-scripts/build.gradle.kts | 2 +- .../scripts/ops/updatebinaries/UpdateLlvm.kt | 34 ++++++++--------- .../scripts/ops/updatebinaries/UpdateSwift.kt | 37 ++++++++----------- 3 files changed, 34 insertions(+), 39 deletions(-) diff --git a/flank-scripts/build.gradle.kts b/flank-scripts/build.gradle.kts index 91c626ab80..b2a31389e5 100644 --- a/flank-scripts/build.gradle.kts +++ b/flank-scripts/build.gradle.kts @@ -26,7 +26,7 @@ shadowJar.apply { } } // .. -version = "1.9.2" +version = "1.9.3" group = "com.github.flank" application { diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateLlvm.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateLlvm.kt index 7bbfa956ff..19e6f42490 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateLlvm.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateLlvm.kt @@ -9,28 +9,24 @@ import java.nio.file.Paths private val currentPath = Paths.get("") private val llvmPath = Paths.get(currentPath.toString(), "llvm") -fun updateLlvm() = if (isWindows) updateLlvmWindows() else updateLlvmNonWindows() +fun updateLlvm() = if (isWindows) retrieveNMForWindows() else updateLlvmNonWindows() -private fun updateLlvmWindows() { - println(" Will be available after #1134") - /* - TODO finish this in #1134 - val llvmExe = Paths.get(llvmPath.toString(), "LLVM-win64.exe") - if (llvmExe.toFile().exists()) { - println("LLVM exists") +private fun retrieveNMForWindows() { + val binariesPath = Paths.get(currentPath.toString(), "master.zip") + if (binariesPath.toFile().exists()) { + println("Binaries already exists") } else { - println("Downloading Windows LLVM...") - llvmPath.toFile().mkdirs() + println("Downloading binaries for windows...") + binariesPath.toFile().mkdirs() downloadFile( - srcUrl = "https://releases.llvm.org/8.0.0/LLVM-8.0.0-win64.exe", - destinationPath = llvmExe.toString() + sourceUrl = "https://github.com/Flank/binaries/archive/master.zip", + destination = binariesPath.toString() ) } - llvmExe.toFile().extract(llvmPath.toFile(), "zip", "xz") - findAndCopyLlvmLicense() + binariesPath.toFile().extract(binariesPath.toFile(), "zip", "xz") findAndCopyLlvmNmFile() - llvmPath.toFile().deleteRecursively()*/ + llvmPath.toFile().deleteRecursively() } private fun updateLlvmNonWindows() { @@ -66,8 +62,12 @@ private fun findAndCopyLlvmLicense() { } private fun findAndCopyLlvmNmFile() { - val llvmNmSuffix = Paths.get("bin", "llvm-nm").toString() - val llvmNmOutputFile = Paths.get(currentPath.toString(), "nm").toFile() + val llvmNmSuffix = + if (!isWindows) Paths.get("bin", "llvm-nm").toString() else Paths.get("bin", "llvm-nm.exe").toString() + val llvmNmOutputFile = if (!isWindows) Paths.get(currentPath.toString(), "nm").toFile() else Paths.get( + currentPath.toString(), + "nm.exe" + ).toFile() println("Copying llvm nm ...") Files.walk(llvmPath) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateSwift.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateSwift.kt index 8efc5852c5..7441456417 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateSwift.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateSwift.kt @@ -12,26 +12,21 @@ private val swiftPath = Paths.get(currentPath.toString(), "swift") fun updateSwift() = if (isWindows) updateSwiftWindows() else updateSwiftOther() private fun updateSwiftWindows() { - println(" Will be available after #1134") - /* - TODO finish this in #1134 - val swiftExe = Paths.get(swiftPath.toString(), "swift.exe") - - if (swiftExe.toFile().exists()) { - println("Swift exists") - } else { - println("Downloading swift for Windows") - swiftPath.toFile().mkdirs() - downloadFile( - srcUrl = "https://swift.org/builds/swift-5.3-release/windows10/swift-5.3-RELEASE/swift-5.3-RELEASE-windows10.exe", - destinationPath = swiftExe.toString() - ) - } + val binariesPath = Paths.get(currentPath.toString(), "master.zip") + if (binariesPath.toFile().exists()) { + println("Binaries already exists") + } else { + println("Downloading binaries for windows...") + binariesPath.toFile().mkdirs() + downloadFile( + sourceUrl = "https://github.com/Flank/binaries/archive/master.zip", + destination = binariesPath.toString() + ) + } - swiftExe.toFile().extract(swiftPath.toFile(), "zip", "gz") - findAndCopySwiftLicense() - findAndCopySwiftDemangleFile() - swiftPath.toFile().deleteRecursively()*/ + binariesPath.toFile().extract(binariesPath.toFile(), "zip", "xz") + findAndCopySwiftDemangleFile() + swiftPath.toFile().deleteRecursively() } private fun updateSwiftOther() { @@ -67,8 +62,8 @@ private fun findAndCopySwiftLicense() { } private fun findAndCopySwiftDemangleFile() { - val switftDemangleFileSuffix = Paths.get("usr", "bin", "swift-demangle").toString() - val switftDemangleOutputFile = Paths.get(currentPath.toString(), "swift-demangle").toFile() + val switftDemangleFileSuffix = if (isWindows) Paths.get("swift-demangle.exe").toString() else Paths.get("usr", "bin", "swift-demangle").toString() + val switftDemangleOutputFile = if (isWindows) Paths.get(currentPath.toString(), "swift-demangle.exe").toFile() else Paths.get(currentPath.toString(), "swift-demangle").toFile() println("Copying swift-demangle ...") Files.walk(swiftPath) From cf954c43e7c92f8e328df82bcbb02b88460756a3 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 22 Mar 2021 10:19:31 +0100 Subject: [PATCH 2/8] Update --- .../scripts/ops/updatebinaries/UpdateLlvm.kt | 21 +++++++----- .../scripts/ops/updatebinaries/UpdateSwift.kt | 33 ++++++++++++++++--- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateLlvm.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateLlvm.kt index 19e6f42490..3758787c39 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateLlvm.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateLlvm.kt @@ -7,7 +7,9 @@ import java.nio.file.Files import java.nio.file.Paths private val currentPath = Paths.get("") -private val llvmPath = Paths.get(currentPath.toString(), "llvm") +private val llvmPath = + if (isWindows) Paths.get(currentPath.toString(), "master") + else Paths.get(currentPath.toString(), "llvm") fun updateLlvm() = if (isWindows) retrieveNMForWindows() else updateLlvmNonWindows() @@ -17,14 +19,14 @@ private fun retrieveNMForWindows() { println("Binaries already exists") } else { println("Downloading binaries for windows...") - binariesPath.toFile().mkdirs() downloadFile( sourceUrl = "https://github.com/Flank/binaries/archive/master.zip", destination = binariesPath.toString() ) } - - binariesPath.toFile().extract(binariesPath.toFile(), "zip", "xz") + val destinationPath = Paths.get(currentPath.toString(), "master") + destinationPath.toFile().mkdirs() + binariesPath.toFile().extract(destinationPath.toFile(), "zip") findAndCopyLlvmNmFile() llvmPath.toFile().deleteRecursively() } @@ -63,11 +65,12 @@ private fun findAndCopyLlvmLicense() { private fun findAndCopyLlvmNmFile() { val llvmNmSuffix = - if (!isWindows) Paths.get("bin", "llvm-nm").toString() else Paths.get("bin", "llvm-nm.exe").toString() - val llvmNmOutputFile = if (!isWindows) Paths.get(currentPath.toString(), "nm").toFile() else Paths.get( - currentPath.toString(), - "nm.exe" - ).toFile() + if (!isWindows) Paths.get("bin", "llvm-nm").toString() + else Paths.get("master", "binaries-master", "llvm-nm.exe").toString() + + val llvmNmOutputFile = + if (!isWindows) Paths.get(currentPath.toString(), "nm").toFile() + else Paths.get(currentPath.toString(), "nm.exe").toFile() println("Copying llvm nm ...") Files.walk(llvmPath) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateSwift.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateSwift.kt index 7441456417..2b7bb0f677 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateSwift.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateSwift.kt @@ -7,7 +7,9 @@ import java.nio.file.Files import java.nio.file.Paths private val currentPath = Paths.get("") -private val swiftPath = Paths.get(currentPath.toString(), "swift") +private val swiftPath = + if (isWindows) Paths.get(currentPath.toString(), "master-swift") + else Paths.get(currentPath.toString(), "swift") fun updateSwift() = if (isWindows) updateSwiftWindows() else updateSwiftOther() @@ -24,7 +26,9 @@ private fun updateSwiftWindows() { ) } - binariesPath.toFile().extract(binariesPath.toFile(), "zip", "xz") + val destinationPath = Paths.get(currentPath.toString(), "master-swift") + destinationPath.toFile().mkdirs() + binariesPath.toFile().extract(destinationPath.toFile(), "zip") findAndCopySwiftDemangleFile() swiftPath.toFile().deleteRecursively() } @@ -62,8 +66,13 @@ private fun findAndCopySwiftLicense() { } private fun findAndCopySwiftDemangleFile() { - val switftDemangleFileSuffix = if (isWindows) Paths.get("swift-demangle.exe").toString() else Paths.get("usr", "bin", "swift-demangle").toString() - val switftDemangleOutputFile = if (isWindows) Paths.get(currentPath.toString(), "swift-demangle.exe").toFile() else Paths.get(currentPath.toString(), "swift-demangle").toFile() + val switftDemangleFileSuffix = + if (isWindows) Paths.get("master-swift", "binaries-master", "swift-demangle.exe").toString() + else Paths.get("usr", "bin", "swift-demangle").toString() + + val switftDemangleOutputFile = + if (isWindows) Paths.get(currentPath.toString(), "swift-demangle.exe").toFile() + else Paths.get(currentPath.toString(), "swift-demangle").toFile() println("Copying swift-demangle ...") Files.walk(swiftPath) @@ -71,4 +80,20 @@ private fun findAndCopySwiftDemangleFile() { .findFirst() .takeIf { it.isPresent } ?.run { get().toFile().copyTo(switftDemangleOutputFile, overwrite = true) } + + if (isWindows) { + println("Copying Windows DLL files") + findAndCopyWindowsRequiredDLlFile() + } +} + +private fun findAndCopyWindowsRequiredDLlFile() { + val switftDLLFileSuffix = Paths.get("master-swift", "binaries-master", "swiftDemangle.dll").toString() + val switftDLLOutputFile = Paths.get(currentPath.toString(), "swiftDemangle.dll").toFile() + + Files.walk(swiftPath) + .filter { it.toString().endsWith(switftDLLFileSuffix) } + .findFirst() + .takeIf { it.isPresent } + ?.run { get().toFile().copyTo(switftDLLOutputFile, overwrite = true) } } From 96f22c3a484dd701882ae22b557ecf8f20991e97 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 22 Mar 2021 10:24:02 +0100 Subject: [PATCH 3/8] Remove atomic download for windows --- .../kotlin/flank/scripts/ops/updatebinaries/UpdateAtomic.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateAtomic.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateAtomic.kt index 60b8c6edd1..92099a8dc2 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateAtomic.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateAtomic.kt @@ -2,6 +2,7 @@ package flank.scripts.ops.updatebinaries import flank.common.downloadFile import flank.common.extract +import flank.common.isWindows import java.nio.file.Files import java.nio.file.Paths import java.util.stream.Collectors @@ -10,6 +11,8 @@ private val currentPath = Paths.get("") private val atomicPath = Paths.get(currentPath.toString(), "libatomic") fun updateAtomic() { + if (isWindows) return + val atomicDeb = Paths.get(atomicPath.toString(), "libatomic.deb").toFile() val atomicDataTarXz = Paths.get(atomicPath.toString(), "data.tar.xz").toFile() From 50681ebb065ae45daae4e7816be95667f7cec57b Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 22 Mar 2021 11:14:16 +0100 Subject: [PATCH 4/8] minor modifications to include tests & ability to use flank.jar to auth --- .../src/test/kotlin/integration/AllTestFilteredIT.kt | 3 --- integration_tests/src/test/kotlin/integration/DumpShardsIT.kt | 3 --- test_runner/bash/flank.bat | 1 + 3 files changed, 1 insertion(+), 6 deletions(-) create mode 100644 test_runner/bash/flank.bat diff --git a/integration_tests/src/test/kotlin/integration/AllTestFilteredIT.kt b/integration_tests/src/test/kotlin/integration/AllTestFilteredIT.kt index c977bbf9ab..36d22ca270 100644 --- a/integration_tests/src/test/kotlin/integration/AllTestFilteredIT.kt +++ b/integration_tests/src/test/kotlin/integration/AllTestFilteredIT.kt @@ -2,8 +2,6 @@ package integration import FlankCommand import com.google.common.truth.Truth.assertThat -import flank.common.isWindows -import org.junit.Assume.assumeFalse import org.junit.Test import run @@ -31,7 +29,6 @@ class AllTestFilteredIT { @Test fun `filter all tests - ios`() { - assumeFalse(isWindows) val name = "$name-ios" val result = FlankCommand( flankPath = FLANK_JAR_PATH, diff --git a/integration_tests/src/test/kotlin/integration/DumpShardsIT.kt b/integration_tests/src/test/kotlin/integration/DumpShardsIT.kt index ede954c018..a55b0397af 100644 --- a/integration_tests/src/test/kotlin/integration/DumpShardsIT.kt +++ b/integration_tests/src/test/kotlin/integration/DumpShardsIT.kt @@ -2,8 +2,6 @@ package integration import FlankCommand import com.google.common.truth.Truth -import flank.common.isWindows -import org.junit.Assume import org.junit.Test import run import utils.containsAll @@ -57,7 +55,6 @@ class DumpShardsIT { @Test fun `dump shards - ios`() { - Assume.assumeFalse(isWindows) val name = "$name-ios" val result = FlankCommand( flankPath = FLANK_JAR_PATH, diff --git a/test_runner/bash/flank.bat b/test_runner/bash/flank.bat new file mode 100644 index 0000000000..b37a6cdfd8 --- /dev/null +++ b/test_runner/bash/flank.bat @@ -0,0 +1 @@ +java -jar "flank.jar" From f2a3931701c7028e63a524069f46627e0a4989bc Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 22 Mar 2021 11:41:25 +0100 Subject: [PATCH 5/8] Update files to copy --- common/src/main/kotlin/flank/common/Files.kt | 4 +++- .../main/kotlin/ftl/ios/xctest/common/InstallParseBinaries.kt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/common/src/main/kotlin/flank/common/Files.kt b/common/src/main/kotlin/flank/common/Files.kt index 08de6b5bc4..ee8a4a343d 100644 --- a/common/src/main/kotlin/flank/common/Files.kt +++ b/common/src/main/kotlin/flank/common/Files.kt @@ -8,6 +8,7 @@ import java.io.IOException import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths +import java.nio.file.StandardCopyOption val defaultCredentialPath: Path by lazy { Paths.get(userHome, ".config/gcloud/application_default_credentials.json") @@ -36,7 +37,8 @@ fun createCopy(sourceDirectoryLocation: String, destinationDirectoryLocation: St copyDirectory(sourceDirectoryLocation, destinationDirectoryLocation) } -fun createFileCopy(source: String, destination: String): Path = Files.copy(Paths.get(source), Paths.get(destination)) +fun createFileCopy(source: String, destination: String): Path = + Files.copy(Paths.get(source), Paths.get(destination), StandardCopyOption.REPLACE_EXISTING) fun copyDirectory(sourceDirectoryLocation: String, destinationDirectoryLocation: String) { Files.walk(Paths.get(sourceDirectoryLocation)) diff --git a/test_runner/src/main/kotlin/ftl/ios/xctest/common/InstallParseBinaries.kt b/test_runner/src/main/kotlin/ftl/ios/xctest/common/InstallParseBinaries.kt index 0fac5aecd4..1faacbffca 100644 --- a/test_runner/src/main/kotlin/ftl/ios/xctest/common/InstallParseBinaries.kt +++ b/test_runner/src/main/kotlin/ftl/ios/xctest/common/InstallParseBinaries.kt @@ -32,7 +32,7 @@ private fun shouldDownloadBinaries(): Boolean { } private fun neededFilesListByOs(): List = if (isWindows) { - listOf("libatomic.so.1", "libatomic.so.1.2.0") // more files should be added after #1134" + listOf("libatomic.so.1", "libatomic.so.1.2.0", "nm.exe", "swift-demangle.exe", "swiftDemangle.dll") } else { listOf("nm", "swift-demangle", "libatomic.so.1", "libatomic.so.1.2.0") } From 3810bcac3aab5969e66d25d47fb0cbcfd4a299ef Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 22 Mar 2021 12:21:18 +0100 Subject: [PATCH 6/8] Minor fixes --- .../ftl/ios/xctest/common/ParseObjTests.kt | 6 +- .../kotlin/ftl/run/platform/RunIosTests.kt | 71 +++++++++---------- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/test_runner/src/main/kotlin/ftl/ios/xctest/common/ParseObjTests.kt b/test_runner/src/main/kotlin/ftl/ios/xctest/common/ParseObjTests.kt index 04f637eced..f51154f404 100644 --- a/test_runner/src/main/kotlin/ftl/ios/xctest/common/ParseObjTests.kt +++ b/test_runner/src/main/kotlin/ftl/ios/xctest/common/ParseObjTests.kt @@ -1,6 +1,8 @@ package ftl.ios.xctest.common +import flank.common.appDataDirectory import flank.common.isMacOS +import flank.common.isWindows import ftl.util.Bash internal fun parseObjcTests(binary: String): List { @@ -10,8 +12,8 @@ internal fun parseObjcTests(binary: String): List { val results = mutableListOf() // https://github.com/linkedin/bluepill/blob/37e7efa42472222b81adaa0e88f2bd82aa289b44/Source/Shared/BPXCTestFile.m#L18 // must quote binary path in case there are spaces - var cmd = "nm -U ${binary.quote()}" - if (!isMacOS) cmd = "PATH=~/.flank $cmd" + var cmd = if (!isWindows) "nm -U ${binary.quote()}" else "nm.exe -U ${binary.quote()}" + if (!isMacOS) cmd = if (isWindows) "PATH=$appDataDirectory\\.flank $cmd" else "PATH=~/.flank $cmd" val output = Bash.execute(cmd) output.lines().forEach { line -> diff --git a/test_runner/src/main/kotlin/ftl/run/platform/RunIosTests.kt b/test_runner/src/main/kotlin/ftl/run/platform/RunIosTests.kt index c82e12a039..33a15d2bd8 100644 --- a/test_runner/src/main/kotlin/ftl/run/platform/RunIosTests.kt +++ b/test_runner/src/main/kotlin/ftl/run/platform/RunIosTests.kt @@ -33,47 +33,46 @@ import kotlinx.coroutines.flow.toList // https://github.com/bootstraponline/gcloud_cli/blob/5bcba57e825fc98e690281cf69484b7ba4eb668a/google-cloud-sdk/lib/googlecloudsdk/api_lib/firebase/test/ios/matrix_creator.py#L109 // https://cloud.google.com/sdk/gcloud/reference/alpha/firebase/test/ios/run // https://cloud.google.com/sdk/gcloud/reference/alpha/firebase/test/ios/ -internal suspend fun IosArgs.runIosTests(): TestResult = - coroutineScope { - val args = this@runIosTests - val stopwatch = beforeRunTests() +internal suspend fun IosArgs.runIosTests(): TestResult = coroutineScope { + val args = this@runIosTests + val stopwatch = beforeRunTests() - val iosDeviceList = GcIosMatrix.build(devices) + val iosDeviceList = GcIosMatrix.build(devices) - val history = GcToolResults.createToolResultsHistory(args) - val otherGcsFiles = uploadOtherFiles() - val additionalIpasGcsFiles = uploadAdditionalIpas() + val history = GcToolResults.createToolResultsHistory(args) + val otherGcsFiles = uploadOtherFiles() + val additionalIpasGcsFiles = uploadAdditionalIpas() - dumpShardsIfXcTest() - saveToFlankLinks( - shardsFilePath, - FtlConstants.GCS_STORAGE_LINK + join(resultsBucket, resultsDir) - ) - val testShardChunks = xcTestRunData.flattenShardChunks() - logLn(beforeRunMessage(testShardChunks)) - - val result = createIosTestContexts().map { context -> - GcIosTestMatrix.build( - iosDeviceList = iosDeviceList, - args = args, - iosTestContext = context, - toolResultsHistory = history, - otherFiles = otherGcsFiles, - additionalIpasGcsPaths = additionalIpasGcsFiles - ) - }.repeat(repeatTests) - .map { async(Dispatchers.IO) { it.executeWithRetry() } } - .toList() - .awaitAll() + dumpShardsIfXcTest() + saveToFlankLinks( + shardsFilePath, + FtlConstants.GCS_STORAGE_LINK + join(resultsBucket, resultsDir) + ) + val testShardChunks = xcTestRunData.flattenShardChunks() + logLn(beforeRunMessage(testShardChunks)) - TestResult( - matrixMap = afterRunTests( - testMatrices = result, - stopwatch = stopwatch - ), - shardChunks = testShardChunks.testCases + val result = createIosTestContexts().map { context -> + GcIosTestMatrix.build( + iosDeviceList = iosDeviceList, + args = args, + iosTestContext = context, + toolResultsHistory = history, + otherFiles = otherGcsFiles, + additionalIpasGcsPaths = additionalIpasGcsFiles ) - } + }.repeat(repeatTests) + .map { async(Dispatchers.IO) { it.executeWithRetry() } } + .toList() + .awaitAll() + + TestResult( + matrixMap = afterRunTests( + testMatrices = result, + stopwatch = stopwatch + ), + shardChunks = testShardChunks.testCases + ) +} private fun IosArgs.dumpShardsIfXcTest() = takeIf { isXcTest }?.let { dumpShards( From ecd91943a3ec1a62da8fd9432716d643e95a43c1 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Wed, 24 Mar 2021 09:44:26 +0100 Subject: [PATCH 7/8] Remove code as per PR request --- flank-scripts/build.gradle.kts | 2 +- .../scripts/ops/updatebinaries/UpdateLlvm.kt | 34 ++---------- .../scripts/ops/updatebinaries/UpdateSwift.kt | 52 ++----------------- 3 files changed, 11 insertions(+), 77 deletions(-) diff --git a/flank-scripts/build.gradle.kts b/flank-scripts/build.gradle.kts index b2a31389e5..bd2e836407 100644 --- a/flank-scripts/build.gradle.kts +++ b/flank-scripts/build.gradle.kts @@ -26,7 +26,7 @@ shadowJar.apply { } } // .. -version = "1.9.3" +version = "1.9.4" group = "com.github.flank" application { diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateLlvm.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateLlvm.kt index 3758787c39..fe187c318c 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateLlvm.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateLlvm.kt @@ -2,34 +2,14 @@ package flank.scripts.ops.updatebinaries import flank.common.downloadFile import flank.common.extract -import flank.scripts.utils.isWindows +import flank.common.isWindows import java.nio.file.Files import java.nio.file.Paths private val currentPath = Paths.get("") -private val llvmPath = - if (isWindows) Paths.get(currentPath.toString(), "master") - else Paths.get(currentPath.toString(), "llvm") +private val llvmPath = Paths.get(currentPath.toString(), "llvm") -fun updateLlvm() = if (isWindows) retrieveNMForWindows() else updateLlvmNonWindows() - -private fun retrieveNMForWindows() { - val binariesPath = Paths.get(currentPath.toString(), "master.zip") - if (binariesPath.toFile().exists()) { - println("Binaries already exists") - } else { - println("Downloading binaries for windows...") - downloadFile( - sourceUrl = "https://github.com/Flank/binaries/archive/master.zip", - destination = binariesPath.toString() - ) - } - val destinationPath = Paths.get(currentPath.toString(), "master") - destinationPath.toFile().mkdirs() - binariesPath.toFile().extract(destinationPath.toFile(), "zip") - findAndCopyLlvmNmFile() - llvmPath.toFile().deleteRecursively() -} +fun updateLlvm() = if (isWindows) Unit else updateLlvmNonWindows() private fun updateLlvmNonWindows() { val llvmTarXz = Paths.get(llvmPath.toString(), "llvm.tar.xz") @@ -64,13 +44,9 @@ private fun findAndCopyLlvmLicense() { } private fun findAndCopyLlvmNmFile() { - val llvmNmSuffix = - if (!isWindows) Paths.get("bin", "llvm-nm").toString() - else Paths.get("master", "binaries-master", "llvm-nm.exe").toString() + val llvmNmSuffix = Paths.get("bin", "llvm-nm").toString() - val llvmNmOutputFile = - if (!isWindows) Paths.get(currentPath.toString(), "nm").toFile() - else Paths.get(currentPath.toString(), "nm.exe").toFile() + val llvmNmOutputFile = Paths.get(currentPath.toString(), "nm").toFile() println("Copying llvm nm ...") Files.walk(llvmPath) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateSwift.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateSwift.kt index 2b7bb0f677..b74b0c34bc 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateSwift.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/updatebinaries/UpdateSwift.kt @@ -2,36 +2,14 @@ package flank.scripts.ops.updatebinaries import flank.common.downloadFile import flank.common.extract -import flank.scripts.utils.isWindows +import flank.common.isWindows import java.nio.file.Files import java.nio.file.Paths private val currentPath = Paths.get("") -private val swiftPath = - if (isWindows) Paths.get(currentPath.toString(), "master-swift") - else Paths.get(currentPath.toString(), "swift") +private val swiftPath = Paths.get(currentPath.toString(), "swift") -fun updateSwift() = if (isWindows) updateSwiftWindows() else updateSwiftOther() - -private fun updateSwiftWindows() { - val binariesPath = Paths.get(currentPath.toString(), "master.zip") - if (binariesPath.toFile().exists()) { - println("Binaries already exists") - } else { - println("Downloading binaries for windows...") - binariesPath.toFile().mkdirs() - downloadFile( - sourceUrl = "https://github.com/Flank/binaries/archive/master.zip", - destination = binariesPath.toString() - ) - } - - val destinationPath = Paths.get(currentPath.toString(), "master-swift") - destinationPath.toFile().mkdirs() - binariesPath.toFile().extract(destinationPath.toFile(), "zip") - findAndCopySwiftDemangleFile() - swiftPath.toFile().deleteRecursively() -} +fun updateSwift() = if (isWindows) Unit else updateSwiftOther() private fun updateSwiftOther() { val swiftTarGz = Paths.get(swiftPath.toString(), "swift.tar.gz") @@ -66,13 +44,9 @@ private fun findAndCopySwiftLicense() { } private fun findAndCopySwiftDemangleFile() { - val switftDemangleFileSuffix = - if (isWindows) Paths.get("master-swift", "binaries-master", "swift-demangle.exe").toString() - else Paths.get("usr", "bin", "swift-demangle").toString() + val switftDemangleFileSuffix = Paths.get("usr", "bin", "swift-demangle").toString() - val switftDemangleOutputFile = - if (isWindows) Paths.get(currentPath.toString(), "swift-demangle.exe").toFile() - else Paths.get(currentPath.toString(), "swift-demangle").toFile() + val switftDemangleOutputFile = Paths.get(currentPath.toString(), "swift-demangle").toFile() println("Copying swift-demangle ...") Files.walk(swiftPath) @@ -80,20 +54,4 @@ private fun findAndCopySwiftDemangleFile() { .findFirst() .takeIf { it.isPresent } ?.run { get().toFile().copyTo(switftDemangleOutputFile, overwrite = true) } - - if (isWindows) { - println("Copying Windows DLL files") - findAndCopyWindowsRequiredDLlFile() - } -} - -private fun findAndCopyWindowsRequiredDLlFile() { - val switftDLLFileSuffix = Paths.get("master-swift", "binaries-master", "swiftDemangle.dll").toString() - val switftDLLOutputFile = Paths.get(currentPath.toString(), "swiftDemangle.dll").toFile() - - Files.walk(swiftPath) - .filter { it.toString().endsWith(switftDLLFileSuffix) } - .findFirst() - .takeIf { it.isPresent } - ?.run { get().toFile().copyTo(switftDLLOutputFile, overwrite = true) } } From 226b9f2f727096afb10e521ac36237f3c5bfc1bd Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Wed, 24 Mar 2021 09:46:55 +0100 Subject: [PATCH 8/8] Update version number --- flank-scripts/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flank-scripts/build.gradle.kts b/flank-scripts/build.gradle.kts index bd2e836407..6398aada47 100644 --- a/flank-scripts/build.gradle.kts +++ b/flank-scripts/build.gradle.kts @@ -26,7 +26,7 @@ shadowJar.apply { } } // .. -version = "1.9.4" +version = "1.9.5" group = "com.github.flank" application {