Skip to content

[Macros] Add 'LibraryPluginProvider' #2300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2024

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Oct 17, 2023

LibraryPluginProvider is a PluginProvider that can load shared library plugins at runtime.


in the near future, combined with #2301, in ASTGen, we can easily create in-process "plugin server" like

@_spi(Compiler) import SwiftCompilerPluginMessageHandling

let inProcPlugins = CompilerPluginMessageHandler(provider: LibraryPluginProvier.shared)

// Load in-process plugins.
let response = inProcPlugins.handleMessage(
  HostToPluginMessage.loadPluginLibrary(libraryPath: path, moduleName: module)
)

// Expand macros.
let response = inProcPlugins.handleMessage(
  HostToPluginMessage.expandFreestandingMacro(...)
)

so we can treat in-process plugins as just another plugin server

@rintaro
Copy link
Member Author

rintaro commented Oct 18, 2023

@swift-ci Please smoke test

// punycode encodings or word substitutions.
// FIXME: This is process global. Can we limit it to a specific .dylib ?
for suffix in [
/*struct*/ "V", /*enum*/ "O", /*class*/ "C"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need to support actors? Or are they mangled as classes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently actors are mangled as classes.

@rintaro rintaro force-pushed the macros-library-provider branch 2 times, most recently from 2a486f7 to 3ec336f Compare May 1, 2024 13:31
@rintaro
Copy link
Member Author

rintaro commented May 1, 2024

swiftlang/swift#69236
@swift-ci Please test

@rintaro rintaro force-pushed the macros-library-provider branch from 3ec336f to f15fc25 Compare May 1, 2024 17:39
@rintaro
Copy link
Member Author

rintaro commented May 1, 2024

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented May 1, 2024

@swift-ci Please test Windows

@rintaro rintaro force-pushed the macros-library-provider branch from f15fc25 to 8c7baac Compare May 1, 2024 19:27
@rintaro
Copy link
Member Author

rintaro commented May 1, 2024

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented May 1, 2024

@swift-ci Please test Windows

@rintaro rintaro closed this May 1, 2024
@rintaro rintaro reopened this May 1, 2024
@rintaro
Copy link
Member Author

rintaro commented May 1, 2024

@swift-ci Please test Windows

@rintaro rintaro force-pushed the macros-library-provider branch from 8c7baac to 6ed9ea2 Compare May 1, 2024 23:38
@rintaro
Copy link
Member Author

rintaro commented May 1, 2024

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented May 1, 2024

@swift-ci Please test Windows

@rintaro
Copy link
Member Author

rintaro commented May 2, 2024

@swift-ci Please test macOS

#if swift(>=6.0)
public import SwiftSyntaxMacros
@_spi(PluginMessage) public import SwiftCompilerPluginMessageHandling
// NOTE: Do not use '_'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// NOTE: Do not use '_'
// NOTE: Do not use '_SwiftSyntaxCShims' for 'dlopen' and 'LoadLibraryW' (Windows) because we don't want other modules depend on 'WinSDK'.

@rintaro rintaro marked this pull request as ready for review May 2, 2024 05:34
@rintaro rintaro requested a review from bnbarham as a code owner May 2, 2024 05:34
@rintaro rintaro requested a review from hamishknight May 2, 2024 05:35
@rintaro rintaro force-pushed the macros-library-provider branch from 6ed9ea2 to 1693c4e Compare May 2, 2024 17:32
LibraryPluginProvider is a 'PluginProvider' type that can load shared
library plugins at runtime.
@rintaro rintaro force-pushed the macros-library-provider branch from 1693c4e to 1c9eb89 Compare May 5, 2024 01:37
@rintaro
Copy link
Member Author

rintaro commented May 5, 2024

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented May 5, 2024

@swift-ci Please test Windows

@rintaro rintaro merged commit 60bc6d4 into swiftlang:main May 5, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants