Skip to content

Commit

Permalink
Merge pull request Carthage#580 from Carthage/no-only-active-arch
Browse files Browse the repository at this point in the history
Set ONLY_ACTIVE_ARCH=NO when building
  • Loading branch information
jspahrsummers committed Jul 17, 2015
2 parents d2655f3 + 69beb6f commit ad8740f
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions Source/CarthageKit/Xcode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ public struct BuildArguments {
/// The platform SDK to build for.
public var sdk: SDK?

/// The build setting whether the product includes only object code for
/// the native architecture.
public var onlyActiveArchitecture: OnlyActiveArchitecture = .NotSpecified

public init(project: ProjectLocator, scheme: String? = nil, configuration: String? = nil, sdk: SDK? = nil) {
self.project = project
self.scheme = scheme
Expand All @@ -122,6 +126,8 @@ public struct BuildArguments {
args += sdk.arguments
}

args += onlyActiveArchitecture.arguments

return args
}
}
Expand Down Expand Up @@ -389,6 +395,34 @@ extension SDK: Printable {
}
}

/// Represents a build setting whether the product includes only object code
/// for the native architecture.
public enum OnlyActiveArchitecture {
/// Not specified.
case NotSpecified

/// The product includes only code for the native architecture.
case Yes

/// The product includes code for its target's valid architectures.
case No

/// The arguments that should be passed to `xcodebuild` to specify the
/// setting for this case.
private var arguments: [String] {
switch self {
case .NotSpecified:
return []

case .Yes:
return [ "ONLY_ACTIVE_ARCH=YES" ]

case .No:
return [ "ONLY_ACTIVE_ARCH=NO" ]
}
}
}

/// Describes the type of product built by an Xcode target.
public enum ProductType: String {
/// A framework bundle.
Expand Down Expand Up @@ -753,16 +787,19 @@ public func buildScheme(scheme: String, withConfiguration configuration: String,

let buildArgs = BuildArguments(project: project, scheme: scheme, configuration: configuration)
let buildSDK = { (sdk: SDK) -> SignalProducer<TaskEvent<BuildSettings>, CarthageError> in
var copiedArgs = buildArgs
copiedArgs.sdk = sdk
var argsForLoading = buildArgs
argsForLoading.sdk = sdk

var argsForBuilding = argsForLoading
argsForBuilding.onlyActiveArchitecture = .No

var buildScheme = xcodebuildTask("build", copiedArgs)
var buildScheme = xcodebuildTask("build", argsForBuilding)
buildScheme.workingDirectoryPath = workingDirectoryURL.path!

return launchTask(buildScheme)
|> mapError { .TaskError($0) }
|> flatMapTaskEvents(.Concat) { _ in
return BuildSettings.loadWithArguments(copiedArgs)
return BuildSettings.loadWithArguments(argsForLoading)
|> filter { settings in
// Only copy build products for the product types we care about.
if let productType = settings.productType.value {
Expand Down

0 comments on commit ad8740f

Please sign in to comment.