Skip to content

Commit

Permalink
Don't start executor if expected Xcode versions are not present (#7375)
Browse files Browse the repository at this point in the history
  • Loading branch information
iain-macdonald authored Sep 9, 2024
1 parent dac0aa7 commit 73174e9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions server/xcode/xcode_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package xcode
import "C"

import (
"flag"
"fmt"
"io/fs"
"os"
Expand All @@ -30,6 +31,8 @@ const developerDirectoryPath = "Contents/Developer"
const filePrefix = "file://"
const defaultXcodeVersion = "default-xcode-version"

var requiredXcodeVersions = flag.String("executor.required_xcode_versions", "", "Comma-delimited list of Xcode versions required on the host system. If any of the provided Xcode versions cannot be found on the host, the executor will fail to start.")

type xcodeLocator struct {
versions map[string]*xcodeVersion
}
Expand All @@ -49,9 +52,25 @@ type xcodePlist struct {
func NewXcodeLocator() *xcodeLocator {
xl := &xcodeLocator{}
xl.locate()
xl.verify()
return xl
}

// Asserts that all of the Xcode versions specified in
// --executor.required_xcode_versions were found, killing the executor if not.
func (x *xcodeLocator) verify() {
if *requiredXcodeVersions == "" {
return
}

requiredXcodes := strings.Split(*requiredXcodeVersions, ",")
for _, requiredXcode := range requiredXcodes {
if _, ok := x.versions[requiredXcode]; !ok {
log.Fatalf("Failed to locate required Xcode version %s", requiredXcode)
}
}
}

// Finds the Xcode that matches the given Xcode version.
// Returns the developer directory for that Xcode and the SDK root for the given SDK.
func (x *xcodeLocator) PathsForVersionAndSDK(xcodeVersion string, sdk string) (string, string, error) {
Expand Down

0 comments on commit 73174e9

Please sign in to comment.