2121
2222import PackageDescription
2323
24- #if os(macOS)
24+ // This is quite janky, but it's more streamlined than redefining the manifest for each platform
25+ // We are using the prebuilt binary for SwiftLint, which is not statically linked and is not portable across
26+ // different Linux distributions than the ones used in their Docker image. Since WatchDuck is designed to be a
27+ // portable binary, SwiftLint is simply omitted from Linux builds. This is okay since the WatchDuck CI always
28+ // runs on a macOS machine, and the Linux binaries are cross-compiled statically. We could build SwiftLint from
29+ // source as part of the WatchDuck build process, but that would add too much overhead and get annoying pretty quickly. :}
30+ func platformDependencies( ) -> [ Package . Dependency ] {
31+ #if os(macOS)
32+ return [ Package . Dependency. package ( url: " https://github.com/SimplyDanny/SwiftLintPlugins " , revision: " a60b5704f335fc18aa3aea3564c74774a338425f " ) ]
33+ #else
34+ return [ ]
35+ #endif
36+ }
37+
38+ func platformPlugins( ) -> [ Target . PluginUsage ] {
39+ #if os(macOS)
40+ return [ Target . PluginUsage. plugin ( name: " SwiftLintBuildToolPlugin " , package : " SwiftLintPlugins " ) ]
41+ #else
42+ return [ ]
43+ #endif
44+ }
45+
2546let package = Package (
2647 name: " WatchDuck " ,
2748 platforms: [ . macOS( . v12) ] ,
2849 dependencies: [
29- . package ( url: " https://github.com/apple/swift-argument-parser.git " , revision: " 1.5.0 " ) ,
30- . package ( url: " https://github.com/jpsim/Yams.git " , revision: " 5.3.1 " ) ,
31- . package ( url: " https://github.com/JohnSundell/Plot.git " , revision: " 0.14.0 " ) ,
32- . package ( url: " https://github.com/JohnSundell/ShellOut.git " , revision: " 2.3.0 " ) ,
33- . package ( url: " https://github.com/SimplyDanny/SwiftLintPlugins " , revision: " 0.58.2 " ) ,
34- . package ( url: " https://github.com/swiftlang/swift-docc-plugin " , from: " 1.1.0 " )
35- ] ,
50+ . package ( url: " https://github.com/apple/swift-argument-parser.git " , revision: " 41982a3656a71c768319979febd796c6fd111d5c " ) ,
51+ . package ( url: " https://github.com/jpsim/Yams.git " , revision: " b4b8042411dc7bbb696300a34a4bf3ba1b7ad19b " ) ,
52+ . package ( url: " https://github.com/JohnSundell/Plot.git " , revision: " 271926b4413fe868739d99f5eadcf2bd6cd62fb8 " ) ,
53+ . package ( url: " https://github.com/JohnSundell/ShellOut.git " , revision: " e1577acf2b6e90086d01a6d5e2b8efdaae033568 " ) ,
54+ . package ( url: " https://github.com/swiftlang/swift-docc-plugin " , revision: " 85e4bb4e1cd62cec64a4b8e769dcefdf0c5b9d64 " )
55+ ] + platformDependencies( ) ,
3656 targets: [
3757 // Targets are the basic building blocks of a package, defining a module or a test suite.
3858 // Targets can depend on other targets in this package and products from dependencies.
@@ -42,39 +62,12 @@ let package = Package(
4262 . product( name: " ArgumentParser " , package : " swift-argument-parser " ) ,
4363 . product( name: " Yams " , package : " Yams " ) ,
4464 . product( name: " Plot " , package : " plot " ) ,
45- . product( name: " ShellOut " , package : " ShellOut " )
65+ . product( name: " ShellOut " , package : " ShellOut " ) ,
4666 ] ,
4767 resources: [
4868 . copy( " Resources " )
4969 ] ,
50- plugins: [ . plugin( name: " SwiftLintBuildToolPlugin " , package : " SwiftLintPlugins " ) ]
51-
52- )
53- ]
54- )
55- #else
56- let package = Package (
57- name: " WatchDuck " ,
58- platforms: [ . macOS( . v12) ] ,
59- dependencies: [
60- . package ( url: " https://github.com/apple/swift-argument-parser.git " , revision: " 1.5.0 " ) ,
61- . package ( url: " https://github.com/jpsim/Yams.git " , revision: " 5.1.3 " ) ,
62- . package ( url: " https://github.com/JohnSundell/Plot.git " , revision: " 0.14.0 " ) ,
63- . package ( url: " https://github.com/JohnSundell/ShellOut.git " , revision: " 2.3.0 " )
64- ] ,
65- targets: [
66- . executableTarget(
67- name: " watchduck " ,
68- dependencies: [
69- . product( name: " ArgumentParser " , package : " swift-argument-parser " ) ,
70- . product( name: " Yams " , package : " Yams " ) ,
71- . product( name: " Plot " , package : " plot " ) ,
72- . product( name: " ShellOut " , package : " ShellOut " )
73- ] ,
74- resources: [
75- . copy( " Resources " )
76- ]
70+ plugins: [ ] + platformPlugins( )
7771 )
7872 ]
7973)
80- #endif
0 commit comments