|
| 1 | +// swift-tools-version:5.7 |
| 2 | +/* |
| 3 | + This source file is part of the Swift.org open source project |
| 4 | + |
| 5 | + Copyright (c) 2021-2023 Apple Inc. and the Swift project authors |
| 6 | + Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | + |
| 8 | + See https://swift.org/LICENSE.txt for license information |
| 9 | + See https://swift.org/CONTRIBUTORS.txt for Swift project authors |
| 10 | +*/ |
| 11 | + |
| 12 | +import PackageDescription |
| 13 | +import class Foundation.ProcessInfo |
| 14 | + |
| 15 | +let cmarkPackageName = ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil ? "swift-cmark" : "cmark" |
| 16 | + |
| 17 | +let package = Package( |
| 18 | + name: "swift-markdown", |
| 19 | + products: [ |
| 20 | + .library( |
| 21 | + name: "Markdown", |
| 22 | + targets: ["Markdown"]), |
| 23 | + ], |
| 24 | + targets: [ |
| 25 | + .target( |
| 26 | + name: "Markdown", |
| 27 | + dependencies: [ |
| 28 | + "CAtomic", |
| 29 | + .product(name: "cmark-gfm", package: cmarkPackageName), |
| 30 | + .product(name: "cmark-gfm-extensions", package: cmarkPackageName), |
| 31 | + ], |
| 32 | + exclude: [ |
| 33 | + "CMakeLists.txt" |
| 34 | + ] |
| 35 | + ), |
| 36 | + .testTarget( |
| 37 | + name: "MarkdownTests", |
| 38 | + dependencies: ["Markdown"], |
| 39 | + resources: [.process("Visitors/Everything.md")]), |
| 40 | + .target(name: "CAtomic"), |
| 41 | + ] |
| 42 | +) |
| 43 | + |
| 44 | +// If the `SWIFTCI_USE_LOCAL_DEPS` environment variable is set, |
| 45 | +// we're building in the Swift.org CI system alongside other projects in the Swift toolchain and |
| 46 | +// we can depend on local versions of our dependencies instead of fetching them remotely. |
| 47 | +if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { |
| 48 | + // Building standalone, so fetch all dependencies remotely. |
| 49 | + package.dependencies += [ |
| 50 | + .package(url: "https://github.com/swiftlang/swift-cmark.git", branch: "gfm"), |
| 51 | + ] |
| 52 | + |
| 53 | + // SwiftPM command plugins are only supported by Swift version 5.6 and later. |
| 54 | + #if swift(>=5.6) |
| 55 | + package.dependencies += [ |
| 56 | + .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.1.0"), |
| 57 | + ] |
| 58 | + #endif |
| 59 | +} else { |
| 60 | + // Building in the Swift.org CI system, so rely on local versions of dependencies. |
| 61 | + package.dependencies += [ |
| 62 | + .package(path: "../cmark"), |
| 63 | + ] |
| 64 | +} |
0 commit comments