Package.swift 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // swift-tools-version:5.9
  2. import PackageDescription
  3. // Builds the oref algorithm as a standalone, macOS-capable module
  4. // so the algorithm test suite can run with `swift test`
  5. //
  6. // This is a "shadow" package: it compiles the *existing* files in
  7. // place rather than owning its own copy, so there is exactly one
  8. // copy of every source file and the Xcode app target keeps
  9. // compiling the same ones. `Sources` and `OpenAPSSwiftTests` are
  10. // symlinks back to Trio/Sources and TrioTests/OpenAPSSwiftTests.
  11. //
  12. // This lives in a subdirectory, not the repo root, because Xcode
  13. // prefers a root Package.swift over Trio.xcworkspace when opening
  14. // a folder — a root manifest makes `xed .` open the package and
  15. // hides every app scheme.
  16. //
  17. // Usage:
  18. // swift test --package-path AlgorithmPackage
  19. // swift test --package-path AlgorithmPackage --filter IobGenerateTests
  20. let algorithmModels = [
  21. "Autosens",
  22. "BGTargets",
  23. "BasalProfileEntry",
  24. "BloodGlucose",
  25. "CarbRatios",
  26. "CarbsEntry",
  27. "Determination",
  28. "IOBEntry",
  29. "InsulinSensitivities",
  30. "Override",
  31. "Preferences",
  32. "PumpHistoryEvent",
  33. "PumpSettings",
  34. "TDD",
  35. "TempBasal",
  36. "TempTarget",
  37. "TrioCustomOrefVariables"
  38. ].map { "Models/\($0).swift" }
  39. let algorithmHelpers = [
  40. "ConvenienceExtensions",
  41. "Decimal+Extensions",
  42. "Formatters",
  43. "JSON",
  44. "Rounding",
  45. "String+Extensions",
  46. "TherapySettingsUtil",
  47. "TimeInterval+Convenience"
  48. ].map { "Helpers/\($0).swift" }
  49. let package = Package(
  50. name: "TrioAlgorithm",
  51. defaultLocalization: "en",
  52. platforms: [.macOS(.v14)],
  53. products: [
  54. .library(name: "Trio", targets: ["Trio"])
  55. ],
  56. targets: [
  57. .target(
  58. name: "Trio",
  59. path: "Sources",
  60. sources: [
  61. "APS/OpenAPSSwift",
  62. "APS/Extensions/DecimalExtensions.swift"
  63. ] + algorithmModels + algorithmHelpers,
  64. swiftSettings: [.define("TRIO_ALGORITHM_PACKAGE")]
  65. ),
  66. .testTarget(
  67. name: "OpenAPSSwiftTests",
  68. dependencies: ["Trio"],
  69. path: "OpenAPSSwiftTests",
  70. resources: [.copy("json")],
  71. swiftSettings: [.define("TRIO_ALGORITHM_PACKAGE")]
  72. )
  73. ]
  74. )