Skip to content

Commit

Permalink
Rename _OpenGraph to OpenGraph_SPI (#86)
Browse files Browse the repository at this point in the history
* Rename _OpenGraph to OpenGraph_SPI

* Add InternalImportsByDefault support
  • Loading branch information
Kyle-Ye authored Nov 4, 2024
1 parent 60d2376 commit f459df4
Show file tree
Hide file tree
Showing 129 changed files with 37 additions and 31 deletions.
14 changes: 4 additions & 10 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ default:
}

var sharedSwiftSettings: [SwiftSetting] = [
.enableUpcomingFeature("InternalImportsByDefault"),
.define("OPENGRAPH_RELEASE_\(releaseVersion)"),
.swiftLanguageMode(.v5),
]
Expand Down Expand Up @@ -103,14 +104,7 @@ let includePath = SDKPath.appending("/usr/lib/swift")

let package = Package(
name: "OpenGraph",
platforms: [
.iOS(.v15),
.macOS(.v12),
.macCatalyst(.v15),
.tvOS(.v15),
.watchOS(.v8),
.visionOS(.v1),
],
platforms: platforms,
products: [
.library(name: "OpenGraphShims", targets: ["OpenGraphShims"]),
.library(name: "OpenGraph", targets: ["OpenGraph"]),
Expand All @@ -123,7 +117,7 @@ let package = Package(
// OpenGraph is a C++ & Swift mix target.
// The SwiftPM support for such usage is still in progress.
.target(
name: "_OpenGraph",
name: "OpenGraph_SPI",
cSettings: [
.unsafeFlags(["-I", includePath], .when(platforms: .nonDarwinPlatforms)),
.define("__COREFOUNDATION_FORSWIFTFOUNDATIONONLY__", to: "1", .when(platforms: .nonDarwinPlatforms)),
Expand All @@ -135,7 +129,7 @@ let package = Package(
),
.target(
name: "OpenGraph",
dependencies: ["_OpenGraph"],
dependencies: ["OpenGraph_SPI"],
swiftSettings: sharedSwiftSettings
),
.plugin(
Expand Down
18 changes: 15 additions & 3 deletions [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,19 @@ func envEnable(_ key: String, default defaultValue: Bool = false) -> Bool {
let isXcodeEnv = Context.environment["__CFBundleIdentifier"] == "com.apple.dt.Xcode"
let development = envEnable("OPENGRAPH_DEVELOPMENT", default: false)

var sharedSwiftSettings: [SwiftSetting] = []
let releaseVersion = Context.environment["OPENGRAPH_TARGET_RELEASE"].flatMap { Int($0) } ?? 2021

var sharedSwiftSettings: [SwiftSetting] = [
.enableExperimentalFeature("AccessLevelOnImport"),
.enableUpcomingFeature("InternalImportsByDefault"),
.define("OPENGRAPH_RELEASE_\(releaseVersion)"),
]

if releaseVersion >= 2021 {
for year in 2021 ... releaseVersion {
sharedSwiftSettings.append(.define("OPENGRAPH_SUPPORT_\(year)_API"))
}
}

let warningsAsErrorsCondition = envEnable("OPENGRAPH_WERROR", default: isXcodeEnv && development)
if warningsAsErrorsCondition {
Expand Down Expand Up @@ -79,7 +91,7 @@ let package = Package(
// OpenGraph is a C++ & Swift mix target.
// The SwiftPM support for such usage is still in progress.
.target(
name: "_OpenGraph",
name: "OpenGraph_SPI",
cSettings: [
.unsafeFlags(["-I", includePath], .when(platforms: .nonDarwinPlatforms)),
.define("__COREFOUNDATION_FORSWIFTFOUNDATIONONLY__", to: "1", .when(platforms: .nonDarwinPlatforms)),
Expand All @@ -91,7 +103,7 @@ let package = Package(
),
.target(
name: "OpenGraph",
dependencies: ["_OpenGraph"],
dependencies: ["OpenGraph_SPI"],
swiftSettings: sharedSwiftSettings
),
.plugin(
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Attribute/AnyAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: API complete

import _OpenGraph
public import OpenGraph_SPI

public typealias AnyAttribute = OGAttribute

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Attribute/Attribute.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _OpenGraph
public import OpenGraph_SPI

@frozen
@propertyWrapper
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Body/AttributeBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: Complete

import _OpenGraph
public import OpenGraph_SPI

public protocol _AttributeBody {
static func _destroySelf(_ pointer: UnsafeMutableRawPointer)
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Rule/AnyRuleContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: Complete

import _OpenGraph
public import OpenGraph_SPI

@frozen
public struct AnyRuleContext {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Rule/Rule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: Complete

import _OpenGraph
public import OpenGraph_SPI

public protocol Rule: _AttributeBody {
associatedtype Value
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Rule/RuleContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: Complete

import _OpenGraph
public import OpenGraph_SPI

@frozen
public struct RuleContext<Value> {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Rule/StatefulRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: Complete

import _OpenGraph
public import OpenGraph_SPI

public protocol StatefulRule: _AttributeBody {
associatedtype Value
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Weak/AnyWeakAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: Complete

import _OpenGraph
public import OpenGraph_SPI

public typealias AnyWeakAttribute = OGWeakAttribute

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Weak/WeakAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: Complete

import _OpenGraph
public import OpenGraph_SPI

@frozen
@propertyWrapper
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Export.swift
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@_exported import _OpenGraph
@_exported public import OpenGraph_SPI
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Graph/OGGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: WIP

import _OpenGraph
public import OpenGraph_SPI

extension OGGraph {
public static func typeIndex(
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Graph/OGSubgraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: WIP

import _OpenGraph
public import OpenGraph_SPI

extension OGSubgraph {
public func addObserver(_ observer: () -> Void) -> Int {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Runtime/CompareValues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: Complete

import _OpenGraph
public import OpenGraph_SPI

@_silgen_name("OGCompareValues")
private func OGCompareValues(
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Runtime/OGTupleType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
//

import _OpenGraph
public import OpenGraph_SPI

@_silgen_name("OGTupleElementType")
@inline(__always)
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Runtime/OGTypeApplyEnumData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
//

import _OpenGraph
// public import OpenGraph_SPI

@discardableResult
public func withUnsafePointerToEnumCase<T>(
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Runtime/OGTypeID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: WIP

import _OpenGraph
public import OpenGraph_SPI
#if canImport(ObjectiveC)
import Foundation
#endif
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraphShims/GraphShims.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// GraphShims.swift

#if OPENGRAPH_ATTRIBUTEGRAPH
@_exported import AttributeGraph
@_exported public import AttributeGraph
public typealias OGAttributeFlags = AGAttributeFlags
public typealias OGAttributeInfo = AGAttributeInfo
public typealias OGAttributeType = AGAttributeType
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Tests/OpenGraphCompatibilityTests/GraphShims.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//

#if OPENGRAPH_COMPATIBILITY_TEST
@_exported import AttributeGraph
@_exported public import AttributeGraph
public typealias OGAttributeFlags = AGAttributeFlags
public typealias OGAttributeInfo = AGAttributeInfo
public typealias OGAttributeType = AGAttributeType
Expand Down

0 comments on commit f459df4

Please sign in to comment.