Skip to content

Commit

Permalink
Support VFSOverlay
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Marcal committed Oct 18, 2022
1 parent e9d3b2f commit 8ec5915
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/com/facebook/buck/swift/SwiftCompile.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ private SwiftCompileStep makeCompileStep(SourcePathResolverAdapter resolver) {
projectFilesystem,
argfilePath,
withDownwardApi,
transformErrorsToAbsolutePaths);
transformErrorsToAbsolutePaths,
vfsOverlay,
vfsoverlayFilePath);
}

/**
Expand Down
12 changes: 11 additions & 1 deletion src/com/facebook/buck/swift/SwiftCompileStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class SwiftCompileStep extends SwiftCompileStepBase {
private final ImmutableMap<String, String> compilerEnvironment;
private final Optional<AbsPath> argfilePath;
private final boolean transformErrorsToAbsolutePaths;
private final Optional<AbsPath> vfsOverlayFile;
private final Optional<VFSOverlay> vfsOverlay;
SwiftCompileStep(
AbsPath compilerCwd,
Map<String, String> compilerEnvironment,
Expand All @@ -63,12 +65,16 @@ class SwiftCompileStep extends SwiftCompileStepBase {
ProjectFilesystem filesystem,
Optional<AbsPath> argfilePath,
boolean withDownwardApi,
boolean transformErrorsToAbsolutePaths) {
boolean transformErrorsToAbsolutePaths,
Optional<VFSOverlay> vfsOverlay,
Optional<AbsPath> 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
Expand All @@ -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<String> colorArguments = getColorArguments(context.getAnsi().isAnsiTerminal());

if (argfilePath.isPresent()) {
Expand Down
9 changes: 8 additions & 1 deletion src/com/facebook/buck/swift/SwiftInterfaceCompile.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -149,7 +154,9 @@ public ImmutableList<Step> getBuildSteps(
filesystem,
Optional.empty(),
withDownwardApi,
false));
false,
Optional.empty(),
Optional.empty()));
}
}
}
4 changes: 3 additions & 1 deletion src/com/facebook/buck/swift/SwiftModuleMapCompile.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ public ImmutableList<Step> getBuildSteps(
filesystem,
Optional.empty(),
withDownwardApi,
false));
false,
Optional.empty(),
Optional.empty()));
}

private boolean isFrameworkPath(Path modulemapPath) {
Expand Down

0 comments on commit 8ec5915

Please sign in to comment.