Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
Remove build settings searching
Browse files Browse the repository at this point in the history
  • Loading branch information
keith committed Oct 19, 2017
1 parent b17a7f2 commit 3d2fe09
Showing 1 changed file with 1 addition and 51 deletions.
52 changes: 1 addition & 51 deletions Sources/XcodeGenKit/SettingsBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,43 +18,19 @@ extension ProjectSpec {
public func getProjectBuildSettings(config: Config) -> BuildSettings {

var buildSettings: BuildSettings = [:]
buildSettings += SettingsPresetFile.base.getBuildSettings()

if let type = config.type {
buildSettings += SettingsPresetFile.config(type).getBuildSettings()
}

buildSettings += getBuildSettings(settings: settings, config: config)

return buildSettings
}

public func getTargetBuildSettings(target: Target, config: Config) -> BuildSettings {
var buildSettings = BuildSettings()

buildSettings += SettingsPresetFile.platform(target.platform).getBuildSettings()
buildSettings += SettingsPresetFile.product(target.type).getBuildSettings()
buildSettings += SettingsPresetFile.productPlatform(target.type, target.platform).getBuildSettings()
buildSettings += getBuildSettings(settings: target.settings, config: config)

return buildSettings
}

public func getBuildSettings(settings: Settings, config: Config) -> BuildSettings {
var buildSettings: BuildSettings = [:]

for group in settings.groups {
if let settings = settingGroups[group] {
buildSettings += getBuildSettings(settings: settings, config: config)
}
}

buildSettings += settings.buildSettings

if let configSettings = settings.configSettings[config.name] {
buildSettings += getBuildSettings(settings: configSettings, config: config)
}

return buildSettings
}

Expand Down Expand Up @@ -89,32 +65,6 @@ private var buildSettingFiles: [String: BuildSettings] = [:]
extension SettingsPresetFile {

public func getBuildSettings() -> BuildSettings? {
if let group = buildSettingFiles[path] {
return group
}
let relativePath = "SettingPresets/\(path).yml"
let possibleSettingsPaths: [Path] = [
Path(relativePath),
Path(Bundle.main.bundlePath) + relativePath,
Path(Bundle.main.bundlePath) + "../share/xcodegen/\(relativePath)",
Path(#file).parent().parent().parent() + relativePath,
]

guard let settingsPath = possibleSettingsPaths.first(where: { $0.exists }) else {
switch self {
case .base, .config, .platform:
print("No \"\(name)\" settings found")
case .product, .productPlatform:
break
}
return nil
}

guard let buildSettings = try? loadYamlDictionary(path: settingsPath) else {
print("Error parsing \"\(name)\" settings")
return nil
}
buildSettingFiles[path] = buildSettings
return buildSettings
return nil
}
}

0 comments on commit 3d2fe09

Please sign in to comment.