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

build: remove the PreviewServer on Windows #604

Merged
merged 1 commit into from
May 31, 2023
Merged
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
79 changes: 55 additions & 24 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,6 @@ let package = Package(
swiftSettings: swiftSettings
),

// Command-line tool library
.target(
name: "SwiftDocCUtilities",
dependencies: [
.target(name: "SwiftDocC"),
.product(name: "NIOHTTP1", package: "swift-nio"),
.product(name: "ArgumentParser", package: "swift-argument-parser")
],
swiftSettings: swiftSettings
),
.testTarget(
name: "SwiftDocCUtilitiesTests",
dependencies: [
.target(name: "SwiftDocCUtilities"),
.target(name: "SwiftDocC"),
.target(name: "SwiftDocCTestUtilities"),
],
resources: [
.copy("Test Resources"),
.copy("Test Bundles"),
],
swiftSettings: swiftSettings
),
// Test utility library
.target(
name: "SwiftDocCTestUtilities",
Expand Down Expand Up @@ -126,20 +103,74 @@ let package = Package(
]
)

// Command-line tool library
#if os(Windows)
package.targets.append(
.target(
name: "SwiftDocCUtilities",
dependencies: [
.target(name: "SwiftDocC"),
.product(name: "ArgumentParser", package: "swift-argument-parser")
],
exclude: [
// PreviewServer requires NIO which cannot support non-POSIX platforms.
"PreviewServer",
"Action/Actions/PreviewAction.swift",
"ArgumentParsing/ActionExtensions/PreviewAction+CommandInitialization.swift",
"ArgumentParsing/Subcommands/Preview.swift",
],
swiftSettings: swiftSettings
)
)
#else
package.targets.append(
.target(
name: "SwiftDocCUtilities",
dependencies: [
.target(name: "SwiftDocC"),
.product(name: "NIOHTTP1", package: "swift-nio"),
.product(name: "ArgumentParser", package: "swift-argument-parser")
],
swiftSettings: swiftSettings
)
)
#endif

package.targets.append(
.testTarget(
name: "SwiftDocCUtilitiesTests",
dependencies: [
.target(name: "SwiftDocCUtilities"),
.target(name: "SwiftDocC"),
.target(name: "SwiftDocCTestUtilities"),
],
resources: [
.copy("Test Resources"),
.copy("Test Bundles"),
],
swiftSettings: swiftSettings
)
)

// If the `SWIFTCI_USE_LOCAL_DEPS` environment variable is set,
// we're building in the Swift.org CI system alongside other projects in the Swift toolchain and
// we can depend on local versions of our dependencies instead of fetching them remotely.
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
// Building standalone, so fetch all dependencies remotely.
package.dependencies += [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.53.0"),
.package(url: "https://github.com/apple/swift-markdown.git", branch: "main"),
.package(url: "https://github.com/apple/swift-lmdb.git", branch: "main"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.2"),
.package(url: "https://github.com/apple/swift-docc-symbolkit", branch: "main"),
.package(url: "https://github.com/apple/swift-crypto.git", from: "2.5.0"),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
]

#if !os(Windows)
package.dependencies += [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.53.0"),
]
#endif
} else {
// Building in the Swift.org CI system, so rely on local versions of dependencies.
package.dependencies += [
Expand Down
9 changes: 7 additions & 2 deletions Sources/SwiftDocCUtilities/Docc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@

import ArgumentParser

#if canImport(NIOHTTP)
private let subcommands: [ParsableCommand.Type] = [Docc.Convert.self, Docc.Index.self, Docc.Preview.self, Docc.ProcessArchive.self]
#else
private let subcommands: [ParsableCommand.Type] = [Docc.Convert.self, Docc.Index.self, Docc.ProcessArchive.self]
#endif

/// The default, command-line interface you use to compile and preview documentation.
public struct Docc: ParsableCommand {

public static var configuration = CommandConfiguration(
abstract: "Documentation Compiler: compile, analyze, and preview documentation.",
subcommands: [Convert.self, Index.self, Preview.self, ProcessArchive.self])
subcommands: subcommands)

public init() {}
}