22import Foundation
33import PackageDescription
44
5- // MARK: - Configuration Service
6-
7- Package . Inject. local. dependencies = [
8- . package ( name: " wrkstrm-foundation " , path: " ../wrkstrm-foundation " ) ,
9- . package ( name: " common-log " , path: " ../../../common/domain/system/common-log " ) ,
10- . package ( name: " wrkstrm-main " , path: " ../wrkstrm-main " ) ,
11- ]
12-
13- Package . Inject. remote. dependencies = [
14- . package ( url: " https://github.com/wrkstrm/wrkstrm-foundation.git " , from: " 3.0.0 " ) ,
15- . package ( url: " https://github.com/wrkstrm/common-log.git " , from: " 3.0.0 " ) ,
16- . package ( url: " https://github.com/wrkstrm/wrkstrm-main.git " , from: " 3.0.0 " ) ,
17- ]
5+ let useLocalDeps : Bool = {
6+ guard let raw = ProcessInfo . processInfo. environment [ " SPM_USE_LOCAL_DEPS " ] else { return false }
7+ let v = raw. trimmingCharacters ( in: . whitespacesAndNewlines) . lowercased ( )
8+ return v == " 1 " || v == " true " || v == " yes "
9+ } ( )
10+
11+ func localOrRemote( name: String , path: String , url: String , from version: Version ) -> Package . Dependency {
12+ if useLocalDeps { return . package ( name: name, path: path) }
13+ return . package ( url: url, from: version)
14+ }
1815
19- // MARK: - Package Declaration
16+ let sharedSwiftSettings : [ SwiftSetting ] =
17+ useLocalDeps ? [ . unsafeFlags( [ " -Xfrontend " , " -warn-long-expression-type-checking=10 " ] ) ] : [ ]
2018
2119let package = Package (
2220 name: " WrkstrmNetworking " ,
@@ -31,7 +29,22 @@ let package = Package(
3129 products: [
3230 . library( name: " WrkstrmNetworking " , targets: [ " WrkstrmNetworking " ] )
3331 ] ,
34- dependencies: Package . Inject. shared. dependencies + [
32+ dependencies: [
33+ localOrRemote (
34+ name: " wrkstrm-foundation " ,
35+ path: " ../wrkstrm-foundation " ,
36+ url: " https://github.com/wrkstrm/wrkstrm-foundation.git " ,
37+ from: " 3.0.0 " ) ,
38+ localOrRemote (
39+ name: " common-log " ,
40+ path: " ../../../common/domain/system/common-log " ,
41+ url: " https://github.com/wrkstrm/common-log.git " ,
42+ from: " 3.0.0 " ) ,
43+ localOrRemote (
44+ name: " wrkstrm-main " ,
45+ path: " ../wrkstrm-main " ,
46+ url: " https://github.com/wrkstrm/wrkstrm-main.git " ,
47+ from: " 3.0.0 " ) ,
3548 . package ( url: " https://github.com/apple/swift-docc-plugin " , from: " 1.4.0 " )
3649 ] ,
3750 targets: [
@@ -43,54 +56,13 @@ let package = Package(
4356 . product( name: " WrkstrmMain " , package : " wrkstrm-main " )
4457 ] ,
4558 path: " sources/wrkstrm-networking " ,
46- swiftSettings: Package . Inject . shared . swiftSettings ,
59+ swiftSettings: sharedSwiftSettings ,
4760 ) ,
4861 . testTarget(
4962 name: " WrkstrmNetworkingTests " ,
5063 dependencies: [ " WrkstrmNetworking " ] ,
5164 path: " tests/wrkstrm-networking-tests " ,
52- swiftSettings: Package . Inject . shared . swiftSettings ,
65+ swiftSettings: sharedSwiftSettings ,
5366 ) ,
5467 ]
5568)
56-
57- // MARK: - Package Service
58-
59- print ( " ---- Package Inject Deps: Begin ---- " )
60- print ( " Use Local Deps? \( ProcessInfo . useLocalDeps) " )
61- print ( Package . Inject. shared. dependencies. map ( \. kind) )
62- print ( " ---- Package Inject Deps: End ---- " )
63-
64- extension Package {
65- @MainActor
66- public struct Inject {
67- public static let version = " 1.0.0 "
68-
69- public var swiftSettings : [ SwiftSetting ] = [ ]
70- var dependencies : [ PackageDescription . Package . Dependency ] = [ ]
71-
72- public static let shared : Inject = ProcessInfo . useLocalDeps ? . local : . remote
73-
74- static var local : Inject = . init( swiftSettings: [ . local] )
75- static var remote : Inject = . init( )
76- }
77- }
78-
79- // MARK: - PackageDescription extensions
80-
81- extension SwiftSetting {
82- public static let local : SwiftSetting = . unsafeFlags( [
83- " -Xfrontend " ,
84- " -warn-long-expression-type-checking=10 " ,
85- ] )
86- }
87-
88- // MARK: - Foundation extensions
89-
90- extension ProcessInfo {
91- public static var useLocalDeps : Bool {
92- ProcessInfo . processInfo. environment [ " SPM_USE_LOCAL_DEPS " ] == " true "
93- }
94- }
95-
96- // PACKAGE_SERVICE_END_V1
0 commit comments