Skip to content

Commit e12148a

Browse files
committed
libSwiftScanner: add an API to invoke compiler in process
1 parent 8226e54 commit e12148a

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

Diff for: include/swift-c/DependencyScan/DependencyScan.h

+3
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,9 @@ swiftscan_scanner_cache_load(swiftscan_scanner_t scanner,
359359
SWIFTSCAN_PUBLIC void
360360
swiftscan_scanner_cache_reset(swiftscan_scanner_t scanner);
361361

362+
/// An entry point to invoke the compiler via a library call.
363+
SWIFTSCAN_PUBLIC int invoke_swift_compiler(int argc, const char **argv);
364+
362365
//===----------------------------------------------------------------------===//
363366

364367
SWIFTSCAN_END_DECLS

Diff for: tools/libSwiftScan/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ add_dependencies(libSwiftScan
1717

1818
target_link_libraries(libSwiftScan PRIVATE
1919
swiftDependencyScan
20-
swiftDriverTool)
20+
swiftDriverTool
21+
libswift)
2122

2223
set_target_properties(libSwiftScan
2324
PROPERTIES

Diff for: tools/libSwiftScan/libSwiftScan.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
#include "swift/Basic/LLVMInitialize.h"
18+
#include "swift/DriverTool/DriverTool.h"
1819
#include "swift/DependencyScan/DependencyScanImpl.h"
1920
#include "swift/DependencyScan/DependencyScanningTool.h"
2021
#include "swift/DependencyScan/StringUtils.h"
@@ -510,3 +511,7 @@ swiftscan_compiler_supported_features_query() {
510511
// TODO: We are yet to figure out how "Features" will be organized.
511512
return nullptr;
512513
}
514+
515+
int invoke_swift_compiler(int argc, const char **argv) {
516+
return swift::mainEntry(argc, argv);
517+
}

Diff for: tools/libSwiftScan/libSwiftScan.exports

+1
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,4 @@ swiftscan_compiler_supported_features_query
5757
swiftscan_scanner_cache_serialize
5858
swiftscan_scanner_cache_load
5959
swiftscan_scanner_cache_reset
60+
invoke_swift_compiler

0 commit comments

Comments
 (0)