diff --git a/Package.resolved b/Package.resolved index 5b52b851..cb542683 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "3723bf697fd3c9deb411523eef2023627c93557d8d2729d3e438c927a4be3b5c", + "originHash" : "88fcdf8451554503ef74eb5a6e07f1c3b4af720431bfc6f6ba1d606475e66ced", "pins" : [ { "identity" : "aexml", @@ -33,8 +33,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/tuist/FileSystem.git", "state" : { - "revision" : "d2f49d5a9f8ada3b6e1a2bc4254d715b214d5753", - "version" : "0.11.8" + "revision" : "1e8890203abfc0dcd887b49ec5e91ea75b394495", + "version" : "0.11.23" } }, { @@ -42,8 +42,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/p-x9/MachOKit", "state" : { - "revision" : "5a09d8ad1be010bcd58d8a39554480b19e0a45e1", - "version" : "0.37.0" + "revision" : "fc1f2646220b3ce9db2e415b6b8848f5a89ed865", + "version" : "0.39.0" } }, { diff --git a/Sources/XcodeGraph/Models/BuildableFolder.swift b/Sources/XcodeGraph/Models/BuildableFolder.swift index 7c83979c..1a1ca412 100644 --- a/Sources/XcodeGraph/Models/BuildableFolder.swift +++ b/Sources/XcodeGraph/Models/BuildableFolder.swift @@ -1,16 +1,47 @@ import Path -/// A buildable folder maps to an PBXFileSystemSynchronizedRootGroup in Xcode projects. +/// Represents a file inside a buildable folder, along with any compiler flags to apply to it. +public struct BuildableFolderFile: Sendable, Codable, Equatable, Hashable { + /// The absolute path to the file within the buildable folder. + public let path: AbsolutePath + + /// Compiler flags to apply when building this file. An empty string means no extra flags. + public let compilerFlags: String? + + /// Initializes a buildable folder file. + /// - Parameters: + /// - path: The absolute path to the file within the buildable folder. + /// - compilerFlags: Compiler flags to apply when building this file. An empty string means no extra flags. + public init(path: AbsolutePath, compilerFlags: String?) { + self.path = path + self.compilerFlags = compilerFlags + } +} + +/// A buildable folder maps to a PBXFileSystemSynchronizedRootGroup in Xcode projects. /// Synchronized groups were introduced in Xcode 16 to reduce git conflicts by having a reference /// to a folder whose content is "synchronized" by Xcode itself. Think of it as Xcode resolving /// the globs. +/// +/// This struct describes a buildable folder, the exception rules for files within it, and the resolved file list. public struct BuildableFolder: Sendable, Codable, Equatable, Hashable { /// The absolute path to the buildable folder. public var path: AbsolutePath - /// Creates an instance of buildable folder. - /// - Parameter path: Absolute path to the buildable folder. - public init(path: AbsolutePath) { + /// Exceptions associated with this buildable folder, describing files to exclude or per-file build configuration overrides. + public var exceptions: BuildableFolderExceptions + + /// The files resolved from this buildable folder, each with any per-file compiler flags. + public var resolvedFiles: [BuildableFolderFile] + + /// Creates a new `BuildableFolder` instance. + /// - Parameters: + /// - path: The absolute path to the buildable folder. + /// - exceptions: The set of exceptions (such as excluded files or custom compiler flags) for the folder. + /// - resolvedFiles: The list of files resolved from the folder, each file optionally having compiler flags. + public init(path: AbsolutePath, exceptions: BuildableFolderExceptions, resolvedFiles: [BuildableFolderFile]) { self.path = path + self.exceptions = exceptions + self.resolvedFiles = resolvedFiles } } diff --git a/Sources/XcodeGraph/Models/BuildableFolderException.swift b/Sources/XcodeGraph/Models/BuildableFolderException.swift new file mode 100644 index 00000000..4fb3b89b --- /dev/null +++ b/Sources/XcodeGraph/Models/BuildableFolderException.swift @@ -0,0 +1,19 @@ +import Path + +/// Represents exceptions for a buildable folder, such as files to exclude or specific compiler flags to apply. +public struct BuildableFolderException: Sendable, Codable, Equatable, Hashable { + /// A list of absolute paths to files excluded from the buildable folder. + public var excluded: [AbsolutePath] + + /// A dictionary mapping files (referenced by their absolute path) to the compiler flags to apply. + public var compilerFlags: [AbsolutePath: String] + + /// Creates a new exception for a buildable folder. + /// - Parameters: + /// - excluded: An array of absolute paths to files that should be excluded from the buildable folder. + /// - compilerFlags: A dictionary mapping absolute file paths to specific compiler flags to apply to those files. + public init(excluded: [AbsolutePath], compilerFlags: [AbsolutePath: String]) { + self.excluded = excluded + self.compilerFlags = compilerFlags + } +} diff --git a/Sources/XcodeGraph/Models/BuildableFolderExceptions.swift b/Sources/XcodeGraph/Models/BuildableFolderExceptions.swift new file mode 100644 index 00000000..076c85a1 --- /dev/null +++ b/Sources/XcodeGraph/Models/BuildableFolderExceptions.swift @@ -0,0 +1,24 @@ +import Path + +/// PBXFileSystemSynchronizedRootGroup have a one-to-many relationship with PBXFileSystemSynchronizedBuildFileExceptionSet +/// through .exceptions. Exceptions are used to exclude files and override conffigurations. +public struct BuildableFolderExceptions: Sendable, Codable, Equatable, Hashable, ExpressibleByArrayLiteral, Sequence { + /// A list with all the exceptions. + public var exceptions: [BuildableFolderException] + + /// Create a group of exceptions to exclude files from your group or change the configuration of some of them. + /// - Parameter exceptions: The list of exceptions. + /// - Returns: An instance containing all the exceptions. + public init(arrayLiteral elements: BuildableFolderException...) { + exceptions = elements + } + + public init(exceptions: [BuildableFolderException]) { + self.exceptions = exceptions + } + + /// Returns an iterator over the contained exceptions. + public func makeIterator() -> [BuildableFolderException].Iterator { + exceptions.makeIterator() + } +}