Skip to content

Commit

Permalink
Add environment variable to force building as dynamic library
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed May 6, 2022
1 parent 0126c17 commit 78657cf
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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),
Expand Down Expand Up @@ -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

0 comments on commit 78657cf

Please sign in to comment.