@@ -57,6 +57,7 @@ static int import(ObjectStore &CAS, ObjectStore &UpstreamCAS,
57
57
ArrayRef<std::string> Objects);
58
58
static int putCacheKey (ObjectStore &CAS, ActionCache &AC,
59
59
ArrayRef<std::string> Objects);
60
+ static int getCacheResult (ObjectStore &CAS, ActionCache &AC, const CASID &ID);
60
61
static int validateObject (ObjectStore &CAS, const CASID &ID);
61
62
62
63
int main (int Argc, char **Argv) {
@@ -90,6 +91,7 @@ int main(int Argc, char **Argv) {
90
91
GetCASIDForFile,
91
92
Import,
92
93
PutCacheKey,
94
+ GetCacheResult,
93
95
Validate,
94
96
};
95
97
cl::opt<CommandKind> Command (
@@ -113,6 +115,8 @@ int main(int Argc, char **Argv) {
113
115
clEnumValN (Import, " import" , " import objects from another CAS" ),
114
116
clEnumValN (PutCacheKey, " put-cache-key" ,
115
117
" set a value for a cache key" ),
118
+ clEnumValN (GetCacheResult, " get-cache-result" ,
119
+ " get the result value from a cache key" ),
116
120
clEnumValN (Validate, " validate" , " validate the object for CASID" )),
117
121
cl::init (CommandKind::Invalid));
118
122
@@ -181,19 +185,24 @@ int main(int Argc, char **Argv) {
181
185
return import (*CAS, *UpstreamCAS, Objects);
182
186
}
183
187
184
- if (Command == PutCacheKey) {
188
+ if (Command == PutCacheKey || Command == GetCacheResult ) {
185
189
if (!AC)
186
190
ExitOnErr (createStringError (inconvertibleErrorCode (),
187
191
" no action-cache available" ));
188
- return putCacheKey (*CAS, *AC, Objects);
189
192
}
190
193
194
+ if (Command == PutCacheKey)
195
+ return putCacheKey (*CAS, *AC, Objects);
196
+
191
197
// Remaining commands need exactly one CAS object.
192
198
if (Objects.size () > 1 )
193
199
ExitOnErr (createStringError (inconvertibleErrorCode (),
194
200
" too many <object>s, expected 1" ));
195
201
CASID ID = ExitOnErr (CAS->parseID (Objects.front ()));
196
202
203
+ if (Command == GetCacheResult)
204
+ return getCacheResult (*CAS, *AC, ID);
205
+
197
206
if (Command == TraverseGraph)
198
207
return traverseGraph (*CAS, ID);
199
208
@@ -577,6 +586,18 @@ static int putCacheKey(ObjectStore &CAS, ActionCache &AC,
577
586
return 0 ;
578
587
}
579
588
589
+ static int getCacheResult (ObjectStore &CAS, ActionCache &AC, const CASID &ID) {
590
+ ExitOnError ExitOnErr (" llvm-cas: get-cache-result: " );
591
+
592
+ auto Result = ExitOnErr (AC.get (ID));
593
+ if (!Result) {
594
+ outs () << " result not found\n " ;
595
+ return 1 ;
596
+ }
597
+ outs () << *Result << " \n " ;
598
+ return 0 ;
599
+ }
600
+
580
601
int validateObject (ObjectStore &CAS, const CASID &ID) {
581
602
ExitOnError ExitOnErr (" llvm-cas: validate: " );
582
603
ExitOnErr (CAS.validate (ID));
0 commit comments