Skip to content

[BLOCKED] Set the working directory of build tool plugin commands deterministically #8645

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions Sources/PackagePlugin/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,11 @@ extension Plugin {
// package is the one we'll set the context's `package` property to.
let context: PluginContext
let target: Target
let pluginWorkDirectory: URL
do {
var deserializer = PluginContextDeserializer(wireInput)
let package = try deserializer.package(for: rootPackageId)
let pluginWorkDirectory = try deserializer.url(for: wireInput.pluginWorkDirId)
pluginWorkDirectory = try deserializer.url(for: wireInput.pluginWorkDirId)
let toolSearchDirectories = try wireInput.toolSearchDirIds.map {
try deserializer.url(for: $0)
}
Expand Down Expand Up @@ -208,7 +209,8 @@ extension Plugin {
displayName: displayName,
executable: executable,
arguments: arguments,
environment: environment
environment: environment,
workingDirectory: pluginWorkDirectory
)
let message = PluginToHostMessage.defineBuildCommand(
configuration: command,
Expand All @@ -222,7 +224,8 @@ extension Plugin {
displayName: displayName,
executable: executable,
arguments: arguments,
environment: environment
environment: environment,
workingDirectory: pluginWorkDirectory
)
let message = PluginToHostMessage.definePrebuildCommand(
configuration: command,
Expand All @@ -248,6 +251,7 @@ extension Plugin {

// Deserialize the context from the wire input structures, and create a record for us to pass to the XcodeProjectPlugin library.
let record: XcodeProjectPluginInvocationRecord
let pluginWorkDirectory: URL
do {
var deserializer = PluginContextDeserializer(wireInput)
let xcodeProject = try deserializer.xcodeProject(for: rootProjectId)
Expand All @@ -256,7 +260,7 @@ extension Plugin {
pluginGeneratedSources: try generatedSources.map { try deserializer.url(for: $0) },
pluginGeneratedResources: try generatedResources.map { try deserializer.url(for: $0) }
)
let pluginWorkDirectory = try deserializer.url(for: wireInput.pluginWorkDirId)
pluginWorkDirectory = try deserializer.url(for: wireInput.pluginWorkDirId)
let toolSearchDirectories = try wireInput.toolSearchDirIds.map {
try deserializer.url(for: $0)
}
Expand Down Expand Up @@ -288,7 +292,7 @@ extension Plugin {
executable: exec,
arguments: args,
environment: env,
workingDirectory: nil)
workingDirectory: pluginWorkDirectory)
let message = PluginToHostMessage.defineBuildCommand(
configuration: command,
inputFiles: inputs,
Expand All @@ -301,7 +305,7 @@ extension Plugin {
executable: exec,
arguments: args,
environment: env,
workingDirectory: nil)
workingDirectory: pluginWorkDirectory)
let message = PluginToHostMessage.definePrebuildCommand(
configuration: command,
outputFilesDirectory: outdir)
Expand Down