-
Notifications
You must be signed in to change notification settings - Fork 52
[SwiftDriver] Part III - Introduce synchronization between swift-frontend invocations #210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
22484b4
Add syncing implementation
polac24 148c99d
Add docs
polac24 3853ce2
Write to the shared frontend lock early
polac24 8dffbd4
Add missing unit tests
polac24 56d9c20
Fix typos
polac24 f4eed9e
Apply review suggestions
polac24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,7 @@ _XCRemoteCache is a remote cache tool for Xcode projects. It reuses target artif | |
| - [Limitations](#limitations) | ||
| - [FAQ](#faq) | ||
| - [Development](#development) | ||
| - [Architectural Designs](#architectural-designs) | ||
| - [Release](#release) | ||
| * [Releasing CocoaPods plugin](#releasing-cocoapods-plugin) | ||
| * [Building release package](#building-release-package) | ||
|
|
@@ -291,7 +292,7 @@ where | |
|
|
||
| ```shell | ||
| ditto "${SCRIPT_INPUT_FILE_0}" "${SCRIPT_OUTPUT_FILE_0}" | ||
| [ -f "${SCRIPT_INPUT_FILE_1}" ] && ditto "${SCRIPT_INPUT_FILE_1}" "${SCRIPT_OUTPUT_FILE_1}" || rm "${SCRIPT_OUTPUT_FILE_1}" | ||
| [ -f "${SCRIPT_INPUT_FILE_1}" ] && ditto "${SCRIPT_INPUT_FILE_1}" "${SCRIPT_OUTPUT_FILE_1}" || rm -f "${SCRIPT_OUTPUT_FILE_1}" | ||
| ``` | ||
|
|
||
| where | ||
|
|
@@ -469,6 +470,10 @@ Follow the [FAQ](docs/FAQ.md) page. | |
|
|
||
| Follow the [Development](docs/Development.md) guide. It has all the information on how to get started. | ||
|
|
||
| ## Architectural designs | ||
|
|
||
| Follow the [Architectural designs](docs/design/ArchitecturalDesigns.md) document that describes and documents XCRemoteCache designs and implementation details. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Minor - the graphs are hard to read for dark mode.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for spotting that! Fixed it. |
||
|
|
||
| ## Release | ||
|
|
||
| To release a version, in [Releases](https://github.com/spotify/XCRemoteCache/releases) draft a new release with `v0.3.0{-rc0}` tag format. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Sources/XCRemoteCache/Commands/SwiftFrontend/SwiftFrontendContext.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // Copyright (c) 2023 Spotify AB. | ||
| // | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| import Foundation | ||
|
|
||
| struct SwiftFrontendContext { | ||
| /// File lock used for synchronizing multiple invocations | ||
| let invocationLockFile: URL | ||
| } | ||
|
|
||
| extension SwiftFrontendContext { | ||
| init(_ swiftcContext: SwiftcContext, env: [String: String]) throws { | ||
| /// The LLBUILD_BUILD_ID ENV that describes the entire (incl. parent's swiftc) bui;d | ||
| let llbuildId: String = try env.readEnv(key: "LLBUILD_BUILD_ID") | ||
| invocationLockFile = Self.self.buildLlbuildIdSharedLockUrl( | ||
| llbuildId: llbuildId, | ||
| tmpDir: swiftcContext.tempDir | ||
| ) | ||
| } | ||
|
|
||
| /// Generate the filename to be used to synchronize multiple swift-frontend invocations | ||
| /// The same file is used in prebuild, xcswift-frontend and postbuild (to clean it up) | ||
| static func buildLlbuildIdSharedLockUrl(llbuildId: String, tmpDir: URL) -> URL { | ||
| return tmpDir.appendingPathComponent(llbuildId).appendingPathExtension("lock") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sidefix: found that if a first build has a cache miss, this snippet fails with an error that
$SCRIPT_OUTPUT_FILE_1doesn't exist. In such cases, we can safely no-op (so forcingrm)