-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// swift-tools-version: 5.9 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import Foundation | ||
import PackageDescription | ||
|
||
let exampleTarget = Target.executableTarget( | ||
name: "Example", | ||
dependencies: [ | ||
.product(name: "OpenSwiftUI", package: "OpenSwiftUI"), | ||
], | ||
path: "Example", | ||
sources: ["ExampleApp.swift", "ContentView.swift"] | ||
) | ||
|
||
let package = Package( | ||
name: "Example", | ||
platforms: [ | ||
.macOS(.v10_15), | ||
], | ||
products: [.executable(name: "Example", targets: ["Example"])], | ||
dependencies: [ | ||
.package(path: "../"), | ||
.package(url: "https://github.com/OpenSwiftUIProject/OpenGraph", branch: "main"), | ||
], | ||
targets: [ | ||
exampleTarget, | ||
] | ||
) | ||
|
||
func envEnable(_ key: String, default defaultValue: Bool = false) -> Bool { | ||
guard let value = ProcessInfo.processInfo.environment[key] else { | ||
return defaultValue | ||
} | ||
if value == "1" { | ||
return true | ||
} else if value == "0" { | ||
return false | ||
} else { | ||
return defaultValue | ||
} | ||
} | ||
|
||
#if os(macOS) | ||
let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH", default: true) | ||
#else | ||
let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH") | ||
#endif | ||
|
||
extension Target { | ||
func addAGSettings() { | ||
// FIXME: Weird SwiftPM behavior for binary Target. Otherwize we'll get the following error message | ||
// "could not determine executable path for bundle 'AttributeGraph.framework'" | ||
dependencies.append(.product(name: "AttributeGraph", package: "OpenGraph")) | ||
|
||
var swiftSettings = swiftSettings ?? [] | ||
swiftSettings.append(.define("OPENGRAPH_ATTRIBUTEGRAPH")) | ||
self.swiftSettings = swiftSettings | ||
} | ||
} | ||
|
||
if attributeGraphCondition { | ||
exampleTarget.addAGSettings() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters