Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,21 @@ let isSPIBuild = envEnable("SPI_BUILD")
let isXcodeEnv = Context.environment["__CFBundleIdentifier"] == "com.apple.dt.Xcode"
let development = envEnable("OPENATTRIBUTEGRAPH_DEVELOPMENT", default: false)

let swiftBinPath = Context.environment["_"] ?? "/usr/bin/swift"
let swiftBinURL = URL(fileURLWithPath: swiftBinPath)
let SDKPath = swiftBinURL.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent().path
let includePath = SDKPath.appending("/usr/lib/swift")
// From Swift toolchain being installed or from Swift SDK.
func detectLibSwiftPath() -> String {
guard let libSwiftPath = Context.environment["OPENATTRIBUTEGRAPH_LIB_SWIFT_PATH"] else {
// Fallback when LIB_SWIFT_PATH is not set
let swiftBinPath = Context.environment["OPENATTRIBUTEGRAPH_BIN_SWIFT_PATH"] ?? Context.environment["_"] ?? "/usr/bin/swift"
let swiftBinURL = URL(fileURLWithPath: swiftBinPath)
let SDKPath = swiftBinURL.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent().path
return SDKPath.appending("/usr/lib/swift")
}
return libSwiftPath
}
let libSwiftPath = detectLibSwiftPath()

var sharedCSettings: [CSetting] = [
.unsafeFlags(["-I", includePath], .when(platforms: .nonDarwinPlatforms)),
.unsafeFlags(["-I", libSwiftPath], .when(platforms: .nonDarwinPlatforms)),
.define("NDEBUG", .when(configuration: .release)),
]

Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dependencies: [
```

> [!NOTE]
>
> - You may need to configure the Swift toolchain header for proper integration of OpenAttributeGraph
> - By default, OpenAttributeGraphShims will use the private AttributeGraph as its implementation on Apple platforms

Expand All @@ -49,6 +50,26 @@ For a simpler setup, you can use the prebuilt XCFramework available on the [rele

The current suggested toolchain to build the project is Swift 6.1.2 / Xcode 16.4.

### Set up LIB_SWIFT_PATH on non-Darwin platform

If your swift binary path is located in your `<toolchain>/usr/bin/swift` (eg. installed by [swiftbox](https://github.com/stevapple/swiftbox)), no setup is required.

Otherwise set up it manully by exporting `LIB_SWIFT_PATH` environment variable.

> The following command assume you already have [swiftly](https://github.com/swiftlang/swiftly) installed.

```shell
export OPENATTRIBUTEGRAPH_LIB_SWIFT_PATH="$(swiftly use --print-location)/usr/lib/swift"
# Or use the swift_static path
export OPENATTRIBUTEGRAPH_LIB_SWIFT_PATH="$(swiftly use --print-location)/usr/lib/swift_static"
```

Alternatively, you can set the path using the Swift SDK location. For example:

```shell
export OPENATTRIBUTEGRAPH_LIB_SWIFT_PATH=~/.swiftpm/swift-sdks/swift-6.1.3-RELEASE_static-linux-0.0.1.artifactbundle/swift-6.1.3-RELEASE_static-linux-0.0.1/swift-linux-musl/musl-1.2.5.sdk/aarch64/usr/lib/swift_static
```

## License

See LICENSE file - MIT
Expand Down