common, compiler: Upgrade to SystemPackage
For cross-platform support. Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
+10
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"originHash" : "5d36627594955e7c1e9d5ca6b02c23ee9dc8e0d4ce73dc310b34fa6d1b966434",
|
"originHash" : "ef9c8ff40b986db3a591fe3c50d79e4fe2a9e11749d84a72fbe97babc9ba3683",
|
||||||
"pins" : [
|
"pins" : [
|
||||||
{
|
{
|
||||||
"identity" : "swift-argument-parser",
|
"identity" : "swift-argument-parser",
|
||||||
@@ -37,6 +37,15 @@
|
|||||||
"version" : "602.0.0"
|
"version" : "602.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"identity" : "swift-system",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/apple/swift-system",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "7c6ad0fc39d0763e0b699210e4124afd5041c5df",
|
||||||
|
"version" : "1.6.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"identity" : "swift-tree-sitter",
|
"identity" : "swift-tree-sitter",
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
|
|||||||
+7
-1
@@ -36,6 +36,7 @@ let package = Package(
|
|||||||
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
|
.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/swiftlang/swift-syntax", from: "602.0.0"),
|
||||||
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
|
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
|
||||||
|
.package(url: "https://github.com/apple/swift-system", from: "1.6.1"),
|
||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
.macro(
|
.macro(
|
||||||
@@ -67,7 +68,11 @@ let package = Package(
|
|||||||
),
|
),
|
||||||
.target(
|
.target(
|
||||||
name: "Common",
|
name: "Common",
|
||||||
dependencies: ["Macros"],
|
dependencies: [
|
||||||
|
"Macros",
|
||||||
|
.product(name: "SystemPackage", package: "swift-system"),
|
||||||
|
|
||||||
|
],
|
||||||
swiftSettings: [.enableExperimentalFeature("CodeItemMacros")],
|
swiftSettings: [.enableExperimentalFeature("CodeItemMacros")],
|
||||||
),
|
),
|
||||||
.target(
|
.target(
|
||||||
@@ -90,6 +95,7 @@ let package = Package(
|
|||||||
name: "Tests",
|
name: "Tests",
|
||||||
dependencies: [
|
dependencies: [
|
||||||
"P4Compiler", "P4Runtime", "P4Lang", "Macros", "TreeSitterExtensions", "Common",
|
"P4Compiler", "P4Runtime", "P4Lang", "Macros", "TreeSitterExtensions", "Common",
|
||||||
|
.product(name: "SystemPackage", package: "swift-system"),
|
||||||
],
|
],
|
||||||
swiftSettings: [.enableExperimentalFeature("CodeItemMacros")],
|
swiftSettings: [.enableExperimentalFeature("CodeItemMacros")],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import System
|
import SystemPackage
|
||||||
|
|
||||||
/// Represent a location in a post-preprocessed piece of P4 source code.
|
/// Represent a location in a post-preprocessed piece of P4 source code.
|
||||||
public struct SourceLocation: Equatable, CustomStringConvertible {
|
public struct SourceLocation: Equatable, CustomStringConvertible {
|
||||||
@@ -145,9 +145,7 @@ func do_preprocess(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to make a url from the configured file.
|
// Try to make a url from the configured file.
|
||||||
guard let included_url = URL.init(filePath: included_path) else {
|
let included_url = URL.init(filePath: included_path.string)
|
||||||
return .Error(Error(withMessage: "Could not convert \(included_path) into a URL"))
|
|
||||||
}
|
|
||||||
|
|
||||||
// By calling ourselves recursively, the include being processed will
|
// By calling ourselves recursively, the include being processed will
|
||||||
// be _completely_ expanded (including any nested includes).
|
// be _completely_ expanded (including any nested includes).
|
||||||
@@ -203,9 +201,7 @@ public struct SourceCodePreprocessor {
|
|||||||
return .Error(Error(withMessage: "Could not open \(file) for preprocessing"))
|
return .Error(Error(withMessage: "Could not open \(file) for preprocessing"))
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let url = URL.init(filePath: file_to_open) else {
|
let url = URL.init(filePath: file_to_open.string)
|
||||||
return .Error(Error(withMessage: "Could not convert \(file_to_open) into a URL"))
|
|
||||||
}
|
|
||||||
|
|
||||||
switch do_preprocess(url, self.manager) {
|
switch do_preprocess(url, self.manager) {
|
||||||
case .Ok((let location, let contents)):
|
case .Ok((let location, let contents)):
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import P4Compiler
|
|||||||
import P4Lang
|
import P4Lang
|
||||||
import P4Runtime
|
import P4Runtime
|
||||||
import SwiftTreeSitter
|
import SwiftTreeSitter
|
||||||
import System
|
import SystemPackage
|
||||||
import Testing
|
import Testing
|
||||||
import TreeSitter
|
import TreeSitter
|
||||||
import TreeSitterP4
|
import TreeSitterP4
|
||||||
|
|||||||
Reference in New Issue
Block a user