Skip to content

Commit 51afd91

Browse files
committed
[llbuild3] Add external CAS database interface
1 parent d7922b0 commit 51afd91

File tree

12 files changed

+341
-28
lines changed

12 files changed

+341
-28
lines changed

llbuild.xcodeproj/project.pbxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@
8383
403552E52C52069300D415BA /* Label.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4072B4CB2C51995100B68221 /* Label.pb.swift */; };
8484
403552EF2C522BAF00D415BA /* Visibility.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 403552EE2C522BA700D415BA /* Visibility.hpp */; settings = {ATTRIBUTES = (Public, ); }; };
8585
403552F12C522F9E00D415BA /* SwiftProtobuf in Frameworks */ = {isa = PBXBuildFile; productRef = 403552F02C522F9E00D415BA /* SwiftProtobuf */; };
86-
4035F55A2CDEABA100337926 /* EngineInternal.proto in Sources */ = {isa = PBXBuildFile; fileRef = 4035F5592CDEAB8100337926 /* EngineInternal.proto */; };
8786
4035F55D2CDEB2F500337926 /* EngineInternal.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4035F55C2CDEB2F500337926 /* EngineInternal.pb.cc */; };
8887
4035F55E2CDEB2F500337926 /* EngineInternal.pb.h in Headers */ = {isa = PBXBuildFile; fileRef = 4035F55B2CDEB2F500337926 /* EngineInternal.pb.h */; };
88+
4035F64B2CF140B000337926 /* CAS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4035F64A2CF140A900337926 /* CAS.swift */; };
8989
403B81602C79047D00CD4F1E /* EngineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 403B815E2C79047D00CD4F1E /* EngineTests.swift */; };
9090
403DC5882C52031D00A9AE24 /* libllbuild3ThirdParty.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4072B4E02C51B3A000B68221 /* libllbuild3ThirdParty.a */; };
9191
4072B5DF2C51BE5100B68221 /* llbuild3.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4072B5D72C51BE5100B68221 /* llbuild3.framework */; };
@@ -1618,6 +1618,7 @@
16181618
4035F55B2CDEB2F500337926 /* EngineInternal.pb.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EngineInternal.pb.h; sourceTree = "<group>"; };
16191619
4035F55C2CDEB2F500337926 /* EngineInternal.pb.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EngineInternal.pb.cc; sourceTree = "<group>"; };
16201620
4035F5CB2CE72F2A00337926 /* README.llbuild3.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.llbuild3.md; sourceTree = "<group>"; };
1621+
4035F64A2CF140A900337926 /* CAS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CAS.swift; sourceTree = "<group>"; };
16211622
40377C7C2061D24200C0FD4D /* Package.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; tabWidth = 4; };
16221623
403B815E2C79047D00CD4F1E /* EngineTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EngineTests.swift; sourceTree = "<group>"; };
16231624
403DB4402C51D07C00A9AE24 /* ProtocolBuffers_iOS.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = ProtocolBuffers_iOS.xcodeproj; sourceTree = "<group>"; };
@@ -5005,6 +5006,7 @@
50055006
40E837E32CCC5FFB0022B026 /* CAS.pb.h */,
50065007
40E837E42CCC5FFB0022B026 /* CAS.pb.cc */,
50075008
40E837E52CCC5FFB0022B026 /* CAS.pb.swift */,
5009+
4035F64A2CF140A900337926 /* CAS.swift */,
50085010
40E7C51B2C61CAEF00FC0383 /* CoreTypes.swift */,
50095011
4072B4C42C51995100B68221 /* Engine.h */,
50105012
4072B4C52C51995100B68221 /* Engine.cpp */,
@@ -10764,7 +10766,6 @@
1076410766
4072B5F12C51BF1700B68221 /* Error.pb.cc in Sources */,
1076510767
40E7C53A2C61CB0800FC0383 /* CoreTypes.swift in Sources */,
1076610768
4072B5F22C51BF1700B68221 /* Artifact.pb.swift in Sources */,
10767-
4035F55A2CDEABA100337926 /* EngineInternal.proto in Sources */,
1076810769
40E836B12CBDC6FA0022B026 /* ActionCache.swift in Sources */,
1076910770
40E7C53E2C61CF6800FC0383 /* Engine.swift in Sources */,
1077010771
4072B5F32C51BF1700B68221 /* ActionCache.pb.cc in Sources */,
@@ -10773,6 +10774,7 @@
1077310774
40E837E72CCC5FFB0022B026 /* CAS.pb.swift in Sources */,
1077410775
4072B5F52C51BF1700B68221 /* ActionCache.cpp in Sources */,
1077510776
40E837EA2CCC64430022B026 /* CAS.cpp in Sources */,
10777+
4035F64B2CF140B000337926 /* CAS.swift in Sources */,
1077610778
4072B5F62C51BF1700B68221 /* Error.pb.swift in Sources */,
1077710779
4072B5F72C51BF1700B68221 /* ActionCache.pb.swift in Sources */,
1077810780
4072B5F82C51BF1700B68221 /* Label.cpp in Sources */,

products/llbuild3/Errors.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ enum EngineError: uint64_t {
4646
Unknown = 0
4747
};
4848

49+
enum CASError: uint64_t {
50+
ObjectNotFound = 100,
51+
52+
// Unknown
53+
UnknownCASError = 0
54+
};
55+
4956
}
5057
}
5158

products/llbuild3/SwiftAdaptors.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ struct EngineConfig;
3333
typedef std::string ArtifactPB;
3434
typedef std::string CacheKeyPB;
3535
typedef std::string CacheValuePB;
36+
typedef std::string CASIDBytes;
37+
typedef std::string CASObjectPB;
3638
typedef std::string ErrorPB;
3739
typedef std::string LabelPB;
3840
typedef std::string SignaturePB;
@@ -113,6 +115,17 @@ class BuildRef {
113115
LLBUILD3_EXPORT void addCompletionHandler(void* ctx, void (*handler)(void*, result<ArtifactPB, ErrorPB>*));
114116
};
115117

118+
struct ExtCASDatabase {
119+
void* ctx;
120+
121+
// FIXME: cleanup context
122+
123+
void (*containsFn)(void* ctx, CASIDBytes id, std::function<void (bool, ErrorPB)>);
124+
void (*getFn)(void* ctx, CASIDBytes id, std::function<void (CASObjectPB, ErrorPB)>);
125+
void (*putFn)(void* ctx, CASObjectPB obj, std::function<void (CASIDBytes, ErrorPB)>);
126+
CASIDBytes (*identifyFn)(void* ctx, CASObjectPB obj);
127+
};
128+
116129
class CASDatabase;
117130
typedef std::shared_ptr<CASDatabase> CASDatabaseRef;
118131
LLBUILD3_EXPORT CASDatabaseRef makeInMemoryCASDatabase();

src/llbuild3/Error.pb.cc

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/llbuild3/Error.pb.h

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/llbuild3/Error.pb.swift

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ public enum Llbuild3_ErrorType: SwiftProtobuf.Enum, Swift.CaseIterable {
2424
public typealias RawValue = Int
2525
case engine // = 0
2626
case cache // = 1
27-
case executor // = 2
28-
case client // = 3
27+
case cas // = 2
28+
case executor // = 3
29+
case client // = 4
2930
case UNRECOGNIZED(Int)
3031

3132
public init() {
@@ -36,8 +37,9 @@ public enum Llbuild3_ErrorType: SwiftProtobuf.Enum, Swift.CaseIterable {
3637
switch rawValue {
3738
case 0: self = .engine
3839
case 1: self = .cache
39-
case 2: self = .executor
40-
case 3: self = .client
40+
case 2: self = .cas
41+
case 3: self = .executor
42+
case 4: self = .client
4143
default: self = .UNRECOGNIZED(rawValue)
4244
}
4345
}
@@ -46,8 +48,9 @@ public enum Llbuild3_ErrorType: SwiftProtobuf.Enum, Swift.CaseIterable {
4648
switch self {
4749
case .engine: return 0
4850
case .cache: return 1
49-
case .executor: return 2
50-
case .client: return 3
51+
case .cas: return 2
52+
case .executor: return 3
53+
case .client: return 4
5154
case .UNRECOGNIZED(let i): return i
5255
}
5356
}
@@ -56,6 +59,7 @@ public enum Llbuild3_ErrorType: SwiftProtobuf.Enum, Swift.CaseIterable {
5659
public static let allCases: [Llbuild3_ErrorType] = [
5760
.engine,
5861
.cache,
62+
.cas,
5963
.executor,
6064
.client,
6165
]
@@ -105,8 +109,9 @@ extension Llbuild3_ErrorType: SwiftProtobuf._ProtoNameProviding {
105109
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
106110
0: .same(proto: "ENGINE"),
107111
1: .same(proto: "CACHE"),
108-
2: .same(proto: "EXECUTOR"),
109-
3: .same(proto: "CLIENT"),
112+
2: .same(proto: "CAS"),
113+
3: .same(proto: "EXECUTOR"),
114+
4: .same(proto: "CLIENT"),
110115
]
111116
}
112117

src/llbuild3/Error.proto

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ import "google/protobuf/any.proto";
77

88
enum ErrorType {
99
ENGINE = 0;
10-
1110
CACHE = 1;
12-
13-
EXECUTOR = 2;
14-
15-
CLIENT = 3;
11+
CAS = 2;
12+
EXECUTOR = 3;
13+
CLIENT = 4;
1614
}
1715

1816
message Error {

0 commit comments

Comments
 (0)