-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't require xcodegen settings preset files. All configuration shoul… #84
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,9 @@ struct Setting<T: XCSettingStringEncodeable & Semigroup>: Semigroup { | |
} | ||
} | ||
|
||
|
||
|
||
|
||
struct XCBuildSettings: Encodable { | ||
var copts: [String] = [] | ||
var productName: First<String>? | ||
|
@@ -163,6 +166,11 @@ struct XCBuildSettings: Encodable { | |
var useHeaderMap: First<String>? = First("NO") | ||
var testTargetName: First<String>? | ||
var pythonPath: First<String>? | ||
var sdkRoot: First<String>? | ||
var targetedDeviceFamily: OrderedArray<String> = OrderedArray.empty | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: remove spaces? |
||
|
||
|
||
|
||
enum CodingKeys: String, CodingKey { | ||
// Add to this list the known XCConfig keys | ||
|
@@ -201,6 +209,9 @@ struct XCBuildSettings: Encodable { | |
case codeSignEntitlementsFile = "HAMMER_ENTITLEMENTS_FILE" | ||
case mobileProvisionProfileFile = "HAMMER_PROFILE_FILE" | ||
case tulsiWR = "TULSI_WR" | ||
case sdkRoot = "SDKROOT" | ||
case targetedDeviceFamily = "TARGETED_DEVICE_FAMILY" | ||
|
||
} | ||
|
||
func encode(to encoder: Encoder) throws { | ||
|
@@ -244,6 +255,8 @@ struct XCBuildSettings: Encodable { | |
try useHeaderMap.map { try container.encode($0.v, forKey: .useHeaderMap) } | ||
try testTargetName.map { try container.encode($0.v, forKey: .testTargetName) } | ||
try pythonPath.map { try container.encode($0.v, forKey: .pythonPath) } | ||
try sdkRoot.map { try container.encode($0.v, forKey: .sdkRoot) } | ||
try container.encode(targetedDeviceFamily.joined(separator: ","), forKey: .targetedDeviceFamily) | ||
|
||
// XCHammer only supports Xcode projects at the root directory | ||
try container.encode("$SOURCE_ROOT", forKey: .tulsiWR) | ||
|
@@ -288,7 +301,9 @@ extension XCBuildSettings: Monoid { | |
moduleMapFile: lhs.moduleMapFile <> rhs.moduleMapFile, | ||
useHeaderMap: lhs.useHeaderMap <> rhs.useHeaderMap, | ||
testTargetName: lhs.testTargetName <> rhs.testTargetName, | ||
pythonPath: lhs.pythonPath <> rhs.pythonPath | ||
pythonPath: lhs.pythonPath <> rhs.pythonPath, | ||
sdkRoot: lhs.sdkRoot <> rhs.sdkRoot, | ||
targetedDeviceFamily: lhs.targetedDeviceFamily <> rhs.targetedDeviceFamily | ||
) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -297,7 +297,7 @@ public class XcodeTarget: Hashable, Equatable { | |
.map { sourceInfo -> String in | ||
return self.getRelativePath(for: sourceInfo) | ||
} | ||
|
||
// This is a massive error if this will not allocate with a string. | ||
let sourceFiles = sourceFilePaths | ||
.filter { !$0.hasSuffix(".modulemap") && !$0.hasSuffix(".hmap") } | ||
|
@@ -338,7 +338,7 @@ public class XcodeTarget: Hashable, Equatable { | |
return [] | ||
} | ||
var visited: Set<XcodeTarget> = [self] | ||
|
||
var transitiveTargets: [XcodeTarget] = [] | ||
var queue = unfilteredDependencies | ||
while let xcodeTarget = queue.first { | ||
|
@@ -365,7 +365,7 @@ public class XcodeTarget: Hashable, Equatable { | |
|
||
func makePathFiltersTransitionPredicate(paths: Set<String>) -> TraversalTransitionPredicate<XcodeTarget> { | ||
let pathPredicate = makePathFiltersPredicate(paths) | ||
return TraversalTransitionPredicate { xcodeTarget -> Transition in | ||
return TraversalTransitionPredicate { xcodeTarget -> Transition in | ||
guard let buildFilePath = xcodeTarget.buildFilePath else { | ||
fatalError() | ||
} | ||
|
@@ -457,7 +457,7 @@ public class XcodeTarget: Hashable, Equatable { | |
case .StaticLibrary: | ||
return xcTargetName | ||
default: | ||
fatalError() | ||
return "$(TARGET_NAME)" | ||
} | ||
} | ||
|
||
|
@@ -599,8 +599,14 @@ public class XcodeTarget: Hashable, Equatable { | |
} | ||
|
||
// Product Name | ||
|
||
settings.productName <>= self.bundleName.map { First($0) } | ||
|
||
if settings.productName == nil { | ||
settings.productName = First(self.extractBuiltProductName()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this code path ever be hit? It doesn't seem like it if you set the value in the initializer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it will now that there isn't a default value |
||
} | ||
|
||
|
||
// Product Bundle Identifier | ||
settings.productBundleId <>= self.bundleID.map { First($0) } | ||
|
||
|
@@ -645,13 +651,24 @@ public class XcodeTarget: Hashable, Equatable { | |
// Set thes deployment target if available | ||
if let deploymentTgt = self.deploymentTarget { | ||
switch deploymentTgt.platform { | ||
case .ios: settings.iOSDeploymentTarget <>= First(deploymentTgt.osVersion) | ||
case .tvos: settings.tvOSDeploymentTarget <>= First(deploymentTgt.osVersion) | ||
case .watchos: settings.watchOSDeploymentTarget <>= First(deploymentTgt.osVersion) | ||
case .macos: settings.macOSDeploymentTarget <>= First(deploymentTgt.osVersion) | ||
case .ios: | ||
settings.iOSDeploymentTarget <>= First(deploymentTgt.osVersion) | ||
settings.sdkRoot <>= First("iphoneos") | ||
settings.targetedDeviceFamily <>= ["1", "2"] | ||
case .tvos: | ||
settings.tvOSDeploymentTarget <>= First(deploymentTgt.osVersion) | ||
settings.sdkRoot <>= First("appletvos") | ||
settings.targetedDeviceFamily <>= ["3"] | ||
case .watchos: | ||
settings.watchOSDeploymentTarget <>= First(deploymentTgt.osVersion) | ||
settings.sdkRoot <>= First("watchos") | ||
settings.targetedDeviceFamily <>= ["4"] | ||
case .macos: | ||
settings.macOSDeploymentTarget <>= First(deploymentTgt.osVersion) | ||
settings.sdkRoot <>= First("macosx") | ||
} | ||
} | ||
|
||
// Add defines as copts | ||
settings.copts <>= processDefines(defines: self.extractDefines(map: targetMap)) | ||
|
||
|
@@ -826,7 +843,7 @@ public class XcodeTarget: Hashable, Equatable { | |
bundle_id = "\(bundleID)", | ||
platform_type = \"ios\" | ||
) | ||
""" | ||
""" | ||
} | ||
} | ||
|
||
|
@@ -848,7 +865,7 @@ public class XcodeTarget: Hashable, Equatable { | |
entitlements: entitlements, | ||
provisioningProfile: provisioningProfile, | ||
bundleID: bundleID) | ||
return exportEntitlements | ||
return exportEntitlements | ||
} | ||
|
||
func extractCodeSignEntitlementsFile(genOptions: XCHammerGenerateOptions) -> String? { | ||
|
@@ -936,7 +953,7 @@ public class XcodeTarget: Hashable, Equatable { | |
// Assume extensions are contained in the same workspace | ||
return extensions | ||
.compactMap { targetMap.xcodeTarget(buildLabel: $0, depender: self) } | ||
.map { | ||
.map { | ||
var mutableDep = ProjectSpec.Dependency(type: .target, reference: $0.xcTargetName, | ||
embed: $0.isExtension) | ||
mutableDep.codeSign = false | ||
|
@@ -989,6 +1006,7 @@ public class XcodeTarget: Hashable, Equatable { | |
] | ||
|
||
guard let productType = BuildTypeToTargetType[self.type] else { | ||
print("Unknown product type: \(self.type). Unable to extract xcode equivalent") | ||
return nil | ||
} | ||
return productType | ||
|
@@ -1049,7 +1067,7 @@ public class XcodeTarget: Hashable, Equatable { | |
// Minimal settings for this build | ||
var settings = XCBuildSettings() | ||
settings.codeSigningRequired <>= First("NO") | ||
|
||
settings.productName <>= First("$(TARGET_NAME)") | ||
// A custom XCHammerAsset bazel_build_settings.py is loaded by bazel_build.py | ||
settings.pythonPath = | ||
First("${PYTHONPATH}:$(PROJECT_FILE_PATH)/XCHammerAssets") | ||
|
@@ -1199,7 +1217,7 @@ public func makeXcodeGenTarget(from xcodeTarget: XcodeTarget) -> ProjectSpec.Tar | |
return "iOS" | ||
} | ||
}(xcodeTarget) | ||
|
||
return ProjectSpec.Target( | ||
name: xcodeTarget.xcTargetName, | ||
type: PBXProductType(rawValue: productType.rawValue)!, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,29 @@ | ||
load("//UrlGet.xcodeproj/XCHammerAssets:Hammer.bzl", "export_entitlements") | ||
|
||
export_entitlements( | ||
name = "ios-app-share-extension_entitlements", | ||
bundle_id = "Google.UrlGet.ShareExtension", | ||
entitlements = None, | ||
platform_type = "ios", | ||
provisioning_profile = None, | ||
name = "ios-app-strings-extension_entitlements", | ||
entitlements = None, | ||
provisioning_profile = None, | ||
bundle_id = "Google.UrlGet.StringsExtension", | ||
platform_type = "ios" | ||
) | ||
|
||
export_entitlements( | ||
name = "ios-app-strings-extension_entitlements", | ||
bundle_id = "Google.UrlGet.StringsExtension", | ||
entitlements = None, | ||
platform_type = "ios", | ||
provisioning_profile = None, | ||
name = "ios-app-ios-app_entitlements", | ||
entitlements = None, | ||
provisioning_profile = None, | ||
bundle_id = "Google.UrlGet", | ||
platform_type = "ios" | ||
) | ||
|
||
export_entitlements( | ||
name = "ios-app-siri-extension_entitlements", | ||
bundle_id = "Google.UrlGet.SiriExtension", | ||
entitlements = None, | ||
platform_type = "ios", | ||
provisioning_profile = None, | ||
name = "ios-app-share-extension_entitlements", | ||
entitlements = None, | ||
provisioning_profile = None, | ||
bundle_id = "Google.UrlGet.ShareExtension", | ||
platform_type = "ios" | ||
) | ||
|
||
export_entitlements( | ||
name = "ios-app-ios-app_entitlements", | ||
bundle_id = "Google.UrlGet", | ||
entitlements = None, | ||
platform_type = "ios", | ||
provisioning_profile = None, | ||
) | ||
name = "ios-app-siri-extension_entitlements", | ||
entitlements = None, | ||
provisioning_profile = None, | ||
bundle_id = "Google.UrlGet.SiriExtension", | ||
platform_type = "ios" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's an
OrderedArray
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ordered array is poorly named, it's basically an implementation of ordered set that conform to a few protocols used to serialize build settings. We wanted uniqueness with consistent ordering which is why this was originally written, happy to revisit