From d0d47d280d67894c24bf8471fe130de3d6ae764d Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Mon, 27 Jan 2025 23:38:34 +0000 Subject: [PATCH] Package target setup (#1) This PR contains the work done to setup the *executable*, *library*, and *test* targets for the Swift package. In addition, some boilerplate code has been removed. Reviewed-on: https://repo.rock-n-code.com/rock-n-code/colibri/pulls/1 Co-authored-by: Javier Cicchelli Co-committed-by: Javier Cicchelli --- Package.swift | 40 ++++++++++++++++++++++--- Sources/Executable/Colibri.swift | 13 ++++++++ Sources/Library/ColibriLibrary.swift | 1 + Sources/main.swift | 4 --- Tests/Library/ColibriLibraryTests.swift | 3 ++ 5 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 Sources/Executable/Colibri.swift create mode 100644 Sources/Library/ColibriLibrary.swift delete mode 100644 Sources/main.swift create mode 100644 Tests/Library/ColibriLibraryTests.swift diff --git a/Package.swift b/Package.swift index 80334c3..5026c61 100644 --- a/Package.swift +++ b/Package.swift @@ -1,14 +1,46 @@ // swift-tools-version: 6.0 -// The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "Colibri", + products: [ + .executable( + name: "colibri", + targets: ["Colibri"] + ), + .library( + name: "ColibriLibrary", + targets: ["ColibriLibrary"] + ) + ], + dependencies: [ + .package( + url: "https://github.com/apple/swift-argument-parser", + from: "1.0.0" + ) + ], targets: [ - // Targets are the basic building blocks of a package, defining a module or a test suite. - // Targets can depend on other targets in this package and products from dependencies. .executableTarget( - name: "Colibri"), + name: "Colibri", + dependencies: [ + .product( + name: "ArgumentParser", + package: "swift-argument-parser" + ), + .target(name: "ColibriLibrary") + ], + path: "Sources/Executable" + ), + .target( + name: "ColibriLibrary", + dependencies: [], + path: "Sources/Library" + ), + .testTarget( + name: "ColibriTests", + dependencies: ["ColibriLibrary"], + path: "Tests/Library" + ) ] ) diff --git a/Sources/Executable/Colibri.swift b/Sources/Executable/Colibri.swift new file mode 100644 index 0000000..02690d1 --- /dev/null +++ b/Sources/Executable/Colibri.swift @@ -0,0 +1,13 @@ +import ArgumentParser +import ColibriLibrary + +@main +struct Colibri: AsyncParsableCommand { + + // MARK: Functions + + func run() async throws { + // ... + } + +} diff --git a/Sources/Library/ColibriLibrary.swift b/Sources/Library/ColibriLibrary.swift new file mode 100644 index 0000000..fecc4ab --- /dev/null +++ b/Sources/Library/ColibriLibrary.swift @@ -0,0 +1 @@ +import Foundation diff --git a/Sources/main.swift b/Sources/main.swift deleted file mode 100644 index 44e20d5..0000000 --- a/Sources/main.swift +++ /dev/null @@ -1,4 +0,0 @@ -// The Swift Programming Language -// https://docs.swift.org/swift-book - -print("Hello, world!") diff --git a/Tests/Library/ColibriLibraryTests.swift b/Tests/Library/ColibriLibraryTests.swift new file mode 100644 index 0000000..5cfd2da --- /dev/null +++ b/Tests/Library/ColibriLibraryTests.swift @@ -0,0 +1,3 @@ +import Testing + +struct ColibriLibraryTests {}