Skip to content

Commit

Permalink
@AutoCodec for CreateIncSymlinkAction, ExtractInclusionAction, and
Browse files Browse the repository at this point in the history
SolibSymlinkAction.

PiperOrigin-RevId: 186765454
  • Loading branch information
calpeyser authored and Copybara-Service committed Feb 23, 2018
1 parent 4736217 commit bb489a7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.google.devtools.build.lib.actions.ActionResult;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.util.Fingerprint;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
Expand All @@ -35,9 +36,8 @@
import java.util.Map;
import java.util.SortedMap;

/**
* This action creates a set of symbolic links.
*/
/** This action creates a set of symbolic links. */
@AutoCodec
@Immutable
public final class CreateIncSymlinkAction extends AbstractAction {
private final ImmutableSortedMap<Artifact, Artifact> symlinks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,30 @@
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.ExecException;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import java.io.IOException;

/**
* An action which greps for includes over a given .cc or .h file.
* This is a part of the work required for C++ include scanning.
* An action which greps for includes over a given .cc or .h file. This is a part of the work
* required for C++ include scanning.
*
* <p>For generated files, it is advantageous to do this remotely, to avoid having to download
* the generated file.
* <p>For generated files, it is advantageous to do this remotely, to avoid having to download the
* generated file.
*
* <p>Note that this may run grep-includes over-optimistically, where we previously
* had not. For example, consider a cc_library of generated headers. If another
* library depends on it, and only references one of the headers, the other
* grep-includes will have been wasted.
* <p>Note that this may run grep-includes over-optimistically, where we previously had not. For
* example, consider a cc_library of generated headers. If another library depends on it, and only
* references one of the headers, the other grep-includes will have been wasted.
*/
@AutoCodec
@Immutable
final class ExtractInclusionAction extends AbstractAction {

private static final String GUID = "45b43e5a-4734-43bb-a05e-012313808142";

/**
* Constructs a new action.
*/
public ExtractInclusionAction(ActionOwner owner, Artifact input, Artifact output) {
super(owner, ImmutableList.of(input), ImmutableList.of(output));
/** Constructs a new action. */
public ExtractInclusionAction(
ActionOwner owner, Artifact primaryInput, Artifact primaryOutput) {
super(owner, ImmutableList.of(primaryInput), ImmutableList.of(primaryOutput));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,34 @@
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization;
import com.google.devtools.build.lib.util.Fingerprint;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.io.IOException;

/**
* Creates mangled symlinks in the solib directory for all shared libraries.
* Libraries that have a potential to contain SONAME field rely on the mangled
* symlink to the parent directory instead.
* Creates mangled symlinks in the solib directory for all shared libraries. Libraries that have a
* potential to contain SONAME field rely on the mangled symlink to the parent directory instead.
*
* Such symlinks are used by the linker to ensure that all rpath entries can be
* specified relative to the $ORIGIN.
* <p>Such symlinks are used by the linker to ensure that all rpath entries can be specified
* relative to the $ORIGIN.
*/
@AutoCodec
@Immutable
public final class SolibSymlinkAction extends AbstractAction {
private final Path target;
private final Artifact symlink;

private SolibSymlinkAction(ActionOwner owner, Artifact library, Artifact symlink) {
super(owner, ImmutableList.of(library), ImmutableList.of(symlink));
@VisibleForSerialization
SolibSymlinkAction(
ActionOwner owner, Artifact primaryInput, Artifact primaryOutput) {
super(owner, ImmutableList.of(primaryInput), ImmutableList.of(primaryOutput));

Preconditions.checkArgument(Link.SHARED_LIBRARY_FILETYPES.matches(library.getFilename()));
this.symlink = Preconditions.checkNotNull(symlink);
this.target = library.getPath();
Preconditions.checkArgument(Link.SHARED_LIBRARY_FILETYPES.matches(primaryInput.getFilename()));
this.symlink = Preconditions.checkNotNull(primaryOutput);
this.target = primaryInput.getPath();
}

@Override
Expand Down Expand Up @@ -152,7 +156,8 @@ private static Artifact getDynamicLibrarySymlinkInternal(RuleContext ruleContext
ArtifactRoot root = configuration.getBinDirectory(ruleContext.getRule().getRepository());
Artifact symlink = ruleContext.getShareableArtifact(symlinkName, root);
ruleContext.registerAction(
new SolibSymlinkAction(ruleContext.getActionOwner(), library, symlink));
new SolibSymlinkAction(
ruleContext.getActionOwner(), library, symlink));
return symlink;
}

Expand Down

0 comments on commit bb489a7

Please sign in to comment.