|
25 | 25 | /// SWIFTSCAN_VERSION_MINOR should increase when there are API additions.
|
26 | 26 | /// SWIFTSCAN_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
|
27 | 27 | #define SWIFTSCAN_VERSION_MAJOR 0
|
28 |
| -#define SWIFTSCAN_VERSION_MINOR 5 |
| 28 | +#define SWIFTSCAN_VERSION_MINOR 6 |
29 | 29 |
|
30 | 30 | SWIFTSCAN_BEGIN_DECLS
|
31 | 31 |
|
@@ -437,17 +437,44 @@ typedef struct swiftscan_cas_options_s *swiftscan_cas_options_t;
|
437 | 437 | /// ActionCache.
|
438 | 438 | typedef struct swiftscan_cas_s *swiftscan_cas_t;
|
439 | 439 |
|
| 440 | +/// Opaque type for a cancellation token for async cache operations. |
| 441 | +typedef struct swiftscan_cache_cancellation_token_s |
| 442 | + *swiftscan_cache_cancellation_token_t; |
| 443 | + |
440 | 444 | /// Enum types for output types for cache key computation.
|
441 |
| -/// TODO: complete the list. |
| 445 | +/// List should contain all the output file types, including supplemententary |
| 446 | +/// outputs, except diagnostics outputs, which are covered by cached diagnostic |
| 447 | +/// entry. |
442 | 448 | typedef enum {
|
443 | 449 | SWIFTSCAN_OUTPUT_TYPE_OBJECT = 0,
|
444 | 450 | SWIFTSCAN_OUTPUT_TYPE_SWIFTMODULE = 1,
|
445 | 451 | SWIFTSCAN_OUTPUT_TYPE_SWIFTINTERFACE = 2,
|
446 | 452 | SWIFTSCAN_OUTPUT_TYPE_SWIFTPRIVATEINTERFACE = 3,
|
447 | 453 | SWIFTSCAN_OUTPUT_TYPE_CLANG_MODULE = 4,
|
448 |
| - SWIFTSCAN_OUTPUT_TYPE_CLANG_PCH = 5 |
| 454 | + SWIFTSCAN_OUTPUT_TYPE_CLANG_PCH = 5, |
| 455 | + SWIFTSCAN_OUTPUT_TYPE_CLANG_HEADER = 6, |
| 456 | + SWIFTSCAN_OUTPUT_TYPE_SWIFT_SOURCE_INFO = 7, |
| 457 | + SWIFTSCAN_OUTPUT_TYPE_SWIFT_MODULE_DOC = 8, |
| 458 | + SWIFTSCAN_OUTPUT_TYPE_DEPENDENCIES = 9, |
| 459 | + SWIFTSCAN_OUTPUT_TYPE_SWIFT_DEPS = 10, |
| 460 | + SWIFTSCAN_OUTPUT_TYPE_MODULE_TRACE = 11, |
| 461 | + SWIFTSCAN_OUTPUT_TYPE_TBD = 12, |
| 462 | + SWIFTSCAN_OUTPUT_TYPE_SWIFT_MODULE_SUMMARY = 13, |
| 463 | + SWIFTSCAN_OUTPUT_TYPE_SWIFT_ABI_DESCRIPTOR = 14, |
| 464 | + SWIFTSCAN_OUTPUT_TYPE_CONST_VALUE = 15, |
| 465 | + SWIFTSCAN_OUTPUT_TYPE_MODULE_SEMANTIC_INFO = 16, |
| 466 | + SWIFTSCAN_OUTPUT_TYPE_YAML_OPT_RECORD = 17, |
| 467 | + SWIFTSCAN_OUTPUT_TYPE_BITSTREAM_OPT_RECORD = 18, |
| 468 | + SWIFTSCAN_OUTPUT_TYPE_CACHED_DIAGNOSTICS = 19 |
449 | 469 | } swiftscan_output_kind_t;
|
450 | 470 |
|
| 471 | +/// Enum types for cache result lookup or replay. |
| 472 | +typedef enum { |
| 473 | + SWIFTSCAN_CACHE_RESULT_SUCCESS = 0, |
| 474 | + SWIFTSCAN_CACHE_RESULT_NOT_FOUND = 1, |
| 475 | + SWIFTSCAN_CACHE_RESULT_ERROR = 2, |
| 476 | +} swiftscan_cache_result_t; |
| 477 | + |
451 | 478 | /// Create a \c CASOptions for creating CAS inside scanner specified.
|
452 | 479 | SWIFTSCAN_PUBLIC swiftscan_cas_options_t swiftscan_cas_options_create(void);
|
453 | 480 |
|
@@ -497,6 +524,69 @@ SWIFTSCAN_PUBLIC swiftscan_string_ref_t swiftscan_compute_cache_key(
|
497 | 524 | swiftscan_cas_t cas, int argc, const char **argv, const char *input,
|
498 | 525 | swiftscan_output_kind_t kind, swiftscan_string_ref_t *error);
|
499 | 526 |
|
| 527 | +/// Query the result of the compilation using the output cache key. \c globally |
| 528 | +/// suggests if the lookup should check remote cache if such operation exists. |
| 529 | +/// If remote cache is checked and result is found, the output is materialized |
| 530 | +/// locally so that later replay action should not require remote actions. |
| 531 | +/// If the return value is SWIFTSCAN_CACHE_RESULT_ERROR, the error message is |
| 532 | +/// returned via \c error parameter and it caller needs to free the message |
| 533 | +/// using `swiftscan_string_dispose`. |
| 534 | +SWIFTSCAN_PUBLIC swiftscan_cache_result_t |
| 535 | +swiftscan_cache_query(swiftscan_cas_t cas, const char *key, bool globally, |
| 536 | + swiftscan_string_ref_t *error); |
| 537 | + |
| 538 | +/// Async version of `swiftscan_cache_query` where result is returned via |
| 539 | +/// callback. \c ctx is an opaque value that passed to the callback and |
| 540 | +/// \c swiftscan_cache_cancellation_token_t will return an token that can be |
| 541 | +/// used to cancel the async operation. The token needs to be freed by caller |
| 542 | +/// using `swiftscan_cache_cancellation_token_dispose`. |
| 543 | +SWIFTSCAN_PUBLIC void swiftscan_cache_query_async( |
| 544 | + swiftscan_cas_t cas, const char *key, bool globally, void *ctx, |
| 545 | + void (*callback)(void *ctx, swiftscan_cache_result_t, |
| 546 | + swiftscan_string_ref_t error), |
| 547 | + swiftscan_cache_cancellation_token_t *); |
| 548 | + |
| 549 | +/// Make the cache compilation available globally. \c callback will be called |
| 550 | +/// on completion. |
| 551 | +/// \c swiftscan_cache_cancellation_token_t will return an token that can be |
| 552 | +/// used to cancel the async operation. The token needs to be freed by caller |
| 553 | +/// using `swiftscan_cache_cancellation_token_dispose`. |
| 554 | +SWIFTSCAN_PUBLIC void swiftscan_cache_make_global_async( |
| 555 | + swiftscan_cas_t cas, const char *key, void *ctx, |
| 556 | + void (*callback)(void *ctx, swiftscan_string_ref_t error), |
| 557 | + swiftscan_cache_cancellation_token_t *); |
| 558 | + |
| 559 | +/// Cancel the async cache action that is associated with token. |
| 560 | +SWIFTSCAN_PUBLIC void |
| 561 | + swiftscan_cache_action_cancel(swiftscan_cache_cancellation_token_t); |
| 562 | + |
| 563 | +/// Dispose the cancellation token. |
| 564 | +SWIFTSCAN_PUBLIC void swiftscan_cache_cancellation_token_dispose( |
| 565 | + swiftscan_cache_cancellation_token_t); |
| 566 | + |
| 567 | +/// Replay the cached compilation using command-line. |
| 568 | +/// If the return value is SWIFTSCAN_CACHE_RESULT_ERROR, the error message is |
| 569 | +/// returned via \c error parameter and it caller needs to free the message |
| 570 | +/// using `swiftscan_string_dispose`. |
| 571 | +SWIFTSCAN_PUBLIC swiftscan_cache_result_t swiftscan_cache_replay_compilation( |
| 572 | + swiftscan_cas_t cas, int argc, const char **argv, |
| 573 | + swiftscan_string_ref_t *error); |
| 574 | + |
| 575 | + |
| 576 | +/// Async replay the cached compilation. Callback function will be provided |
| 577 | +/// by the cache replay result, and its stdout, stderr, and any error message. |
| 578 | +/// \c ctx is an opaque value that passed to the callback and |
| 579 | +/// \c swiftscan_cache_cancellation_token_t will return an token that can be |
| 580 | +/// used to cancel the async operation. The token needs to be freed by caller |
| 581 | +/// using `swiftscan_cache_cancellation_token_dispose`. |
| 582 | +SWIFTSCAN_PUBLIC void swiftscan_cache_replay_compilation_async( |
| 583 | + swiftscan_cas_t cas, int argc, const char **argv, void *ctx, |
| 584 | + void (*callback)(void *ctx, swiftscan_cache_result_t, |
| 585 | + swiftscan_string_ref_t std_out, |
| 586 | + swiftscan_string_ref_t std_err, |
| 587 | + swiftscan_string_ref_t error), |
| 588 | + swiftscan_cache_cancellation_token_t *); |
| 589 | + |
500 | 590 | //===----------------------------------------------------------------------===//
|
501 | 591 |
|
502 | 592 | SWIFTSCAN_END_DECLS
|
|
0 commit comments