Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
NinjaLikesCheez committed Jul 27, 2023
1 parent 0088afc commit abac5df
Show file tree
Hide file tree
Showing 25 changed files with 600 additions and 66 deletions.
7 changes: 5 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ excluded:
- .vscode/
- PBXProjParser/.build/ # https://github.com/realm/SwiftLint/issues/2329 doesn't support recursive globs yet
- GenIRLogging/.build/
- GenIRExtensions/.build/

line_length:
warning: 150
ignores_comments: true
ignores_function_declarations: True
ignores_comments: True
warning: 200
error: 250
9 changes: 9 additions & 0 deletions GenIRExtensions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
29 changes: 29 additions & 0 deletions GenIRExtensions/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "GenIRExtensions",
platforms: [.macOS(.v12)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "GenIRExtensions",
targets: ["GenIRExtensions"])
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "GenIRExtensions",
dependencies: []),
.testTarget(
name: "GenIRExtensionsTests",
dependencies: ["GenIRExtensions"])
]
)
3 changes: 3 additions & 0 deletions GenIRExtensions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# GenIRExtensions

A description of this package.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct PlistCodingKeys: CodingKey {
}
}

extension KeyedDecodingContainer {
public extension KeyedDecodingContainer {
func decode(_ type: [String: Any].Type, forKey key: K) throws -> [String: Any] {
let container = try self.nestedContainer(keyedBy: PlistCodingKeys.self, forKey: key)
return try container.decode(type)
Expand Down Expand Up @@ -69,7 +69,7 @@ extension KeyedDecodingContainer {
}
}

extension UnkeyedDecodingContainer {
public extension UnkeyedDecodingContainer {
mutating func decode(_ type: [Any].Type) throws -> [Any] {
var array: [Any] = []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

extension FileManager {
public extension FileManager {
/// Returns a Boolean value that indicates whether a directory exists at the specified url
/// - Parameter url: The url of the directory. This is tilde expanded
/// - Returns: true if a directory exists at the specified path exists, or false if it doesn't exist or it does exist, but is not a directory
Expand Down Expand Up @@ -60,7 +60,7 @@ extension FileManager {
/// - path: The path of the directory to search in
/// - suffix: The suffix to match against file names
/// - recursive: A Boolean value to indicate whether a recursive search should be performed
/// - Returns: An array of URL file paths matching the suffix found in the specifed path
/// - Returns: An array of URL file paths matching the suffix found in the specified path
func files(at path: URL, withSuffix suffix: String, recursive: Bool = true) throws -> [URL] {
try filteredContents(of: path, recursive: recursive) { url in
let attributes = try url.resourceValues(forKeys: [.isRegularFileKey])
Expand Down Expand Up @@ -111,7 +111,7 @@ extension FileManager {
let sourceFiles = try contentsOfDirectory(at: source, includingPropertiesForKeys: nil)

for sourceFile in sourceFiles {
let path = destination.appendingPathComponent(sourceFile.lastPathComponent)
let path = destination.appendingPath(component: sourceFile.lastPathComponent)

if replacing && fileExists(atPath: path.filePath) {
try removeItem(at: path)
Expand All @@ -129,16 +129,16 @@ extension FileManager {
/// - filename: the name of the file
/// - Returns: a URL to a unique file in the given directory
func uniqueFilename(directory: URL, filename: String) -> URL {
var path = directory.appendingPathComponent(filename)
var path = directory.appendingPath(component: filename)
var index = 2

while fileExists(atPath: path.filePath) {
let splitName = filename.split(separator: ".")

if splitName.count == 2 {
path = directory.appendingPathComponent("\(splitName[0]) \(index).\(splitName[1])")
path = directory.appendingPath(component: "\(splitName[0]) \(index).\(splitName[1])")
} else {
path = directory.appendingPathComponent("\(filename) \(index)")
path = directory.appendingPath(component: "\(filename) \(index)")
}

index += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

import Foundation

extension Process {
public extension Process {
/// Presents the result of a Process
struct ReturnValue {
/// The stdout output of the process, if there was any
let stdout: String?
public let stdout: String?
/// The stderr output of the process, if there was any
let stderr: String?
public let stderr: String?
/// The return code of the process
let code: Int32
public let code: Int32

init(stdout: String?, stderr: String?, code: Int32) {
if let stdout, stdout.isEmpty {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

extension String {
public extension String {
/// Replacing double escapes with singles
/// - Returns: the unescaped string
func unescaped() -> String {
Expand Down Expand Up @@ -105,7 +105,7 @@ extension Substring {
}
}

extension [String] {
public extension [String] {
/// Finds the next index of a given item after a given index
/// - Parameters:
/// - item: the element to search for
Expand Down
23 changes: 23 additions & 0 deletions GenIRExtensions/Sources/GenIRExtensions/URL+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// URL+Extension.swift
//
//
// Created by Thomas Hedderwick on 02/08/2022.
//

import Foundation

public extension URL {
/// Returns the path component of a URL
var filePath: String {
return self.path
}

func appendingPath(component: String, isDirectory: Bool = false) -> URL {
if #available(macOS 13.0, *) {
return self.appending(component: component, directoryHint: isDirectory ? .isDirectory : .inferFromPath)
} else {
return self.appendingPathComponent(component, isDirectory: isDirectory)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import XCTest
@testable import GenIRExtensions
8 changes: 4 additions & 4 deletions GenIRLogging/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ let package = Package(
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "GenIRLogging",
targets: ["GenIRLogging"]),
targets: ["GenIRLogging"])
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "GenIRLogging",
dependencies: [
.product(name: "Logging", package: "swift-log"),
.product(name: "Logging", package: "swift-log")
]),
.testTarget(
name: "GenIRLoggingTests",
dependencies: ["GenIRLogging"]),
dependencies: ["GenIRLogging"])
]
)
9 changes: 0 additions & 9 deletions GenIRLogging/Tests/GenIRLoggingTests/GenIRLoggingTests.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
import XCTest
@testable import GenIRLogging

//final class GenIRLoggingTests: XCTestCase {
// func testExample() throws {
// // This is an example of a functional test case.
// // Use XCTAssert and related functions to verify your tests produce the correct
// // results.
// XCTAssertEqual(GenIRLogging().text, "Hello, World!")
// }
//}
81 changes: 81 additions & 0 deletions PBXProjParser/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
{
"pins" : [
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "e394bf350e38cb100b6bc4172834770ede1b7232",
"version" : "1.0.3"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2",
"version" : "1.0.4"
}
},
{
"identity" : "swift-crypto",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto.git",
"state" : {
"revision" : "ddb07e896a2a8af79512543b1c7eb9797f8898a5",
"version" : "1.1.7"
}
},
{
"identity" : "swift-driver",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-driver.git",
"state" : {
"branch" : "release/5.7",
"revision" : "82b274af66cfbb8f3131677676517b34d01e30fd"
}
},
{
"identity" : "swift-llbuild",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-llbuild.git",
"state" : {
"branch" : "release/5.7",
"revision" : "564424db5fdb62dcb5d863bdf7212500ef03a87b"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
Expand All @@ -8,6 +53,42 @@
"revision" : "32e8d724467f8fe623624570367e3d50c5638e46",
"version" : "1.5.2"
}
},
{
"identity" : "swift-package-manager",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-package-manager.git",
"state" : {
"branch" : "release/5.7",
"revision" : "c6e40adbfc78acc60ca464ae482b56442f9f34f4"
}
},
{
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "836bc4557b74fe6d2660218d56e3ce96aff76574",
"version" : "1.1.1"
}
},
{
"identity" : "swift-tools-support-core",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-tools-support-core.git",
"state" : {
"branch" : "release/5.7",
"revision" : "286b48b1d73388e1d49b2bb33aabf995838104e3"
}
},
{
"identity" : "yams",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams.git",
"state" : {
"revision" : "9ff1cc9327586db4e0c8f46f064b6a82ec1566fa",
"version" : "4.0.6"
}
}
],
"version" : 2
Expand Down
8 changes: 6 additions & 2 deletions PBXProjParser/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ let package = Package(
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(path: "../GenIRLogging")
.package(url: "https://github.com/apple/swift-package-manager.git", branch: "release/5.7"),
.package(path: "../GenIRLogging"),
.package(path: "../GenIRExtensions")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand All @@ -25,7 +27,9 @@ let package = Package(
name: "PBXProjParser",
dependencies: [
.product(name: "Logging", package: "swift-log"),
.product(name: "GenIRLogging", package: "GenIRLogging")
.product(name: "SwiftPMDataModel-auto", package: "swift-package-manager"),
.product(name: "GenIRLogging", package: "GenIRLogging"),
.product(name: "GenIRExtensions", package: "GenIRExtensions")
]),
.testTarget(
name: "PBXProjParserTests",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ public class PBXFileReference: PBXObject {
public let fileEncoding: String?
public let explicitFileType: String?
public let includeInIndex: String?
public let lastKnownFileType: String?
public let name: String?
public let sourceTree: String
#endif
public let name: String?
public let lastKnownFileType: String?
public let path: String

private enum CodingKeys: String, CodingKey {
#if FULL_PBX_PARSING
case fileEncoding
case explicitFileType
case includeInIndex
case lastKnownFileType
case name
case sourceTree
#endif
case lastKnownFileType
case name
case path
}

Expand All @@ -36,10 +36,10 @@ public class PBXFileReference: PBXObject {
fileEncoding = try container.decodeIfPresent(String.self, forKey: .fileEncoding)
explicitFileType = try container.decodeIfPresent(String.self, forKey: .explicitFileType)
includeInIndex = try container.decodeIfPresent(String.self, forKey: .includeInIndex)
lastKnownFileType = try container.decodeIfPresent(String.self, forKey: .lastKnownFileType)
name = try container.decodeIfPresent(String.self, forKey: .name)
sourceTree = try container.decode(String.self, forKey: .sourceTree)
#endif
lastKnownFileType = try container.decodeIfPresent(String.self, forKey: .lastKnownFileType)
name = try container.decodeIfPresent(String.self, forKey: .name)
path = try container.decode(String.self, forKey: .path)

try super.init(from: decoder)
Expand Down
Loading

0 comments on commit abac5df

Please sign in to comment.