From 3a14448e09811c47658ae73b11ca3935949ab2ea Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Tue, 9 May 2023 22:20:19 -0400 Subject: [PATCH 1/8] Test release --- tasks/e2e.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/e2e.rb b/tasks/e2e.rb index 9aef28bb..d61ca876 100644 --- a/tasks/e2e.rb +++ b/tasks/e2e.rb @@ -61,7 +61,7 @@ clean_git # Run integrate the project system("pwd") - system("#{XCRC_BINARIES}/xcprepare integrate --input StandaloneApp.xcodeproj --mode producer --final-producer-target StandaloneApp") + system("#{XCRC_BINARIES}/xcprepare integrate --input StandaloneApp.xcodeproj --mode producer") # Build the project to fill in the cache build_project(nil, "StandaloneApp.xcodeproj", 'WatchExtension', 'watch', 'watchOS') build_project(nil, "StandaloneApp.xcodeproj", 'StandaloneApp') @@ -78,7 +78,7 @@ prepare_for_standalone(consumer_srcroot) Dir.chdir(consumer_srcroot) do - system("#{XCRC_BINARIES}/xcprepare integrate --input StandaloneApp.xcodeproj --mode consumer") + system("#{XCRC_BINARIES}/xcprepare integrate --input StandaloneApp.xcodeproj --mode consumer --final-producer-target StandaloneApp --consumer-eligible-configurations Release --configurations-exclude Debug") build_project(nil, "StandaloneApp.xcodeproj", 'WatchExtension', 'watch', 'watchOS', {'derivedDataPath' => "#{DERIVED_DATA_PATH}_consumer"}) build_project(nil, "StandaloneApp.xcodeproj", 'StandaloneApp', 'iphone', 'iOS', {'derivedDataPath' => "#{DERIVED_DATA_PATH}_consumer"}) valide_hit_rate(OpenStruct.new(DEFAULT_EXPECTATIONS)) @@ -172,7 +172,7 @@ def self.build_project(workspace, project, scheme, sdk = 'iphone', platform = 'i 'workspace' => workspace, 'project' => project, 'scheme' => scheme, - 'configuration' => 'Debug', + 'configuration' => 'Release', 'sdk' => "#{sdk}simulator", 'destination' => "generic/platform=#{platform} Simulator", 'derivedDataPath' => DERIVED_DATA_PATH, From 8284f516deeff4ec6049556c20dd71dd364c9236 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Tue, 9 May 2023 22:45:35 -0400 Subject: [PATCH 2/8] mark --- tasks/e2e.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/e2e.rb b/tasks/e2e.rb index d61ca876..e5f16a14 100644 --- a/tasks/e2e.rb +++ b/tasks/e2e.rb @@ -66,6 +66,7 @@ build_project(nil, "StandaloneApp.xcodeproj", 'WatchExtension', 'watch', 'watchOS') build_project(nil, "StandaloneApp.xcodeproj", 'StandaloneApp') system("#{XCRC_BINARIES}/xcprepare stats --reset --format json") + system("#{XCRC_BINARIES}/xcprepare mark --configuration Release --platform iphonesimulator") end puts 'Building standalone consumer...' From 3617f2a7a95d32b82806eacbda395ae6219864b7 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Tue, 9 May 2023 23:05:21 -0400 Subject: [PATCH 3/8] Exclude debug in producer --- tasks/e2e.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/e2e.rb b/tasks/e2e.rb index e5f16a14..9ff94ecc 100644 --- a/tasks/e2e.rb +++ b/tasks/e2e.rb @@ -61,7 +61,7 @@ clean_git # Run integrate the project system("pwd") - system("#{XCRC_BINARIES}/xcprepare integrate --input StandaloneApp.xcodeproj --mode producer") + system("#{XCRC_BINARIES}/xcprepare integrate --input StandaloneApp.xcodeproj --mode producer --configurations-exclude Debug") # Build the project to fill in the cache build_project(nil, "StandaloneApp.xcodeproj", 'WatchExtension', 'watch', 'watchOS') build_project(nil, "StandaloneApp.xcodeproj", 'StandaloneApp') From dbd0f98564b25d42b154fdfdc5484c09f3939823 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Tue, 9 May 2023 23:20:57 -0400 Subject: [PATCH 4/8] Add version fallback --- .../Libtool/FallbackXCLibtoolLogic.swift | 38 +++++++++++++++++++ .../Commands/Libtool/XCLibtool.swift | 4 ++ .../Dependencies/CacheModeController.swift | 2 +- .../xclibtoolSupport/XCLibtoolHelper.swift | 6 +++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift diff --git a/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift b/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift new file mode 100644 index 00000000..a73585c7 --- /dev/null +++ b/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift @@ -0,0 +1,38 @@ +// Copyright (c) 2023 Spotify AB. +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import Foundation + +class FallbackXCLibtoolLogic: XCLibtoolLogic { + private let fallbackCommand: String + + init(fallbackCommand: String) { + self.fallbackCommand = fallbackCommand + } + + func run() { + let args = ProcessInfo().arguments + let paramList = [fallbackCommand] + args.dropFirst() + let cargs = paramList.map { strdup($0) } + [nil] + execvp(fallbackCommand, cargs) + + /// C-function `execv` returns only when the command fails + exit(1) + } +} diff --git a/Sources/XCRemoteCache/Commands/Libtool/XCLibtool.swift b/Sources/XCRemoteCache/Commands/Libtool/XCLibtool.swift index 306818ca..47fed04f 100644 --- a/Sources/XCRemoteCache/Commands/Libtool/XCLibtool.swift +++ b/Sources/XCRemoteCache/Commands/Libtool/XCLibtool.swift @@ -25,6 +25,8 @@ public enum XCLibtoolMode: Equatable { case createLibrary(output: String, filelist: String, dependencyInfo: String) /// Creating a universal library (multiple-architectures) from a set of input .a static libraries case createUniversalBinary(output: String, inputs: [String]) + /// print the toolchain version + case version } public class XCLibtool { @@ -50,6 +52,8 @@ public class XCLibtool { toolName: "Libtool", fallbackCommand: "libtool" ) + case .version: + logic = FallbackXCLibtoolLogic(fallbackCommand: "libtool") } } diff --git a/Sources/XCRemoteCache/Dependencies/CacheModeController.swift b/Sources/XCRemoteCache/Dependencies/CacheModeController.swift index 71f527f4..db8871c3 100644 --- a/Sources/XCRemoteCache/Dependencies/CacheModeController.swift +++ b/Sources/XCRemoteCache/Dependencies/CacheModeController.swift @@ -110,7 +110,7 @@ class PhaseCacheModeController: CacheModeController { } catch { // Gracefully don't disable a cache // That may happen if building a target for the first time - errorLog("Couldn't verify if should disable RC for \(commitValue).") + debugLog("Couldn't verify if should disable RC for \(commitValue).") } return false } diff --git a/Sources/xclibtoolSupport/XCLibtoolHelper.swift b/Sources/xclibtoolSupport/XCLibtoolHelper.swift index fa5a92f0..6ed8e9d0 100644 --- a/Sources/xclibtoolSupport/XCLibtoolHelper.swift +++ b/Sources/xclibtoolSupport/XCLibtoolHelper.swift @@ -32,9 +32,12 @@ public class XCLibtoolHelper { var inputLibraries: [String] = [] var filelist: String? var dependencyInfo: String? + var asksForVersion = false var i = 0 while i < args.count { switch args[i] { + case "-V": + asksForVersion = true case "-o": output = args[i + 1] i += 1 @@ -52,6 +55,9 @@ public class XCLibtoolHelper { } i += 1 } + if asksForVersion { + return .version + } guard let outputInput = output else { throw XCLibtoolHelperError.missingOutput } From 1c9d8927a7c8041f3104eeccb7893c095ecc5f57 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Thu, 11 May 2023 21:32:26 -0400 Subject: [PATCH 5/8] Fix debug/Release --- tasks/e2e.rb | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tasks/e2e.rb b/tasks/e2e.rb index 9ff94ecc..8413ad94 100644 --- a/tasks/e2e.rb +++ b/tasks/e2e.rb @@ -52,6 +52,7 @@ clean_server start_nginx configure_git + configuration = 'Release' # Prepare binaries for the standalone mode prepare_for_standalone(E2E_STANDALONE_SAMPLE_DIR) @@ -63,8 +64,8 @@ system("pwd") system("#{XCRC_BINARIES}/xcprepare integrate --input StandaloneApp.xcodeproj --mode producer --configurations-exclude Debug") # Build the project to fill in the cache - build_project(nil, "StandaloneApp.xcodeproj", 'WatchExtension', 'watch', 'watchOS') - build_project(nil, "StandaloneApp.xcodeproj", 'StandaloneApp') + build_project(nil, "StandaloneApp.xcodeproj", 'WatchExtension', 'watch', 'watchOS', configuration) + build_project(nil, "StandaloneApp.xcodeproj", 'StandaloneApp', 'iphone', 'iOS', configuration) system("#{XCRC_BINARIES}/xcprepare stats --reset --format json") system("#{XCRC_BINARIES}/xcprepare mark --configuration Release --platform iphonesimulator") end @@ -80,15 +81,15 @@ prepare_for_standalone(consumer_srcroot) Dir.chdir(consumer_srcroot) do system("#{XCRC_BINARIES}/xcprepare integrate --input StandaloneApp.xcodeproj --mode consumer --final-producer-target StandaloneApp --consumer-eligible-configurations Release --configurations-exclude Debug") - build_project(nil, "StandaloneApp.xcodeproj", 'WatchExtension', 'watch', 'watchOS', {'derivedDataPath' => "#{DERIVED_DATA_PATH}_consumer"}) - build_project(nil, "StandaloneApp.xcodeproj", 'StandaloneApp', 'iphone', 'iOS', {'derivedDataPath' => "#{DERIVED_DATA_PATH}_consumer"}) + build_project(nil, "StandaloneApp.xcodeproj", 'WatchExtension', 'watch', 'watchOS', configuration, {'derivedDataPath' => "#{DERIVED_DATA_PATH}_consumer"}) + build_project(nil, "StandaloneApp.xcodeproj", 'StandaloneApp', 'iphone', 'iOS', configuration, {'derivedDataPath' => "#{DERIVED_DATA_PATH}_consumer"}) valide_hit_rate(OpenStruct.new(DEFAULT_EXPECTATIONS)) puts 'Building standalone consumer with local change...' # Extra: validate local compilation of the Standalone ObjC code system("echo '' >> StandaloneApp/StandaloneObjc.m") - build_project(nil, "StandaloneApp.xcodeproj", 'WatchExtension', 'watch', 'watchOS', {'derivedDataPath' => "#{DERIVED_DATA_PATH}_consumer_local"}) - build_project(nil, "StandaloneApp.xcodeproj", 'StandaloneApp', 'iphone', 'iOS', {'derivedDataPath' => "#{DERIVED_DATA_PATH}_consumer_local"}) + build_project(nil, "StandaloneApp.xcodeproj", 'WatchExtension', 'watch', 'watchOS', configuration, {'derivedDataPath' => "#{DERIVED_DATA_PATH}_consumer_local"}) + build_project(nil, "StandaloneApp.xcodeproj", 'StandaloneApp', 'iphone', 'iOS', configuration, {'derivedDataPath' => "#{DERIVED_DATA_PATH}_consumer_local"}) end # Revert all side effects @@ -168,12 +169,12 @@ def self.dump_podfile(config, source) end end - def self.build_project(workspace, project, scheme, sdk = 'iphone', platform = 'iOS', extra_args = {}) + def self.build_project(workspace, project, scheme, sdk = 'iphone', platform = 'iOS', configuration = 'Debug', extra_args = {}) xcodebuild_args = { 'workspace' => workspace, 'project' => project, 'scheme' => scheme, - 'configuration' => 'Release', + 'configuration' => configuration, 'sdk' => "#{sdk}simulator", 'destination' => "generic/platform=#{platform} Simulator", 'derivedDataPath' => DERIVED_DATA_PATH, @@ -194,9 +195,9 @@ def self.build_project(workspace, project, scheme, sdk = 'iphone', platform = 'i end end - def self.build_project_cocoapods(sdk = 'iphone', platform = 'iOS', extra_args = {}) + def self.build_project_cocoapods(sdk = 'iphone', platform = 'iOS', configuration = 'Debug', extra_args = {}) system('pod install') - build_project('XCRemoteCacheSample.xcworkspace', nil, 'XCRemoteCacheSample', sdk, platform, extra_args) + build_project('XCRemoteCacheSample.xcworkspace', nil, 'XCRemoteCacheSample', sdk, platform, configuration, extra_args) end def self.read_stats @@ -249,7 +250,7 @@ def self.run_cocoapods_scenario(template_path) dump_podfile(consumer_configuration, template_path) puts('Building consumer ...') Dir.chdir(E2E_COCOAPODS_SAMPLE_DIR) do - build_project_cocoapods('iphone', 'iOS', {'derivedDataPath' => "#{DERIVED_DATA_PATH}_consumer"}) + build_project_cocoapods('iphone', 'iOS', 'Debug', {'derivedDataPath' => "#{DERIVED_DATA_PATH}_consumer"}) valide_hit_rate(expectations) end end From 1d497c684ae75d8c31f6522ea125de29b1bcf112 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Thu, 11 May 2023 21:35:34 -0400 Subject: [PATCH 6/8] Fix linting --- .../XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift b/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift index a73585c7..22987c88 100644 --- a/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift +++ b/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift @@ -32,7 +32,7 @@ class FallbackXCLibtoolLogic: XCLibtoolLogic { let cargs = paramList.map { strdup($0) } + [nil] execvp(fallbackCommand, cargs) - /// C-function `execv` returns only when the command fails + /// C-function execv returns only when the command fails exit(1) } } From 525673833b3080a1e62f4c348870b72d99fd3042 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Thu, 11 May 2023 21:57:04 -0400 Subject: [PATCH 7/8] Fix linting --- .../XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift b/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift index 22987c88..d7d6521c 100644 --- a/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift +++ b/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift @@ -30,9 +30,9 @@ class FallbackXCLibtoolLogic: XCLibtoolLogic { let args = ProcessInfo().arguments let paramList = [fallbackCommand] + args.dropFirst() let cargs = paramList.map { strdup($0) } + [nil] + /// C-function `execv`` returns only when the command fails execvp(fallbackCommand, cargs) - /// C-function execv returns only when the command fails exit(1) } } From 9ac67c2934e2fbfe892bac6c384b2bd652cc7291 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Thu, 11 May 2023 22:01:57 -0400 Subject: [PATCH 8/8] Fix linting --- .../XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift b/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift index d7d6521c..0af7e49f 100644 --- a/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift +++ b/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift @@ -30,7 +30,6 @@ class FallbackXCLibtoolLogic: XCLibtoolLogic { let args = ProcessInfo().arguments let paramList = [fallbackCommand] + args.dropFirst() let cargs = paramList.map { strdup($0) } + [nil] - /// C-function `execv`` returns only when the command fails execvp(fallbackCommand, cargs) exit(1)