From 8ec59158439bcc1fcfc5317b0190b379225eb467 Mon Sep 17 00:00:00 2001 From: Lucas Marcal Date: Tue, 18 Oct 2022 14:29:15 -0300 Subject: [PATCH] Support VFSOverlay --- src/com/facebook/buck/swift/SwiftCompile.java | 4 +++- src/com/facebook/buck/swift/SwiftCompileStep.java | 12 +++++++++++- .../facebook/buck/swift/SwiftInterfaceCompile.java | 9 ++++++++- .../facebook/buck/swift/SwiftModuleMapCompile.java | 4 +++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/com/facebook/buck/swift/SwiftCompile.java b/src/com/facebook/buck/swift/SwiftCompile.java index 060deb99dd0..e1ec8d21b52 100644 --- a/src/com/facebook/buck/swift/SwiftCompile.java +++ b/src/com/facebook/buck/swift/SwiftCompile.java @@ -206,7 +206,9 @@ private SwiftCompileStep makeCompileStep(SourcePathResolverAdapter resolver) { projectFilesystem, argfilePath, withDownwardApi, - transformErrorsToAbsolutePaths); + transformErrorsToAbsolutePaths, + vfsOverlay, + vfsoverlayFilePath); } /** diff --git a/src/com/facebook/buck/swift/SwiftCompileStep.java b/src/com/facebook/buck/swift/SwiftCompileStep.java index 42d73a6b2ea..cbef8f600b2 100644 --- a/src/com/facebook/buck/swift/SwiftCompileStep.java +++ b/src/com/facebook/buck/swift/SwiftCompileStep.java @@ -55,6 +55,8 @@ class SwiftCompileStep extends SwiftCompileStepBase { private final ImmutableMap compilerEnvironment; private final Optional argfilePath; private final boolean transformErrorsToAbsolutePaths; + private final Optional vfsOverlayFile; + private final Optional vfsOverlay; SwiftCompileStep( AbsPath compilerCwd, Map compilerEnvironment, @@ -63,12 +65,16 @@ class SwiftCompileStep extends SwiftCompileStepBase { ProjectFilesystem filesystem, Optional argfilePath, boolean withDownwardApi, - boolean transformErrorsToAbsolutePaths) { + boolean transformErrorsToAbsolutePaths, + Optional vfsOverlay, + Optional vfsOverlayFile) { super( compilerCwd, compilerCommandPrefix, compilerCommandArguments, filesystem, withDownwardApi); this.compilerEnvironment = ImmutableMap.copyOf(compilerEnvironment); this.argfilePath = argfilePath; this.transformErrorsToAbsolutePaths = transformErrorsToAbsolutePaths; + this.vfsOverlay = vfsOverlay; + this.vfsOverlayFile = vfsOverlayFile; } @Override @@ -82,6 +88,10 @@ private ProcessExecutorParams makeProcessExecutorParams(StepExecutionContext con builder.setDirectory(compilerCwd.getPath()); builder.setEnvironment(compilerEnvironment); + if (vfsOverlay.isPresent() && vfsOverlayFile.isPresent()) { + MostFiles.writeLinesToFile(ImmutableList.of(vfsOverlay.get().render()), vfsOverlayFile.get()); + } + Iterable colorArguments = getColorArguments(context.getAnsi().isAnsiTerminal()); if (argfilePath.isPresent()) { diff --git a/src/com/facebook/buck/swift/SwiftInterfaceCompile.java b/src/com/facebook/buck/swift/SwiftInterfaceCompile.java index b71ab05f1b6..8496b406bdc 100644 --- a/src/com/facebook/buck/swift/SwiftInterfaceCompile.java +++ b/src/com/facebook/buck/swift/SwiftInterfaceCompile.java @@ -16,8 +16,12 @@ package com.facebook.buck.swift; +import com.facebook.buck.apple.clang.VFSOverlay; import com.facebook.buck.core.build.context.BuildContext; +import com.facebook.buck.core.filesystems.AbsPath; import com.facebook.buck.core.model.BuildTarget; +import com.facebook.buck.core.model.impl.BuildPaths; +import com.facebook.buck.core.model.impl.BuildTargetPaths; import com.facebook.buck.core.rulekey.AddToRuleKey; import com.facebook.buck.core.rules.SourcePathRuleFinder; import com.facebook.buck.core.sourcepath.SourcePath; @@ -36,6 +40,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedMap; import java.nio.file.Path; import java.util.Optional; import javax.annotation.Nullable; @@ -149,7 +154,9 @@ public ImmutableList getBuildSteps( filesystem, Optional.empty(), withDownwardApi, - false)); + false, + Optional.empty(), + Optional.empty())); } } } diff --git a/src/com/facebook/buck/swift/SwiftModuleMapCompile.java b/src/com/facebook/buck/swift/SwiftModuleMapCompile.java index 874081bef56..bb2677f4f00 100644 --- a/src/com/facebook/buck/swift/SwiftModuleMapCompile.java +++ b/src/com/facebook/buck/swift/SwiftModuleMapCompile.java @@ -241,7 +241,9 @@ public ImmutableList getBuildSteps( filesystem, Optional.empty(), withDownwardApi, - false)); + false, + Optional.empty(), + Optional.empty())); } private boolean isFrameworkPath(Path modulemapPath) {