Skip to content

Commit

Permalink
setting up dump command
Browse files Browse the repository at this point in the history
  • Loading branch information
leogdion committed Jan 1, 2025
1 parent d80997e commit 90521fc
Show file tree
Hide file tree
Showing 31 changed files with 2,076 additions and 13 deletions.
11 changes: 10 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
{
"type": "lldb",
"request": "launch",
"args": [],
"args": ["init", "--path", "Samples/Appz"],
"cwd": "${workspaceFolder:PackageDSLKit}",
"name": "Debug package",
"program": "${workspaceFolder:PackageDSLKit}/.build/debug/package",
"preLaunchTask": "swift: Build Debug package"
},
{
"type": "lldb",
"request": "launch",
"args": ["init", "--path", "Samples/Appz"],
"cwd": "${workspaceFolder:PackageDSLKit}",
"name": "Debug package",
"program": "${workspaceFolder:PackageDSLKit}/.build/debug/package",
Expand Down
1 change: 0 additions & 1 deletion Mintfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
swiftlang/[email protected]
realm/[email protected]
a7ex/[email protected]
peripheryapp/[email protected]
11 changes: 10 additions & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"originHash" : "ce0e3e8f975af962b7511f1240825b9977a11682462e8d730bcb8c1f3f5f1d1e",
"originHash" : "3decd9c5eb6868fc5ea969ecd2b6cffa4288c57141e5c04692f90d05d8c01390",
"pins" : [
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
"version" : "1.5.0"
}
},
{
"identity" : "swift-docc-plugin",
"kind" : "remoteSourceControl",
Expand Down
13 changes: 9 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,31 @@ import PackageDescription
let package = Package(
name: "PackageDSLKit",
platforms: [
.macOS(.v10_15)
.macOS(.v13)
],
products: [
.library(name: "PackageDSLKit", targets: ["PackageDSLKit"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.4.0"),
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "601.0.0-prerelease-2024-11-18"),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.4.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.
.target(
name: "PackageDSLKit"
name: "PackageDSLKit",
dependencies: [
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftParser", package: "swift-syntax")
]
),
.executableTarget(
name: "package",
dependencies: [
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftParser", package: "swift-syntax"),
"PackageDSLKit",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
]
),
.testTarget(
Expand Down
34 changes: 34 additions & 0 deletions Sources/PackageDSLKit/Component.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// Component.swift
// PackageDSLKit
//
// Created by Leo Dion.
// Copyright © 2025 BrightDigit.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//

struct Component {
let name: String
let inheritedTypes: [String]
let properties: [String: Property]
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
// main.swift
// ComponentBuildable.swift
// PackageDSLKit
//
// Created by Leo Dion.
// Copyright © 2024 BrightDigit.
// Copyright © 2025 BrightDigit.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
Expand All @@ -27,4 +27,6 @@
// OTHER DEALINGS IN THE SOFTWARE.
//

print("Hello, world!")
protocol ComponentBuildable {
init?(component: Component)
}
63 changes: 63 additions & 0 deletions Sources/PackageDSLKit/Dependency.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// Dependency.swift
// PackageDSLKit
//
// Created by Leo Dion.
// Copyright © 2025 BrightDigit.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//

public struct Dependency: TypeSource {
public let typeName: String

public struct DependencyType: OptionSet, Sendable {
public init(rawValue: Int) {
self.rawValue = rawValue
}

public var rawValue: Int

public typealias RawValue = Int

public static let package = DependencyType(rawValue: 1)
public static let target = DependencyType(rawValue: 2)

private static let strings: [String] = ["PackageDependency", "TargetDependency"]
public init?(strings: [String]) {
let indicies = strings.map {
Self.strings.firstIndex(of: $0)
}
let rawValues = indicies.compactMap(\.self).map { $0 + 1 }
if rawValues.isEmpty {
return nil
}
assert(rawValues.count == indicies.count)
let rawValue = rawValues.reduce(0) { $0 + $1 }
self.init(rawValue: rawValue)
}
}

let type: DependencyType
let dependency: String?
let package: DependencyRef?
}
32 changes: 32 additions & 0 deletions Sources/PackageDSLKit/FileManagerType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// FileManagerType.swift
// PackageDSLKit
//
// Created by Leo Dion.
// Copyright © 2025 BrightDigit.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//

public enum FileManagerType: String, CaseIterable {
case fileManager
}
43 changes: 43 additions & 0 deletions Sources/PackageDSLKit/ImportDeclSyntax.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// ImportDeclSyntax.swift
// PackageDSLKit
//
// Created by Leo Dion.
// Copyright © 2025 BrightDigit.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//

import SwiftSyntax

extension ImportDeclSyntax {
static func module(_ moduleName: String) -> ImportDeclSyntax {
ImportDeclSyntax(
path: ImportPathComponentListSyntax([
ImportPathComponentSyntax(
leadingTrivia: .space,
name: .identifier(moduleName)
)
])
)
}
}
81 changes: 81 additions & 0 deletions Sources/PackageDSLKit/Index.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//
// Index.swift
// PackageDSLKit
//
// Created by Leo Dion.
// Copyright © 2025 BrightDigit.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//

public struct Index {
public init(
entries: [EntryRef],
dependencies: [DependencyRef],
testTargets: [TestTargetRef],
swiftSettings: [SwiftSettingRef],
modifiers: [Modifier]
) {
self.entries = entries
self.dependencies = dependencies
self.testTargets = testTargets
self.swiftSettings = swiftSettings
self.modifiers = modifiers
}

public let entries: [EntryRef]
public let dependencies: [DependencyRef]
public let testTargets: [TestTargetRef]
public let swiftSettings: [SwiftSettingRef]
public let modifiers: [Modifier]
}

extension Index {
internal init(
items: [(PackageIndexStrategy.ExpressionKind, String)], modifiers: [ModifierType: [String]]
) {
var entries: [EntryRef] = []
var dependencies: [DependencyRef] = []
var testTargets: [TestTargetRef] = []
var swiftSettings: [SwiftSettingRef] = []
for item in items {
switch item.0 {
case .entries:
entries.append(.init(name: item.1))
case .dependencies:
dependencies.append(.init(name: item.1))
case .testTargets:
testTargets.append(.init(name: item.1))
case .swiftSettings:
swiftSettings.append(.init(name: item.1))
}
}

self.init(
entries: entries,
dependencies: dependencies,
testTargets: testTargets,
swiftSettings: swiftSettings,
modifiers: modifiers.map(Modifier.init)
)
}
}
33 changes: 33 additions & 0 deletions Sources/PackageDSLKit/Modifier.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Modifier.swift
// PackageDSLKit
//
// Created by Leo Dion.
// Copyright © 2025 BrightDigit.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//

public struct Modifier {
let type: ModifierType
let code: [String]
}
Loading

0 comments on commit 90521fc

Please sign in to comment.