|
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,47 @@ 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 container for a CASID. |
| 441 | +typedef struct swiftscan_cas_id_s *swiftscan_cas_id_t; |
| 442 | + |
| 443 | +/// Opaque type for a cancellation token for async cache operations. |
| 444 | +typedef struct swiftscan_cache_cancellation_token_s |
| 445 | + *swiftscan_cache_cancellation_token_t; |
| 446 | + |
440 | 447 | /// Enum types for output types for cache key computation.
|
441 |
| -/// TODO: complete the list. |
| 448 | +/// List should contain all the output file types, including supplemententary |
| 449 | +/// outputs, except diagnostics outputs, which are covered by cached diagnostic |
| 450 | +/// entry. |
442 | 451 | typedef enum {
|
443 | 452 | SWIFTSCAN_OUTPUT_TYPE_OBJECT = 0,
|
444 | 453 | SWIFTSCAN_OUTPUT_TYPE_SWIFTMODULE = 1,
|
445 | 454 | SWIFTSCAN_OUTPUT_TYPE_SWIFTINTERFACE = 2,
|
446 | 455 | SWIFTSCAN_OUTPUT_TYPE_SWIFTPRIVATEINTERFACE = 3,
|
447 | 456 | SWIFTSCAN_OUTPUT_TYPE_CLANG_MODULE = 4,
|
448 |
| - SWIFTSCAN_OUTPUT_TYPE_CLANG_PCH = 5 |
| 457 | + SWIFTSCAN_OUTPUT_TYPE_CLANG_PCH = 5, |
| 458 | + SWIFTSCAN_OUTPUT_TYPE_CLANG_HEADER = 6, |
| 459 | + SWIFTSCAN_OUTPUT_TYPE_SWIFT_SOURCE_INFO = 7, |
| 460 | + SWIFTSCAN_OUTPUT_TYPE_SWIFT_MODULE_DOC = 8, |
| 461 | + SWIFTSCAN_OUTPUT_TYPE_DEPENDENCIES = 9, |
| 462 | + SWIFTSCAN_OUTPUT_TYPE_SWIFT_DEPS = 10, |
| 463 | + SWIFTSCAN_OUTPUT_TYPE_MODULE_TRACE = 11, |
| 464 | + SWIFTSCAN_OUTPUT_TYPE_TBD = 12, |
| 465 | + SWIFTSCAN_OUTPUT_TYPE_SWIFT_MODULE_SUMMARY = 13, |
| 466 | + SWIFTSCAN_OUTPUT_TYPE_SWIFT_ABI_DESCRIPTOR = 14, |
| 467 | + SWIFTSCAN_OUTPUT_TYPE_CONST_VALUE = 15, |
| 468 | + SWIFTSCAN_OUTPUT_TYPE_MODULE_SEMANTIC_INFO = 16, |
| 469 | + SWIFTSCAN_OUTPUT_TYPE_YAML_OPT_RECORD = 17, |
| 470 | + SWIFTSCAN_OUTPUT_TYPE_BITSTREAM_OPT_RECORD = 18, |
| 471 | + SWIFTSCAN_OUTPUT_TYPE_CACHED_DIAGNOSTICS = 19 |
449 | 472 | } swiftscan_output_kind_t;
|
450 | 473 |
|
| 474 | +/// Enum types for cache result lookup or replay. |
| 475 | +typedef enum { |
| 476 | + SWIFTSCAN_CACHE_RESULT_SUCCESS = 0, |
| 477 | + SWIFTSCAN_CACHE_RESULT_NOT_FOUND = 1, |
| 478 | + SWIFTSCAN_CACHE_RESULT_ERROR = 2, |
| 479 | +} swiftscan_cache_result_t; |
| 480 | + |
451 | 481 | /// Create a \c CASOptions for creating CAS inside scanner specified.
|
452 | 482 | SWIFTSCAN_PUBLIC swiftscan_cas_options_t swiftscan_cas_options_create(void);
|
453 | 483 |
|
@@ -497,6 +527,91 @@ SWIFTSCAN_PUBLIC swiftscan_string_ref_t swiftscan_compute_cache_key(
|
497 | 527 | swiftscan_cas_t cas, int argc, const char **argv, const char *input,
|
498 | 528 | swiftscan_output_kind_t kind, swiftscan_string_ref_t *error);
|
499 | 529 |
|
| 530 | +/// Query the result of the compilation using the output cache key. \c globally |
| 531 | +/// suggests if the lookup should check remote cache if such operation exists. |
| 532 | +/// Returns the CASID of the result if found, or nullptr if output is not found |
| 533 | +/// or an error occurs. When an error occurs, the error message is returned via |
| 534 | +/// \c error parameter and it caller needs to free the message using |
| 535 | +/// `swiftscan_string_dispose`. The returned CASID needs to be freed via |
| 536 | +/// `swiftscan_cas_id_dispose`. |
| 537 | +SWIFTSCAN_PUBLIC swiftscan_cas_id_t |
| 538 | +swiftscan_cache_query(swiftscan_cas_t cas, const char *key, bool globally, |
| 539 | + swiftscan_string_ref_t *error); |
| 540 | + |
| 541 | +/// Async version of `swiftscan_cache_query` where result is returned via |
| 542 | +/// callback. Both cache_result enum and CASID will be provided to callback. |
| 543 | +/// \c ctx is an opaque value that passed to the callback and |
| 544 | +/// \c swiftscan_cache_cancellation_token_t will return an token that can be |
| 545 | +/// used to cancel the async operation. The token needs to be freed by caller |
| 546 | +/// using `swiftscan_cache_cancellation_token_dispose`. |
| 547 | +SWIFTSCAN_PUBLIC void swiftscan_cache_query_async( |
| 548 | + swiftscan_cas_t cas, const char *key, bool globally, void *ctx, |
| 549 | + void (*callback)(void *ctx, swiftscan_cache_result_t, swiftscan_cas_id_t, |
| 550 | + swiftscan_string_ref_t error), |
| 551 | + swiftscan_cache_cancellation_token_t *); |
| 552 | + |
| 553 | +/// Dispose a CASID. |
| 554 | +SWIFTSCAN_PUBLIC void swiftscan_cas_id_dispose(swiftscan_cas_id_t); |
| 555 | + |
| 556 | +/// Download and materialized the CASObject referenced by the CASID in the local |
| 557 | +/// CAS if needed from a remote CAS. |
| 558 | +/// If the return value is SWIFTSCAN_CACHE_RESULT_ERROR, the error message is |
| 559 | +/// returned via \c error parameter and it caller needs to free the message |
| 560 | +/// using `swiftscan_string_dispose`. |
| 561 | +SWIFTSCAN_PUBLIC swiftscan_cache_result_t swiftscan_cache_load_object( |
| 562 | + swiftscan_cas_t cas, swiftscan_cas_id_t, swiftscan_string_ref_t *error); |
| 563 | + |
| 564 | +/// Async version of `swiftscan_cache_load_object` where result is returned via |
| 565 | +/// callback. \c ctx is an opaque value that passed to the callback and |
| 566 | +/// \c swiftscan_cache_cancellation_token_t will return an token that can be |
| 567 | +/// used to cancel the async operation. The token needs to be freed by caller |
| 568 | +/// using `swiftscan_cache_cancellation_token_dispose`. |
| 569 | +SWIFTSCAN_PUBLIC void swiftscan_cache_load_object_async( |
| 570 | + swiftscan_cas_t cas, swiftscan_cas_id_t, void *ctx, |
| 571 | + void (*callback)(void *ctx, swiftscan_cache_result_t, |
| 572 | + swiftscan_string_ref_t error), |
| 573 | + swiftscan_cache_cancellation_token_t *); |
| 574 | + |
| 575 | +/// Make the cache compilation available globally. \c callback will be called |
| 576 | +/// on completion. |
| 577 | +/// \c swiftscan_cache_cancellation_token_t will return an token that can be |
| 578 | +/// used to cancel the async operation. The token needs to be freed by caller |
| 579 | +/// using `swiftscan_cache_cancellation_token_dispose`. |
| 580 | +SWIFTSCAN_PUBLIC void swiftscan_cache_make_global_async( |
| 581 | + swiftscan_cas_t cas, const char *key, void *ctx, |
| 582 | + void (*callback)(void *ctx, swiftscan_string_ref_t error), |
| 583 | + swiftscan_cache_cancellation_token_t *); |
| 584 | + |
| 585 | +/// Cancel the async cache action that is associated with token. |
| 586 | +SWIFTSCAN_PUBLIC void |
| 587 | + swiftscan_cache_action_cancel(swiftscan_cache_cancellation_token_t); |
| 588 | + |
| 589 | +/// Dispose the cancellation token. |
| 590 | +SWIFTSCAN_PUBLIC void swiftscan_cache_cancellation_token_dispose( |
| 591 | + swiftscan_cache_cancellation_token_t); |
| 592 | + |
| 593 | +/// Replay the cached compilation using command-line. |
| 594 | +/// If the return value is SWIFTSCAN_CACHE_RESULT_ERROR, the error message is |
| 595 | +/// returned via \c error parameter and it caller needs to free the message |
| 596 | +/// using `swiftscan_string_dispose`. |
| 597 | +SWIFTSCAN_PUBLIC swiftscan_cache_result_t swiftscan_cache_replay_compilation( |
| 598 | + swiftscan_cas_t cas, int argc, const char **argv, void *reserved, |
| 599 | + swiftscan_string_ref_t *error); |
| 600 | + |
| 601 | +/// Async replay the cached compilation. Callback function will be provided |
| 602 | +/// by the cache replay result, and its stdout, stderr, and any error message. |
| 603 | +/// \c ctx is an opaque value that passed to the callback and |
| 604 | +/// \c swiftscan_cache_cancellation_token_t will return an token that can be |
| 605 | +/// used to cancel the async operation. The token needs to be freed by caller |
| 606 | +/// using `swiftscan_cache_cancellation_token_dispose`. |
| 607 | +SWIFTSCAN_PUBLIC void swiftscan_cache_replay_compilation_async( |
| 608 | + swiftscan_cas_t cas, int argc, const char **argv, void *reserved, void *ctx, |
| 609 | + void (*callback)(void *ctx, swiftscan_cache_result_t, |
| 610 | + swiftscan_string_ref_t std_out, |
| 611 | + swiftscan_string_ref_t std_err, |
| 612 | + swiftscan_string_ref_t error), |
| 613 | + swiftscan_cache_cancellation_token_t *); |
| 614 | + |
500 | 615 | //===----------------------------------------------------------------------===//
|
501 | 616 |
|
502 | 617 | SWIFTSCAN_END_DECLS
|
|
0 commit comments