-
Notifications
You must be signed in to change notification settings - Fork 32
/
CachedBuilderService.swift
43 lines (37 loc) · 2.1 KB
/
CachedBuilderService.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Foundation
final class CachedBuilderService {
private let frameworkCachingService: FrameworkCachingService
private let carthageBuilderService: CarthageBuilderService
init(sharedCachePath: String?) {
self.frameworkCachingService = FrameworkCachingService(sharedCachePath: sharedCachePath)
self.carthageBuilderService = CarthageBuilderService(frameworkCachingService: frameworkCachingService)
}
func frameworkProducts(manifest: Manifest, appTarget: AppTarget, dependencyGraph: DependencyGraph, platform: Platform) throws -> [FrameworkProduct] {
var frameworkProducts: [FrameworkProduct] = []
for framework in try appTarget.frameworkDependencies(manifest: manifest, dependencyGraph: dependencyGraph).flattenedDeepFirstOrder() {
if let cachedFrameworkProduct = try frameworkCachingService.cachedProduct(framework: framework, platform: platform) {
frameworkProducts.append(cachedFrameworkProduct)
} else {
switch try InstallationTypeDetectorService.shared.detectInstallationType(for: framework) {
case .swiftPackageManager:
try XcodeProjectGeneratorService.shared.generateXcodeProject(framework: framework)
let frameworkProduct = try carthageBuilderService.build(
framework: framework,
platform: platform,
alreadyBuiltFrameworkProducts: frameworkProducts
)
frameworkProducts.append(frameworkProduct)
case .carthage:
try GitResetService.shared.resetGit(atPath: framework.projectDirectory, includeUntrackedFiles: false)
let frameworkProduct = try carthageBuilderService.build(
framework: framework,
platform: platform,
alreadyBuiltFrameworkProducts: frameworkProducts
)
frameworkProducts.append(frameworkProduct)
}
}
}
return frameworkProducts
}
}