|
2 | 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. |
3 | 3 |
|
4 | 4 | import PackageDescription |
| 5 | +import Foundation |
| 6 | + |
| 7 | +// MARK: - Pro |
| 8 | + |
| 9 | +extension [Target.Dependency] { |
| 10 | + func pro(_ targetNames: [String]) -> [Target.Dependency] { |
| 11 | + if isProIncluded { |
| 12 | + // include the pro package |
| 13 | + return self + targetNames.map { Target.Dependency.product(name: $0, package: "Pro") } |
| 14 | + } |
| 15 | + return self |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +extension [Package.Dependency] { |
| 20 | + var pro: [Package.Dependency] { |
| 21 | + if isProIncluded { |
| 22 | + // include the pro package |
| 23 | + return self + [.package(path: "../Pro/Pro")] |
| 24 | + } |
| 25 | + return self |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +let isProIncluded: Bool = { |
| 30 | + func isProIncluded(file: StaticString = #file) -> Bool { |
| 31 | + let filePath = "\(file)" |
| 32 | + let fileURL = URL(fileURLWithPath: filePath) |
| 33 | + let rootURL = fileURL |
| 34 | + .deletingLastPathComponent() |
| 35 | + .deletingLastPathComponent() |
| 36 | + let confURL = rootURL.appendingPathComponent("PLUS") |
| 37 | + if !FileManager.default.fileExists(atPath: confURL.path) { |
| 38 | + return false |
| 39 | + } |
| 40 | + do { |
| 41 | + let content = String( |
| 42 | + data: try Data(contentsOf: confURL), |
| 43 | + encoding: .utf8 |
| 44 | + ) |
| 45 | + print("") |
| 46 | + return content?.hasPrefix("YES") ?? false |
| 47 | + } catch { |
| 48 | + return false |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + return isProIncluded() |
| 53 | +}() |
| 54 | + |
| 55 | +// MARK: - Package |
5 | 56 |
|
6 | 57 | let package = Package( |
7 | 58 | name: "Core", |
@@ -322,52 +373,3 @@ let package = Package( |
322 | 373 | ] |
323 | 374 | ) |
324 | 375 |
|
325 | | -// MARK: - Pro |
326 | | - |
327 | | -extension [Target.Dependency] { |
328 | | - func pro(_ targetNames: [String]) -> [Target.Dependency] { |
329 | | - if isProIncluded { |
330 | | - // include the pro package |
331 | | - return self + targetNames.map { Target.Dependency.product(name: $0, package: "Pro") } |
332 | | - } |
333 | | - return self |
334 | | - } |
335 | | -} |
336 | | - |
337 | | -extension [Package.Dependency] { |
338 | | - var pro: [Package.Dependency] { |
339 | | - if isProIncluded { |
340 | | - // include the pro package |
341 | | - return self + [.package(path: "../Pro/Pro")] |
342 | | - } |
343 | | - return self |
344 | | - } |
345 | | -} |
346 | | - |
347 | | -import Foundation |
348 | | - |
349 | | -let isProIncluded: Bool = { |
350 | | - func isProIncluded(file: StaticString = #file) -> Bool { |
351 | | - let filePath = "\(file)" |
352 | | - let fileURL = URL(fileURLWithPath: filePath) |
353 | | - let rootURL = fileURL |
354 | | - .deletingLastPathComponent() |
355 | | - .deletingLastPathComponent() |
356 | | - let confURL = rootURL.appendingPathComponent("PLUS") |
357 | | - if !FileManager.default.fileExists(atPath: confURL.path) { |
358 | | - return false |
359 | | - } |
360 | | - do { |
361 | | - let content = String( |
362 | | - data: try Data(contentsOf: confURL), |
363 | | - encoding: .utf8 |
364 | | - ) |
365 | | - print("") |
366 | | - return content?.hasPrefix("YES") ?? false |
367 | | - } catch { |
368 | | - return false |
369 | | - } |
370 | | - } |
371 | | - |
372 | | - return isProIncluded() |
373 | | -}() |
|
0 commit comments