diff --git a/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift b/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift new file mode 100644 index 00000000..0af7e49f --- /dev/null +++ b/Sources/XCRemoteCache/Commands/Libtool/FallbackXCLibtoolLogic.swift @@ -0,0 +1,37 @@ +// 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) + + 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 } diff --git a/tasks/e2e.rb b/tasks/e2e.rb index 9aef28bb..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) @@ -61,11 +62,12 @@ 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 --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 puts 'Building standalone consumer...' @@ -78,16 +80,16 @@ prepare_for_standalone(consumer_srcroot) Dir.chdir(consumer_srcroot) do - system("#{XCRC_BINARIES}/xcprepare integrate --input StandaloneApp.xcodeproj --mode consumer") - 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"}) + 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', 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 @@ -167,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' => 'Debug', + 'configuration' => configuration, 'sdk' => "#{sdk}simulator", 'destination' => "generic/platform=#{platform} Simulator", 'derivedDataPath' => DERIVED_DATA_PATH, @@ -193,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 @@ -248,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