10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
12
13
- #ifndef LLBUILD3_CORE_SWIFTADAPTORS_H
14
- #define LLBUILD3_CORE_SWIFTADAPTORS_H
13
+ #ifndef LLBUILD3_SWIFTADAPTORS_H
14
+ #define LLBUILD3_SWIFTADAPTORS_H
15
15
16
+ #include < functional>
16
17
#include < memory>
17
18
#include < optional>
18
19
#include < string>
20
+ #include < unordered_map>
19
21
#include < vector>
20
22
21
23
#include < llbuild3/Visibility.hpp>
22
24
#include < llbuild3/Result.hpp>
23
25
24
26
25
27
namespace llbuild3 {
26
- namespace core {
27
28
28
29
class Build ;
29
30
class Engine ;
30
31
struct EngineConfig ;
31
32
32
33
// Serialized Protobuf Objects
34
+ typedef std::string ActionPB;
33
35
typedef std::string ArtifactPB;
34
36
typedef std::string CacheKeyPB;
35
37
typedef std::string CacheValuePB;
@@ -45,9 +47,33 @@ typedef std::string TaskNextStatePB;
45
47
46
48
// Swift helper typedefs
47
49
typedef std::vector<LabelPB> LabelVector;
50
+ typedef std::vector<std::pair<uint64_t , result<void *, ErrorPB>>> SubtaskResultMap;
48
51
49
52
// External Adaptor Objects
50
53
54
+ class CASDatabase ;
55
+ typedef std::shared_ptr<CASDatabase> CASDatabaseRef;
56
+
57
+ struct ExtCASDatabase {
58
+ void * ctx;
59
+
60
+ // FIXME: cleanup context
61
+
62
+ void (*containsFn)(void * ctx, CASIDBytes id, std::function<void (bool , ErrorPB)>);
63
+ void (*getFn)(void * ctx, CASIDBytes id, std::function<void (CASObjectPB, ErrorPB)>);
64
+ void (*putFn)(void * ctx, CASObjectPB obj, std::function<void (CASIDBytes, ErrorPB)>);
65
+ CASIDBytes (*identifyFn)(void * ctx, CASObjectPB obj);
66
+ };
67
+
68
+ LLBUILD3_EXPORT CASDatabaseRef makeExtCASDatabase (ExtCASDatabase extCASDB);
69
+ LLBUILD3_EXPORT CASDatabaseRef makeInMemoryCASDatabase ();
70
+
71
+ LLBUILD3_EXPORT void * getRawCASDatabaseContext (CASDatabaseRef casDB);
72
+ LLBUILD3_EXPORT void adaptedCASDatabaseContains (CASDatabaseRef casDB, CASIDBytes, void * ctx, void (*handler)(void *, result<bool , ErrorPB>*));
73
+ LLBUILD3_EXPORT void adaptedCASDatabaseGet (CASDatabaseRef casDB, CASIDBytes, void * ctx, void (*handler)(void *, result<CASObjectPB, ErrorPB>*));
74
+ LLBUILD3_EXPORT void adaptedCASDatabasePut (CASDatabaseRef casDB, CASObjectPB, void * ctx, void (*handler)(void *, result<CASIDBytes, ErrorPB>*));
75
+ LLBUILD3_EXPORT CASIDBytes adaptedCASDatabaseIdentify (CASDatabaseRef casDB, CASObjectPB);
76
+
51
77
struct ExtRule ;
52
78
53
79
struct ExtRuleProvider {
@@ -62,6 +88,23 @@ struct ExtRuleProvider {
62
88
bool (*ruleForArtifactFn)(void *, const LabelPB*, ExtRule*);
63
89
};
64
90
91
+ class ExtSubtaskInterface {
92
+ private:
93
+ void * impl;
94
+ uint64_t ctx;
95
+
96
+ public:
97
+ ExtSubtaskInterface (void * impl, uint64_t ctx) : impl(impl), ctx(ctx) { }
98
+
99
+ LLBUILD3_EXPORT CASDatabaseRef cas ();
100
+ };
101
+
102
+ struct ExtSubtask {
103
+ void * ctx;
104
+
105
+ void (*perform)(void *, ExtSubtaskInterface, std::function<void (void *, ErrorPB)>);
106
+ };
107
+
65
108
class ExtTaskInterface {
66
109
private:
67
110
void * impl;
@@ -74,7 +117,8 @@ class ExtTaskInterface {
74
117
75
118
LLBUILD3_EXPORT result<uint64_t , ErrorPB> requestArtifact (const LabelPB label);
76
119
LLBUILD3_EXPORT result<uint64_t , ErrorPB> requestRule (const LabelPB label);
77
- LLBUILD3_EXPORT result<uint64_t , ErrorPB> requestAction ();
120
+ LLBUILD3_EXPORT result<uint64_t , ErrorPB> requestAction (const ActionPB action);
121
+ LLBUILD3_EXPORT result<uint64_t , ErrorPB> spawnSubtask (const ExtSubtask subtask);
78
122
};
79
123
80
124
struct ExtTask {
@@ -88,7 +132,7 @@ struct ExtTask {
88
132
// FIXME: some method for cleaning up context
89
133
90
134
void (*producesFn)(void *, std::vector<LabelPB>*);
91
- bool (*computeFn)(void *, ExtTaskInterface, const TaskContextPB*, const TaskInputsPB*, TaskNextStatePB*);
135
+ bool (*computeFn)(void *, ExtTaskInterface, const TaskContextPB*, const TaskInputsPB*, SubtaskResultMap*, TaskNextStatePB*);
92
136
};
93
137
94
138
struct ExtRule {
@@ -115,22 +159,6 @@ class BuildRef {
115
159
LLBUILD3_EXPORT void addCompletionHandler (void * ctx, void (*handler)(void *, result<ArtifactPB, ErrorPB>*));
116
160
};
117
161
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
-
129
- class CASDatabase ;
130
- typedef std::shared_ptr<CASDatabase> CASDatabaseRef;
131
- LLBUILD3_EXPORT CASDatabaseRef makeExtCASDatabase (ExtCASDatabase extCASDB);
132
- LLBUILD3_EXPORT CASDatabaseRef makeInMemoryCASDatabase ();
133
-
134
162
struct ExtActionCache {
135
163
void * ctx;
136
164
@@ -145,6 +173,9 @@ typedef std::shared_ptr<ActionCache> ActionCacheRef;
145
173
LLBUILD3_EXPORT ActionCacheRef makeExtActionCache (ExtActionCache extCache);
146
174
LLBUILD3_EXPORT ActionCacheRef makeInMemoryActionCache ();
147
175
176
+ class ActionExecutor ;
177
+ typedef std::shared_ptr<ActionExecutor> ActionExecutorRef;
178
+ LLBUILD3_EXPORT ActionExecutorRef makeActionExecutor ();
148
179
149
180
struct ExtEngineConfig {
150
181
std::optional<LabelPB> initRule;
@@ -160,9 +191,12 @@ class EngineRef {
160
191
LLBUILD3_EXPORT BuildRef build (const LabelPB artifact);
161
192
};
162
193
163
- LLBUILD3_EXPORT EngineRef makeEngine (ExtEngineConfig config, CASDatabaseRef casdb, ActionCacheRef cache, const ExtRuleProvider provider);
194
+ LLBUILD3_EXPORT EngineRef makeEngine (ExtEngineConfig config,
195
+ CASDatabaseRef casdb,
196
+ ActionCacheRef cache,
197
+ ActionExecutorRef executor,
198
+ const ExtRuleProvider provider);
164
199
165
- }
166
200
}
167
201
168
202
#endif /* Header_h */
0 commit comments