Skip to content

Commit 3505cf4

Browse files
committed
[llbuild3] initial locally executed actions support
1 parent a52f3d5 commit 3505cf4

35 files changed

+6956
-2975
lines changed

llbuild.xcodeproj/project.pbxproj

Lines changed: 43 additions & 11 deletions
Large diffs are not rendered by default.

products/llbuild3/Errors.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,28 @@ enum class EngineError: uint64_t {
4848

4949
enum class CASError: uint64_t {
5050
ObjectNotFound = 100,
51+
IOError = 101,
52+
StreamStall = 102,
5153

5254
// Unknown
5355
Unknown = 0
5456
};
5557

5658
enum class ExecutorError: uint64_t {
5759

60+
// 100 - Process Errors
61+
FileNotFound = 100,
62+
IOError = 101,
63+
ProcessSpawnFailed = 102,
64+
WaitFailed = 103,
65+
ControlProtocolError = 104,
66+
ProcessStatsError = 105,
67+
5868
// 200 - Client Implementation Errors
5969
BadRequest = 200,
70+
DuplicateProvider = 201,
71+
BadProviderPrefix = 202,
72+
NoProvider = 203,
6073

6174
// 1000 - Executor Internal Errors
6275
Unimplemented = 1000,

products/llbuild3/SwiftAdaptors.hpp

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLBUILD3_SWIFTADAPTORS_H
1414
#define LLBUILD3_SWIFTADAPTORS_H
1515

16+
#include <cstdint>
1617
#include <functional>
1718
#include <memory>
1819
#include <optional>
@@ -38,6 +39,7 @@ typedef std::string CacheValuePB;
3839
typedef std::string CASIDBytes;
3940
typedef std::string CASObjectPB;
4041
typedef std::string ErrorPB;
42+
typedef std::string FileObjectPB;
4143
typedef std::string LabelPB;
4244
typedef std::string SignaturePB;
4345
typedef std::string TaskContextPB;
@@ -57,7 +59,7 @@ typedef std::shared_ptr<CASDatabase> CASDatabaseRef;
5759
struct ExtCASDatabase {
5860
void* ctx;
5961

60-
// FIXME: cleanup context
62+
void (*releaseFn)(void* ctx);
6163

6264
void (*containsFn)(void* ctx, CASIDBytes id, std::function<void (bool, ErrorPB)>);
6365
void (*getFn)(void* ctx, CASIDBytes id, std::function<void (CASObjectPB, ErrorPB)>);
@@ -173,9 +175,38 @@ typedef std::shared_ptr<ActionCache> ActionCacheRef;
173175
LLBUILD3_EXPORT ActionCacheRef makeExtActionCache(ExtActionCache extCache);
174176
LLBUILD3_EXPORT ActionCacheRef makeInMemoryActionCache();
175177

178+
179+
struct ExtLocalSandbox {
180+
void* ctx;
181+
182+
void (*releaseFn)(void* ctx);
183+
184+
void (*dirFn)(void* ctx, std::string*);
185+
void (*prepareInputFn)(void* ctx, std::string* path, int type, CASIDBytes* id, ErrorPB*);
186+
void (*collectOutputsFn)(void*, std::vector<std::string>, std::vector<FileObjectPB>*, ErrorPB*);
187+
void (*releaseSandboxFn)(void* ctx);
188+
};
189+
190+
struct ExtLocalSandboxProvider {
191+
void* ctx;
192+
193+
void (*releaseFn)(void* ctx);
194+
195+
ExtLocalSandbox (*createFn)(void* ctx, uint64_t handle, ErrorPB*);
196+
};
197+
176198
class ActionExecutor;
199+
class LocalExecutor;
200+
class LocalSandboxProvider;
201+
class RemoteExecutor;
177202
typedef std::shared_ptr<ActionExecutor> ActionExecutorRef;
178-
LLBUILD3_EXPORT ActionExecutorRef makeActionExecutor();
203+
typedef std::shared_ptr<LocalExecutor> LocalExecutorRef;
204+
typedef std::shared_ptr<LocalSandboxProvider> LocalSandboxProviderRef;
205+
typedef std::shared_ptr<RemoteExecutor> RemoteExecutorRef;
206+
LLBUILD3_EXPORT ActionExecutorRef makeActionExecutor(CASDatabaseRef, ActionCacheRef, LocalExecutorRef, RemoteExecutorRef);
207+
LLBUILD3_EXPORT LocalSandboxProviderRef makeExtLocalSandboxProvider(ExtLocalSandboxProvider);
208+
LLBUILD3_EXPORT LocalExecutorRef makeLocalExecutor(LocalSandboxProviderRef);
209+
LLBUILD3_EXPORT RemoteExecutorRef makeRemoteExecutor();
179210

180211
struct ExtEngineConfig {
181212
std::optional<LabelPB> initRule;
@@ -188,6 +219,8 @@ class EngineRef {
188219
public:
189220
EngineRef(std::shared_ptr<Engine> engine) : engine(engine) { }
190221

222+
LLBUILD3_EXPORT CASDatabaseRef cas();
223+
191224
LLBUILD3_EXPORT BuildRef build(const LabelPB artifact);
192225
};
193226

0 commit comments

Comments
 (0)