diff --git a/Package.resolved b/Package.resolved index 4bcd2af..8649a6c 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,6 +1,15 @@ { - "originHash" : "3969417c2a67000e225174da55741dc4261b615b990ae4ce381417f06c5e9099", + "originHash" : "5d36627594955e7c1e9d5ca6b02c23ee9dc8e0d4ce73dc310b34fa6d1b966434", "pins" : [ + { + "identity" : "swift-argument-parser", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-argument-parser", + "state" : { + "revision" : "626b5b7b2f45e1b0b1c6f4a309296d1d21d7311b", + "version" : "1.7.1" + } + }, { "identity" : "swift-docc-plugin", "kind" : "remoteSourceControl", diff --git a/Package.swift b/Package.swift index 96d3ebf..8fc7ace 100644 --- a/Package.swift +++ b/Package.swift @@ -5,78 +5,93 @@ import CompilerPluginSupport import PackageDescription let package = Package( - name: "p4rse", - platforms: [ .iOS(.v17), .macOS(.v13)], - products: [ - // Products define the executables and libraries a package produces, making them visible to other packages. - .library( - name: "P4Compiler", - targets: ["P4Compiler"] - ), - .library( - name: "Common", - targets: ["Common"] - ), - .library( - name: "P4Lang", - targets: ["P4Lang"] - ), - .library( - name: "P4Runtime", - targets: ["P4Runtime"] - ), - ], - dependencies: [ - .package(path: "./tree-sitter-p4"), - .package(url: "https://github.com/tree-sitter/swift-tree-sitter", revision: "main"), - .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), - .package(url: "https://github.com/swiftlang/swift-syntax", from: "602.0.0"), - ], - targets: [ - .macro( - name: "Macros", - dependencies: [ - .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), - .product(name: "SwiftCompilerPlugin", package: "swift-syntax"), - ], - swiftSettings: [.enableExperimentalFeature("CodeItemMacros")]), - .target( - name: "P4Compiler", - dependencies: [ - .product(name: "SwiftTreeSitter", package: "swift-tree-sitter"), - .product(name: "SwiftTreeSitterLayer", package: "swift-tree-sitter"), - .product(name: "TreeSitterP4", package: "tree-sitter-p4"), - .target(name: "TreeSitterExtensions"), - .target(name: "Common"), - .target(name: "P4Lang"), - .target(name: "P4Runtime"), - ], - swiftSettings: [.enableExperimentalFeature("CodeItemMacros")], - ), - .target( - name: "TreeSitterExtensions", - dependencies: [ - .product(name: "SwiftTreeSitter", package: "swift-tree-sitter"), - .product(name: "SwiftTreeSitterLayer", package: "swift-tree-sitter"), - ], - ), - .target( - name: "Common", - dependencies: ["Macros"], - swiftSettings: [.enableExperimentalFeature("CodeItemMacros")], - ), - .target( - name: "P4Lang", - dependencies: ["Common"] - ), - .target( - name: "P4Runtime", - dependencies: ["P4Lang", "Common"] - ), - .testTarget( - name: "Tests", - dependencies: ["P4Compiler", "P4Runtime", "P4Lang", "Macros", "TreeSitterExtensions", "Common"], - swiftSettings: [.enableExperimentalFeature("CodeItemMacros")], - ), - ], + name: "p4ce", + platforms: [.iOS(.v17), .macOS(.v13)], + products: [ + // Products define the executables and libraries a package produces, making them visible to other packages. + .library( + name: "P4Compiler", + targets: ["P4Compiler"] + ), + .library( + name: "Common", + targets: ["Common"] + ), + .library( + name: "P4Lang", + targets: ["P4Lang"] + ), + .library( + name: "P4Runtime", + targets: ["P4Runtime"] + ), + .executable( + name: "p4ce", + targets: ["Cli"] + ), + ], + dependencies: [ + .package(path: "./tree-sitter-p4"), + .package(url: "https://github.com/tree-sitter/swift-tree-sitter", revision: "main"), + .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), + .package(url: "https://github.com/swiftlang/swift-syntax", from: "602.0.0"), + .package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"), + ], + targets: [ + .macro( + name: "Macros", + dependencies: [ + .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), + .product(name: "SwiftCompilerPlugin", package: "swift-syntax"), + ], + swiftSettings: [.enableExperimentalFeature("CodeItemMacros")]), + .target( + name: "P4Compiler", + dependencies: [ + .product(name: "SwiftTreeSitter", package: "swift-tree-sitter"), + .product(name: "SwiftTreeSitterLayer", package: "swift-tree-sitter"), + .product(name: "TreeSitterP4", package: "tree-sitter-p4"), + .target(name: "TreeSitterExtensions"), + .target(name: "Common"), + .target(name: "P4Lang"), + .target(name: "P4Runtime"), + ], + swiftSettings: [.enableExperimentalFeature("CodeItemMacros")], + ), + .target( + name: "TreeSitterExtensions", + dependencies: [ + .product(name: "SwiftTreeSitter", package: "swift-tree-sitter"), + .product(name: "SwiftTreeSitterLayer", package: "swift-tree-sitter"), + ], + ), + .target( + name: "Common", + dependencies: ["Macros"], + swiftSettings: [.enableExperimentalFeature("CodeItemMacros")], + ), + .target( + name: "P4Lang", + dependencies: ["Common"] + ), + .target( + name: "P4Runtime", + dependencies: ["P4Lang", "Common"] + ), + .executableTarget( + name: "Cli", + dependencies: [ + "Common", "P4Lang", "P4Compiler", "P4Runtime", "Macros", + .product(name: "ArgumentParser", package: "swift-argument-parser"), + ], + swiftSettings: [.enableExperimentalFeature("CodeItemMacros")], + ), + .testTarget( + name: "Tests", + dependencies: [ + "P4Compiler", "P4Runtime", "P4Lang", "Macros", "TreeSitterExtensions", "Common", + ], + swiftSettings: [.enableExperimentalFeature("CodeItemMacros")], + ), + ], ) diff --git a/README.md b/README.md index 0833080..353fc3f 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ where `` is one of: 4. `common`: For any Swift-based components common to the entire project (and macros). 5. `documentation`: For any documentation updates. 6. `testing`: For Swift-based tests. +7. `cli`: For Cli components. where `` can be more free-form and `` is a pithy description of the changes in the commit. diff --git a/Sources/Cli/main.swift b/Sources/Cli/main.swift new file mode 100644 index 0000000..5416dbe --- /dev/null +++ b/Sources/Cli/main.swift @@ -0,0 +1,27 @@ +// p4rse, Copyright 2026, Will Hawkins +// +// This file is part of p4rse. +// +// This file is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +import ArgumentParser +import Darwin +import Common +@main +struct Cli: ParsableCommand { + public func run() throws { + let e = ErrorWithLocation(sourceLocation: SourceLocation(1, 5), withError: "Testing") + print(e.format()) + } +}