From 78657cfddc0d87c955319d5ab788c339aad2343b Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Fri, 6 May 2022 00:49:43 -0700 Subject: [PATCH] Add environment variable to force building as dynamic library --- Package.swift | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index f882810..8533e14 100644 --- a/Package.swift +++ b/Package.swift @@ -1,9 +1,12 @@ // swift-tools-version:5.5 import PackageDescription +import class Foundation.ProcessInfo -let libraryType: PackageDescription.Product.Library.LibraryType = .dynamic +// force building as dynamic library +let dynamicLibrary = ProcessInfo.processInfo.environment["SWIFT_BUILD_DYNAMIC_LIBRARY"] != nil +let libraryType: PackageDescription.Product.Library.LibraryType? = dynamicLibrary ? .dynamic : nil -let package = Package( +var package = Package( name: "BluetoothLinux", platforms: [ .macOS(.v10_15), @@ -59,3 +62,13 @@ let package = Package( ) ] ) + +// SwiftPM command plugins are only supported by Swift version 5.6 and later. +#if swift(>=5.6) +let buildDocs = ProcessInfo.processInfo.environment["BUILDING_FOR_DOCUMENTATION_GENERATION"] != nil +if buildDocs { + package.dependencies += [ + .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), + ] +} +#endif