diff --git a/README.md b/README.md index 66818a8..43183b6 100755 --- a/README.md +++ b/README.md @@ -299,6 +299,7 @@ _Note that for the `producer` mode, the prebuild build phase and `xccc`, `xcld`, | `product_files_extensions_with_content_override ` | List of all extensions that should carry over source fingerprints. Extensions of all product files that contain non-deterministic content (absolute paths, timestamp, etc) should be included. | `["swiftmodule"]` | ⬜️ | | `thinning_enabled ` | If true, support for thin projects is enabled | `false` | ⬜️ | | `thinning_target_module_name ` | Module name of a target that works as a helper for thinned targets | `"ThinningRemoteCacheModule"` | ⬜️ | +| `prettify_meta_files` | A Boolean value that opts-in pretty JSON formatting for meta files | `false` | ⬜️ | | `aws_secret_key` | Secret key for AWS V4 Signature Authorization. If this is set to a non-empty String - an Authentication Header will be added based on this and the other `aws_*` parameters.| `""` | ⬜️ | | `aws_access_key` | Access key for AWS V4 Signature Authorization. | `""` | ⬜️ | | `aws_region` | Region for AWS V4 Signature Authorization. E.g. `eu`. | `""` | ⬜️ | diff --git a/Sources/XCRemoteCache/Commands/Postbuild/XCPostbuild.swift b/Sources/XCRemoteCache/Commands/Postbuild/XCPostbuild.swift index d927cb5..7ace692 100644 --- a/Sources/XCRemoteCache/Commands/Postbuild/XCPostbuild.swift +++ b/Sources/XCRemoteCache/Commands/Postbuild/XCPostbuild.swift @@ -85,7 +85,7 @@ public class XCPostbuild { algorithm: MD5Algorithm() ) let organizer = ZipArtifactOrganizer(targetTempDir: context.targetTempDir, fileManager: fileManager) - let metaWriter = JsonMetaWriter(fileWriter: fileManager) + let metaWriter = JsonMetaWriter(fileWriter: fileManager, pretty: config.prettifyMetaFiles) let artifactCreator = BuildArtifactCreator( buildDir: context.productsDir, tempDir: context.targetTempDir, diff --git a/Sources/XCRemoteCache/Config/XCRemoteCacheConfig.swift b/Sources/XCRemoteCache/Config/XCRemoteCacheConfig.swift index 3b6b84b..4a7b373 100644 --- a/Sources/XCRemoteCache/Config/XCRemoteCacheConfig.swift +++ b/Sources/XCRemoteCache/Config/XCRemoteCacheConfig.swift @@ -112,6 +112,8 @@ public struct XCRemoteCacheConfig: Encodable { var thinningEnabled: Bool = false /// Module name of a target that works as a helper for thinned targets var thinningTargetModuleName: String = "ThinningRemoteCacheModule" + /// Opt-in pretty json formatting for meta files + var prettifyMetaFiles: Bool = false /// Secret key for AWS V4 Signature, if this is set the Authentication Header will be added var AWSSecretKey: String = "" /// Access key for AWS V4 Signature @@ -165,6 +167,7 @@ extension XCRemoteCacheConfig { scheme.productFilesExtensionsWithContentOverride ?? productFilesExtensionsWithContentOverride merge.thinningEnabled = scheme.thinningEnabled ?? thinningEnabled merge.thinningTargetModuleName = scheme.thinningTargetModuleName ?? thinningTargetModuleName + merge.prettifyMetaFiles = scheme.prettifyMetaFiles ?? prettifyMetaFiles merge.AWSAccessKey = scheme.AWSAccessKey ?? AWSAccessKey merge.AWSSecretKey = scheme.AWSSecretKey ?? AWSSecretKey merge.AWSRegion = scheme.AWSRegion ?? AWSRegion @@ -223,6 +226,7 @@ struct ConfigFileScheme: Decodable { let productFilesExtensionsWithContentOverride: [String]? let thinningEnabled: Bool? let thinningTargetModuleName: String? + let prettifyMetaFiles: Bool? let AWSSecretKey: String? let AWSAccessKey: String? let AWSRegion: String? @@ -264,6 +268,7 @@ struct ConfigFileScheme: Decodable { case productFilesExtensionsWithContentOverride = "product_files_extensions_with_content_override" case thinningEnabled = "thinning_enabled" case thinningTargetModuleName = "thinning_target_module_name" + case prettifyMetaFiles = "prettify_meta_files" case AWSSecretKey = "aws_secret_key" case AWSAccessKey = "aws_access_key" case AWSRegion = "aws_region" diff --git a/Sources/XCRemoteCache/Models/MetaWriter.swift b/Sources/XCRemoteCache/Models/MetaWriter.swift index 97b9bfd..527d7d0 100644 --- a/Sources/XCRemoteCache/Models/MetaWriter.swift +++ b/Sources/XCRemoteCache/Models/MetaWriter.swift @@ -24,11 +24,16 @@ protocol MetaWriter { } class JsonMetaWriter: MetaWriter { - private let metaEncoder = JSONEncoder() + private let metaEncoder: JSONEncoder private let fileWriter: FileWriter - init(fileWriter: FileWriter) { + init(fileWriter: FileWriter, pretty: Bool = false) { self.fileWriter = fileWriter + let encoder = JSONEncoder() + if pretty { + encoder.outputFormatting = .prettyPrinted + } + self.metaEncoder = encoder } func write(_ meta: T, locationDir : URL) throws -> URL where T : Meta { diff --git a/Tests/XCRemoteCacheTests/Commands/XCCCTests.swift b/Tests/XCRemoteCacheTests/Commands/XCCCTests.swift index c62e8e8..97ae987 100644 --- a/Tests/XCRemoteCacheTests/Commands/XCCCTests.swift +++ b/Tests/XCRemoteCacheTests/Commands/XCCCTests.swift @@ -28,7 +28,7 @@ class TemplateBasedCCWrapperBuilderTests: FileXCTestCase { private static let history = "history.compile" private static let prebuild = "prebuild.d" private static let commitSha = "321" - private static let timeout = 5.0 + private static let timeout = 10.0 static let xccc: URL = { let fileManager = FileManager.default diff --git a/cocoapods-plugin/README.md b/cocoapods-plugin/README.md index fe5d4e9..cac845c 100644 --- a/cocoapods-plugin/README.md +++ b/cocoapods-plugin/README.md @@ -52,6 +52,7 @@ An object that is passed to the `xcremotecache` can contain all properties suppo | `modify_lldb_init` | Controls if the pod integration should modify `~/.lldbinit` | `true` | ⬜️ | | `xccc_file` | The path where should be placed the `xccc` binary (in the pod installation phase) | `{podfile_dir}/.rc/xccc` | ⬜️ | | `remote_commit_file` | The path of the file with the remote commit sha (in the pod installation phase) | `{podfile_dir}/.rc/arc.rc`| ⬜️ | +| `prettify_meta_files` | A Boolean value that opts-in pretty JSON formatting for meta files | `false` | ⬜️ | ## Uninstalling diff --git a/cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb b/cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb index 069fa18..0834da5 100644 --- a/cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb +++ b/cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb @@ -58,6 +58,7 @@ module CocoapodsXCRemoteCacheModifier 'xccc_file' => "#{BIN_DIR}/xccc", 'remote_commit_file' => "#{BIN_DIR}/arc.rc", 'exclude_targets' => [], + 'prettify_meta_files' => false } @@configuration.merge! default_values.select { |k, v| !@@configuration.key?(k) } end