Skip to content

Revert the use of generate-pipeline-plugin on Windows platforms. #423

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@
import Foundation
import PackageDescription

// FIXME: The `generate-pipeline-plugin` doesn't appear to be executing correctly during the build
// on Windows. To work around this for the time being, we check in the generated files and don't
// run the plugin there, but continue to run the plugin on other platforms and exclue the generated
// files from the build.
#if os(Windows)
let swiftFormatExclusions: [String] = []
let swiftFormatConfigurationExclusions: [String] = []
let swiftFormatRulesExclusions: [String] = []
let pluginsToRun: [Target.PluginUsage] = []
#else
let swiftFormatExclusions: [String] = ["Pipelines+Generated.swift"]
let swiftFormatConfigurationExclusions: [String] = ["RuleRegistry+Generated.swift"]
let swiftFormatRulesExclusions: [String] = ["RuleNameCache+Generated.swift"]
let pluginsToRun: [Target.PluginUsage] = ["generate-pipeline-plugin"]
#endif

let package = Package(
name: "swift-format",
platforms: [
Expand Down Expand Up @@ -49,11 +65,13 @@ let package = Package(
.product(name: "SwiftOperators", package: "swift-syntax"),
.product(name: "SwiftParser", package: "swift-syntax"),
],
plugins: ["generate-pipeline-plugin"]
exclude: swiftFormatExclusions,
plugins: pluginsToRun
),
.target(
name: "SwiftFormatConfiguration",
plugins: ["generate-pipeline-plugin"]
exclude: swiftFormatConfigurationExclusions,
plugins: pluginsToRun
),
.target(
name: "SwiftFormatCore",
Expand All @@ -66,7 +84,8 @@ let package = Package(
.target(
name: "SwiftFormatRules",
dependencies: ["SwiftFormatCore", "SwiftFormatConfiguration"],
plugins: ["generate-pipeline-plugin"]
exclude: swiftFormatRulesExclusions,
plugins: pluginsToRun
),
.target(
name: "SwiftFormatPrettyPrint",
Expand Down
33 changes: 33 additions & 0 deletions Scripts/generate-all-pipelines.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
#
# This script is used to manually generate sources otherwise generated by the
# `generate-pipeline-plugin` build tool, until that tool is working in Windows
# builds. The generated sources will be ignored when building on non-Windows
# platforms.

SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
PACKAGE_DIR="$(dirname -- "${SCRIPT_DIR}")"
SOURCES_DIR="${PACKAGE_DIR}/Sources"

echo "*** Generating ${SOURCES_DIR}/SwiftFormat/Pipelines+Generated.swift..."

swift run --package-path "${PACKAGE_DIR}" generate-pipeline \
--sources-directory "${SOURCES_DIR}" \
--output-file "${SOURCES_DIR}/SwiftFormat/Pipelines+Generated.swift" \
--target SwiftFormat

echo "*** Generating ${SOURCES_DIR}/SwiftFormatConfiguration/RuleRegistry+Generated.swift..."

swift run --package-path "${PACKAGE_DIR}" generate-pipeline \
--sources-directory "${SOURCES_DIR}" \
--output-file "${SOURCES_DIR}/SwiftFormatConfiguration/RuleRegistry+Generated.swift" \
--target SwiftFormatConfiguration

echo "*** Generating ${SOURCES_DIR}/SwiftFormatRules/RuleNameCache+Generated.swift..."

swift run --package-path "${PACKAGE_DIR}" generate-pipeline \
--sources-directory "${SOURCES_DIR}" \
--output-file "${SOURCES_DIR}/SwiftFormatRules/RuleNameCache+Generated.swift" \
--target SwiftFormatRules

echo "*** Done!"
Loading