Skip to content
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

[Macros] Add 'LibraryPluginProvider' #2300

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
Collaborator

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

apple/swift#69236
@swift-ci Please test

@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 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
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
LibraryPluginProvider is a 'PluginProvider' type that can load shared
library plugins at runtime.
@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 apple: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.

None yet

3 participants