File tree 3 files changed +33
-0
lines changed
examples/c-api/buildsystem
3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ static llb_buildsystem_command_t*
52
52
fancy_tool_create_command (void * context , const llb_data_t * name ) {
53
53
llb_buildsystem_external_command_delegate_t delegate ;
54
54
delegate .context = NULL ;
55
+ delegate .get_signature = NULL ;
55
56
delegate .execute_command = fancy_command_execute_command ;
56
57
return llb_buildsystem_external_command_create (name , delegate );
57
58
}
Original file line number Diff line number Diff line change 20
20
#include " llbuild/BuildSystem/ExternalCommand.h"
21
21
#include " llbuild/Core/BuildEngine.h"
22
22
23
+ #include " llvm/ADT/Hashing.h"
23
24
#include " llvm/ADT/SmallString.h"
24
25
#include " llvm/Support/SourceMgr.h"
25
26
#include " llvm/Support/raw_ostream.h"
@@ -409,6 +410,24 @@ class CAPIExternalCommand : public ExternalCommand {
409
410
// FIXME: Provide client control.
410
411
llvm::raw_svector_ostream (result) << getName ();
411
412
}
413
+
414
+ virtual uint64_t getSignature () override {
415
+ // FIXME: Use a more appropriate hashing infrastructure.
416
+ using llvm::hash_combine;
417
+ llvm::hash_code code = ExternalCommand::getSignature ();
418
+ if (cAPIDelegate.get_signature ) {
419
+ llb_data_t data;
420
+ cAPIDelegate.get_signature (cAPIDelegate.context , (llb_buildsystem_command_t *)this ,
421
+ &data);
422
+ code = hash_combine (code, StringRef ((const char *)data.data , data.length ));
423
+
424
+ // Release the client memory.
425
+ //
426
+ // FIXME: This is gross, come up with a general purpose solution.
427
+ free ((char *)data.data );
428
+ }
429
+ return size_t (code);
430
+ }
412
431
};
413
432
414
433
}
Original file line number Diff line number Diff line change @@ -371,6 +371,19 @@ typedef struct llb_buildsystem_external_command_delegate_t_ {
371
371
/// User context pointer.
372
372
void * context ;
373
373
374
+ /// Called to get a signature which represents the internal state of the
375
+ /// command which is not tracked by any other attribute visible to the build
376
+ /// system (for example, a declared input or output). This signature is
377
+ /// compared with previous executions of the command when determining whether
378
+ /// or not it needs to rerun.
379
+ ///
380
+ /// The contents *MUST* be returned in a new buffer allocated with \see
381
+ /// malloc().
382
+ //
383
+ // FIXME: We need to use a better data type than a uint64_t here.
384
+ void (* get_signature )(void * context , llb_buildsystem_command_t * command ,
385
+ llb_data_t * data_out );
386
+
374
387
/// Called by the build system's execution queue after the command's inputs
375
388
/// are available and the execution queue is ready to schedule the command.
376
389
///
You can’t perform that action at this time.
0 commit comments