Skip to content

Run build tool plugins for C-family targets #6516

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 10, 2023

Conversation

neonichu
Copy link
Contributor

@neonichu neonichu commented May 3, 2023

While we intentionally don't support generating C sources from plugins today since we haven't figured out how to deal with headers etc, not running plugins at all without any diagnostics whatsoever seems like an implementation oversight based on the fact that we have two completely different implementations for Swift and C-family targets (which is something we also need to rectify at some point).

With this change, we're running build-tool plugins in the exact same way as we are doing it for Swift targets. We are only doing this for packages with tools-version 5.9 or higher in order to have any unintentional impact on existing packages.

rdar://101671614

@neonichu neonichu requested a review from abertelrud as a code owner May 3, 2023 21:41
@neonichu neonichu self-assigned this May 3, 2023
@neonichu
Copy link
Contributor Author

neonichu commented May 3, 2023

@swift-ci please smoke test

// MARK: - Compilation

extension LLBuildManifestBuilder {
private func addBuildToolPlugins(_ target: TargetBuildDescription) throws {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just extracted from computeSwiftCompileCmdInputs()


/// Shared functionality between `ClangTargetBuildDescription` and `SwiftTargetBuildDescription` with the eventual hope of having a single type.
struct SharedTargetBuildDescription {
static func computePluginGeneratedFiles(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just extracted from SwiftTargetBuildDescription

@neonichu
Copy link
Contributor Author

neonichu commented May 3, 2023

C:\Users\swift-ci\jenkins\workspace\swiftpm-PR-windows\swiftpm\Sources\Build\BuildDescription\ClangTargetBuildDescription.swift:137:72: error: cannot find 'SharedTargetBuildDescription' in scope

            (self.pluginDerivedSources, self.pluginDerivedResources) = SharedTargetBuildDescription.computePluginGeneratedFiles(

                                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

forgot to add the new file to the CMake build

@neonichu neonichu force-pushed the run-build-tool-plugins-for-c-family-targets branch from 88582bf to cf2592f Compare May 3, 2023 22:20
@neonichu
Copy link
Contributor Author

neonichu commented May 3, 2023

@swift-ci please smoke test

@MaxDesiatov
Copy link
Contributor

@swift-ci test windows

@neonichu neonichu force-pushed the run-build-tool-plugins-for-c-family-targets branch 2 times, most recently from 6b2f4cf to 8c4b5b2 Compare May 9, 2023 23:26
@neonichu
Copy link
Contributor Author

neonichu commented May 9, 2023

@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

/Users/ec2-user/jenkins/workspace/swift-package-manager-with-xcode-self-hosted-PR-osx/branch-main/swiftpm/Sources/Build/BuildDescription/ClangTargetBuildDescription.swift:116:34: error: cannot find type 'PrebuildCommandResult' in scope
        prebuildCommandResults: [PrebuildCommandResult] = [],
                                 ^~~~~~~~~~~~~~~~~~~~~

I may have accidentally removed an import during rebase.

While we intentionally don't support generating C sources from plugins today since we haven't figured out how to deal with headers etc, not running plugins at all without any diagnostics whatsoever seems like an implementation oversight based on the fact that we have two completely different implementations for Swift and C-family targets (which is something we also need to rectify at some point).

With this change, we're running build-tool plugins in the exact same way as we are doing it for Swift targets. We are only doing this for packages with tools-version 5.9 or higher in order to have any unintentional impact on existing packages.

rdar://101671614

Co-authored-by: Max Desiatov <m_desiatov@apple.com>
@neonichu neonichu force-pushed the run-build-tool-plugins-for-c-family-targets branch from 8c4b5b2 to 7abffec Compare May 10, 2023 16:56
@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

@swift-ci please smoke test windows

@neonichu neonichu merged commit 678e683 into main May 10, 2023
@neonichu neonichu deleted the run-build-tool-plugins-for-c-family-targets branch May 10, 2023 23:46
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