Merge pull request #5 from CognitiveDisson/fix-cache-miss-for-xcode13
Add ACTION env check for prebuild and postbuild
This commit is contained in:
@@ -29,6 +29,12 @@ enum MachOType: String, Codable {
|
||||
case unknown
|
||||
}
|
||||
|
||||
enum PostbuildActionType: String, Codable {
|
||||
case build
|
||||
case index = "indexbuild"
|
||||
case unknown
|
||||
}
|
||||
|
||||
enum PostbuildContextError: Error {
|
||||
/// URL address is not a valid URL
|
||||
case invalidAddress(String)
|
||||
@@ -71,6 +77,8 @@ public struct PostbuildContext {
|
||||
let derivedSourcesDir: URL
|
||||
/// List of all targets to downloaded from the thinning aggregation target
|
||||
var thinnedTargets: [String]
|
||||
/// Action type: build, indexbuild etc.
|
||||
var action: PostbuildActionType = .unknown
|
||||
}
|
||||
|
||||
extension PostbuildContext {
|
||||
@@ -112,5 +120,10 @@ extension PostbuildContext {
|
||||
derivedSourcesDir = try env.readEnv(key: "DERIVED_SOURCES_DIR")
|
||||
let thinFocusedTargetsString: String = env.readEnv(key: "SPT_XCREMOTE_CACHE_THINNED_TARGETS") ?? ""
|
||||
thinnedTargets = thinFocusedTargetsString.split(separator: ",").map(String.init)
|
||||
if let rawAction = env.readEnv(key: "ACTION") {
|
||||
action = PostbuildActionType(rawValue: rawAction) ?? .unknown
|
||||
} else {
|
||||
action = .unknown
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,11 @@ public class XCPostbuild {
|
||||
exit(1, "FATAL: Postbuild initialization failed with error: \(error)")
|
||||
}
|
||||
|
||||
guard context.action != .index else {
|
||||
printToUser("Indexbuild. Skip remote cache")
|
||||
exit(0)
|
||||
}
|
||||
|
||||
// Postbuild cannot disable marker, so NoopMarkerWriter used instead of a real file writer
|
||||
let modeController = PhaseCacheModeController(
|
||||
tempDir: context.targetTempDir,
|
||||
|
||||
@@ -24,6 +24,12 @@ enum PrebuildContextError: Error {
|
||||
case invalidAddress(String)
|
||||
}
|
||||
|
||||
enum PrebuildActionType: String, Codable {
|
||||
case build
|
||||
case index = "indexbuild"
|
||||
case unknown
|
||||
}
|
||||
|
||||
public struct PrebuildContext {
|
||||
let targetTempDir: URL
|
||||
let productsDir: URL
|
||||
@@ -43,6 +49,8 @@ public struct PrebuildContext {
|
||||
let targetName: String
|
||||
/// List of all targets to downloaded from the thinning aggregation target
|
||||
var thinnedTargets: [String]?
|
||||
/// Action type: build, indexbuild etc.
|
||||
var action: PrebuildActionType = .unknown
|
||||
}
|
||||
|
||||
extension PrebuildContext {
|
||||
@@ -64,5 +72,10 @@ extension PrebuildContext {
|
||||
self.targetName = targetName
|
||||
let thinFocusedTargetsString: String? = env.readEnv(key: "SPT_XCREMOTE_CACHE_THINNED_TARGETS")
|
||||
thinnedTargets = thinFocusedTargetsString?.split(separator: ",").map(String.init)
|
||||
if let rawAction = env.readEnv(key: "ACTION") {
|
||||
action = PrebuildActionType(rawValue: rawAction) ?? .unknown
|
||||
} else {
|
||||
action = .unknown
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,11 @@ public class XCPrebuild {
|
||||
exit(1, "FATAL: Prebuild initialization failed with error: \(error)")
|
||||
}
|
||||
|
||||
guard context.action != .index else {
|
||||
printToUser("Indexbuild. Skip remote cache")
|
||||
exit(0)
|
||||
}
|
||||
|
||||
// Xcode may call xcprebuild phase even none of compilation files has changed (e.g. when switching between
|
||||
// simulator versions) and modifying 'mdate' of a marker file unnecessary invalidates compilation steps
|
||||
// that have to repeat their "use-from-cache" flow
|
||||
|
||||
Reference in New Issue
Block a user