C++: fix formatting of files that commonly complicate diffs
These files don't follow the style guide, so every cl that touches them also reformats pieces of them. Doing one big reformat to simplify future reviews.
RELNOTES:none
PiperOrigin-RevId: 237244551
diff --git a/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java b/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java
index 1ef10cb..d3f683f 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java
@@ -531,11 +531,10 @@
/** Used in an integration test to confirm that flags are visible to the interpreter. */
@Option(
- name = "internal_skylark_flag_test_canary",
- defaultValue = "false",
- documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
- effectTags = {OptionEffectTag.UNKNOWN}
- )
+ name = "internal_skylark_flag_test_canary",
+ defaultValue = "false",
+ documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
+ effectTags = {OptionEffectTag.UNKNOWN})
public boolean internalSkylarkFlagTestCanary;
@Option(
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderHelper.java
index c62e54e..13154c2 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderHelper.java
@@ -202,12 +202,13 @@
"fdo",
prefetchHintsFile.getAbsolutePath().getBaseName(),
ruleContext.getBinOrGenfilesDirectory());
- ruleContext.registerAction(SymlinkAction.toAbsolutePath(
- ruleContext.getActionOwner(),
- PathFragment.create(prefetchHintsFile.getAbsolutePath().getPathString()),
- prefetchHintsArtifact,
- "Symlinking LLVM Cache Prefetch Hints Profile "
- + prefetchHintsFile.getAbsolutePath().getPathString()));
+ ruleContext.registerAction(
+ SymlinkAction.toAbsolutePath(
+ ruleContext.getActionOwner(),
+ PathFragment.create(prefetchHintsFile.getAbsolutePath().getPathString()),
+ prefetchHintsArtifact,
+ "Symlinking LLVM Cache Prefetch Hints Profile "
+ + prefetchHintsFile.getAbsolutePath().getPathString()));
return prefetchHintsArtifact;
}
@@ -394,13 +395,11 @@
return null;
}
-
if (fdoInputs != null) {
fdoInputFile = fdoInputs.getFirst();
protoProfileArtifact = fdoInputs.getSecond();
}
-
CcSkyframeSupportValue ccSkyframeSupportValue = null;
SkyKey ccSupportKey = null;
CToolchain toolchain = null;
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
index 22105a3..9e7c9d2 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
@@ -82,9 +82,8 @@
static final PathFragment PIC_OBJS = PathFragment.create("_pic_objs");
// TODO(bazel-team): should this use Link.SHARED_LIBRARY_FILETYPES?
- public static final FileTypeSet SHARED_LIBRARY_FILETYPES = FileTypeSet.of(
- CppFileTypes.SHARED_LIBRARY,
- CppFileTypes.VERSIONED_SHARED_LIBRARY);
+ public static final FileTypeSet SHARED_LIBRARY_FILETYPES =
+ FileTypeSet.of(CppFileTypes.SHARED_LIBRARY, CppFileTypes.VERSIONED_SHARED_LIBRARY);
/** Base label of the c++ toolchain category. */
public static final String TOOLCHAIN_TYPE_LABEL = "//tools/cpp:toolchain_type";
@@ -93,9 +92,7 @@
// prevents construction
}
- /**
- * Returns the malloc implementation for the given target.
- */
+ /** Returns the malloc implementation for the given target. */
public static TransitiveInfoCollection mallocForTarget(
RuleContext ruleContext, String mallocAttrName) {
if (ruleContext.getFragment(CppConfiguration.class).customMalloc() != null) {
@@ -116,13 +113,11 @@
* @param ruleContext the ruleContext to be used as the context of Make variable expansion
* @param attributeName the name of the attribute to use in error reporting
* @param input the list of strings to expand
- * @return a list of strings containing the expanded and tokenized values for the
- * attribute
+ * @return a list of strings containing the expanded and tokenized values for the attribute
*/
private static List<String> expandMakeVariables(
RuleContext ruleContext, String attributeName, List<String> input) {
- boolean tokenization =
- !ruleContext.getFeatures().contains("no_copts_tokenization");
+ boolean tokenization = !ruleContext.getFeatures().contains("no_copts_tokenization");
List<String> tokens = new ArrayList<>();
Expander expander = ruleContext.getExpander().withDataExecLocations();
@@ -146,9 +141,7 @@
return ImmutableList.copyOf(tokens);
}
- /**
- * Returns the tokenized values of the copts attribute to copts.
- */
+ /** Returns the tokenized values of the copts attribute to copts. */
// Called from CcCommon and CcSupport (Google's internal version of proto_library).
public static ImmutableList<String> getAttributeCopts(RuleContext ruleContext) {
String attr = "copts";
@@ -224,9 +217,7 @@
* @param sharedLib true if the output is a shared lib, false if it's an executable
*/
public static ImmutableList<String> getDynamicLinkOptions(
- CppConfiguration config,
- CcToolchainProvider toolchain,
- Boolean sharedLib) {
+ CppConfiguration config, CcToolchainProvider toolchain, Boolean sharedLib) {
if (sharedLib) {
return toolchain.getSharedLibraryLinkOptions(
toolchain.getLegacyDynamicLinkFlags(config.getCompilationMode()));
@@ -313,12 +304,12 @@
@Nullable
public static CcToolchainProvider getToolchain(
RuleContext ruleContext, String toolchainAttribute) {
- if (!ruleContext.isAttrDefined(toolchainAttribute, LABEL)) {
- // TODO(bazel-team): Report an error or throw an exception in this case.
- return null;
- }
- TransitiveInfoCollection dep = ruleContext.getPrerequisite(toolchainAttribute, Mode.TARGET);
- return getToolchain(ruleContext, dep);
+ if (!ruleContext.isAttrDefined(toolchainAttribute, LABEL)) {
+ // TODO(bazel-team): Report an error or throw an exception in this case.
+ return null;
+ }
+ TransitiveInfoCollection dep = ruleContext.getPrerequisite(toolchainAttribute, Mode.TARGET);
+ return getToolchain(ruleContext, dep);
}
/** Returns the c++ toolchain type, or null if it is not specified on the rule class. */
@@ -440,7 +431,7 @@
LinkTargetType linkType)
throws RuleErrorException {
return getLinkedArtifact(
- ruleContext, ccToolchain, config, linkType, /* linkedArtifactNameSuffix= */ "");
+ ruleContext, ccToolchain, config, linkType, /* linkedArtifactNameSuffix= */ "");
}
/** Returns the linked artifact with the given suffix. */
@@ -478,11 +469,13 @@
String linkedArtifactNameSuffix) {
PathFragment name = PathFragment.create(label.getName());
if (linkType != LinkTargetType.EXECUTABLE) {
- name = name.replaceName(
- "lib" + name.getBaseName()
- + linkedArtifactNameSuffix
- + linkType.getPicExtensionWhenApplicable()
- + linkType.getDefaultExtension());
+ name =
+ name.replaceName(
+ "lib"
+ + name.getBaseName()
+ + linkedArtifactNameSuffix
+ + linkType.getPicExtensionWhenApplicable()
+ + linkType.getDefaultExtension());
}
return actionConstructionContext.getPackageRelativeArtifact(
@@ -499,8 +492,10 @@
for (Linkstamp pair : linkstamps) {
Artifact artifact = pair.getArtifact();
if (result.containsKey(artifact)) {
- listener.ruleWarning("rule inherits the '" + artifact.toDetailString()
- + "' linkstamp file from more than one cc_library rule");
+ listener.ruleWarning(
+ "rule inherits the '"
+ + artifact.toDetailString()
+ + "' linkstamp file from more than one cc_library rule");
}
result.put(artifact, pair.getDeclaredIncludeSrcs());
}
@@ -511,8 +506,7 @@
/** Returns whether binaries must be compiled with position independent code. */
public static boolean usePicForBinaries(
- CcToolchainProvider toolchain,
- FeatureConfiguration featureConfiguration) {
+ CcToolchainProvider toolchain, FeatureConfiguration featureConfiguration) {
// TODO(b/124030770): Please do not use this feature without contacting the C++ rules team at
// bazel-team@google.com. The feature will be removed in a later Bazel release and it might
// break you. Contact us so we can find alternatives for your build.
@@ -625,8 +619,12 @@
purpose += "_with_solib";
}
return ImmutableList.of(
- factory.createMiddlemanAllowMultiple(ruleContext.getAnalysisEnvironment(), actionOwner,
- ruleContext.getPackageDirectory(), purpose, artifacts,
+ factory.createMiddlemanAllowMultiple(
+ ruleContext.getAnalysisEnvironment(),
+ actionOwner,
+ ruleContext.getPackageDirectory(),
+ purpose,
+ artifacts,
configuration.getMiddlemanDirectory(ruleContext.getRule().getRepository())));
}
@@ -660,11 +658,12 @@
Artifact output,
FeatureConfiguration featureConfiguration) {
if (featureConfiguration.isEnabled(CppRuleClasses.NO_STRIPPING)) {
- context.registerAction(SymlinkAction.toArtifact(
- context.getActionOwner(),
- input,
- output,
- "Symlinking original binary as stripped binary"));
+ context.registerAction(
+ SymlinkAction.toArtifact(
+ context.getActionOwner(),
+ input,
+ output,
+ "Symlinking original binary as stripped binary"));
return;
}
@@ -705,8 +704,8 @@
context.registerAction(stripAction);
}
- public static void maybeAddStaticLinkMarkerProvider(RuleConfiguredTargetBuilder builder,
- RuleContext ruleContext) {
+ public static void maybeAddStaticLinkMarkerProvider(
+ RuleConfiguredTargetBuilder builder, RuleContext ruleContext) {
if (ruleContext.getFeatures().contains("fully_static_link")) {
builder.add(StaticallyLinkedMarkerProvider.class, new StaticallyLinkedMarkerProvider(true));
}
@@ -791,9 +790,11 @@
Artifact defParser,
ImmutableList<Artifact> objectFiles,
String dllName) {
- Artifact defFile = ruleContext.getBinArtifact(
- ruleContext.getLabel().getName()
- + ".gen" + Iterables.getOnlyElement(CppFileTypes.WINDOWS_DEF_FILE.getExtensions()));
+ Artifact defFile =
+ ruleContext.getBinArtifact(
+ ruleContext.getLabel().getName()
+ + ".gen"
+ + Iterables.getOnlyElement(CppFileTypes.WINDOWS_DEF_FILE.getExtensions()));
CustomCommandLine.Builder argv = new CustomCommandLine.Builder();
for (Artifact objectFile : objectFiles) {
argv.addDynamicString(objectFile.getExecPathString());
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
index cf1e82c..f3439df 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
@@ -213,7 +213,7 @@
private String getActionName() {
return linkType.getActionName();
}
-
+
/** Returns linker inputs that are not libraries. */
public Set<LinkerInput> getObjectFiles() {
return objectFiles;
@@ -229,16 +229,12 @@
return linkstampsBuilder.build();
}
- /**
- * Returns command line options for this link action.
- */
+ /** Returns command line options for this link action. */
public final List<String> getLinkopts() {
return this.linkopts;
}
-
- /**
- * Returns the type of this link action.
- */
+
+ /** Returns the type of this link action. */
public LinkTargetType getLinkType() {
return this.linkType;
}
@@ -247,13 +243,11 @@
return this.linkingMode;
}
- /**
- * Returns true for a cc_fake_binary.
- */
+ /** Returns true for a cc_fake_binary. */
public boolean isFake() {
return this.fake;
}
-
+
public CppLinkActionBuilder setLinkArtifactFactory(LinkArtifactFactory linkArtifactFactory) {
this.linkArtifactFactory = linkArtifactFactory;
return this;
@@ -387,9 +381,7 @@
}
private ImmutableList<String> collectPerFileLtoBackendOpts(Artifact objectFile) {
- return cppConfiguration
- .getPerFileLtoBackendOpts()
- .stream()
+ return cppConfiguration.getPerFileLtoBackendOpts().stream()
.filter(perLabelOptions -> perLabelOptions.isIncluded(objectFile))
.map(PerLabelOptions::getOptions)
.flatMap(options -> options.stream())
@@ -998,8 +990,7 @@
inputsBuilder.add(ImmutableList.of(linkCommandLine.getParamFile()));
// Pass along tree artifacts, so they can be properly expanded.
ImmutableSet<Artifact> paramFileActionInputs =
- expandedLinkerArtifacts
- .stream()
+ expandedLinkerArtifacts.stream()
.filter(a -> a.isTreeArtifact())
.collect(ImmutableSet.toImmutableSet());
@@ -1064,8 +1055,7 @@
inputsBuilder.add(linkstampObjectArtifacts);
ImmutableSet<Artifact> fakeLinkerInputArtifacts =
- collectedLibrariesToLink.getExpandedLinkerInputs()
- .stream()
+ collectedLibrariesToLink.getExpandedLinkerInputs().stream()
.filter(LinkerInput::isFake)
.map(LinkerInput::getArtifact)
.collect(ImmutableSet.toImmutableSet());
@@ -1211,7 +1201,7 @@
protected ActionOwner getOwner() {
return actionConstructionContext.getActionOwner();
}
-
+
/** Sets the mnemonic for the link action. */
public CppLinkActionBuilder setMnemonic(String mnemonic) {
this.mnemonic = mnemonic;
@@ -1267,8 +1257,8 @@
for (VariablesExtension variablesExtension : variablesExtensions) {
addVariablesExtension(variablesExtension);
}
- return this;
- }
+ return this;
+ }
/**
* Sets the interface output of the link. A non-null argument can only be provided if the link
@@ -1291,7 +1281,7 @@
return this;
}
- private void addObjectFile(LinkerInput input) {
+ private void addObjectFile(LinkerInput input) {
// We skip file extension checks for TreeArtifacts because they represent directory artifacts
// without a file extension.
String name = input.getArtifact().getFilename();
@@ -1303,9 +1293,7 @@
}
}
- /**
- * Adds a single object file to the set of inputs.
- */
+ /** Adds a single object file to the set of inputs. */
public CppLinkActionBuilder addObjectFile(Artifact input) {
addObjectFile(
LinkerInputs.simpleLinkerInput(
@@ -1313,9 +1301,7 @@
return this;
}
- /**
- * Adds object files to the linker action.
- */
+ /** Adds object files to the linker action. */
public CppLinkActionBuilder addObjectFiles(Iterable<Artifact> inputs) {
for (Artifact input : inputs) {
addObjectFile(
@@ -1427,8 +1413,8 @@
}
/**
- * Sets the identifier of the library produced by the action. See
- * {@link LinkerInputs.LibraryToLink#getLibraryIdentifier()}
+ * Sets the identifier of the library produced by the action. See {@link
+ * LinkerInputs.LibraryToLink#getLibraryIdentifier()}
*/
public CppLinkActionBuilder setLibraryIdentifier(String libraryIdentifier) {
this.libraryIdentifier = libraryIdentifier;
@@ -1537,26 +1523,20 @@
this.toolchainLibrariesSolibDir = toolchainLibrariesSolibDir;
return this;
}
-
- /**
- * Adds an extra input artifact to the link action.
- */
+
+ /** Adds an extra input artifact to the link action. */
public CppLinkActionBuilder addActionInput(Artifact input) {
this.linkActionInputs.add(input);
return this;
}
-
- /**
- * Adds extra input artifacts to the link action.
- */
+
+ /** Adds extra input artifacts to the link action. */
public CppLinkActionBuilder addActionInputs(Iterable<Artifact> inputs) {
this.linkActionInputs.addAll(inputs);
return this;
}
-
- /**
- * Adds extra input artifacts to the link actions.
- */
+
+ /** Adds extra input artifacts to the link actions. */
public CppLinkActionBuilder addTransitiveActionInputs(NestedSet<Artifact> inputs) {
this.linkActionInputs.addTransitive(inputs);
return this;
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppRuleClasses.java
index 0399910..46ac895 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppRuleClasses.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppRuleClasses.java
@@ -46,9 +46,7 @@
import com.google.devtools.build.lib.util.FileTypeSet;
import com.google.devtools.build.lib.util.OsUtils;
-/**
- * Rule class definitions for C++ rules.
- */
+/** Rule class definitions for C++ rules. */
public class CppRuleClasses {
/**
@@ -86,27 +84,29 @@
}
// Artifacts of these types are discarded from the 'hdrs' attribute in cc rules
- static final FileTypeSet DISALLOWED_HDRS_FILES = FileTypeSet.of(
- ARCHIVE,
- PIC_ARCHIVE,
- ALWAYS_LINK_LIBRARY,
- ALWAYS_LINK_PIC_LIBRARY,
- SHARED_LIBRARY,
- INTERFACE_SHARED_LIBRARY,
- VERSIONED_SHARED_LIBRARY,
- OBJECT_FILE,
- PIC_OBJECT_FILE);
+ static final FileTypeSet DISALLOWED_HDRS_FILES =
+ FileTypeSet.of(
+ ARCHIVE,
+ PIC_ARCHIVE,
+ ALWAYS_LINK_LIBRARY,
+ ALWAYS_LINK_PIC_LIBRARY,
+ SHARED_LIBRARY,
+ INTERFACE_SHARED_LIBRARY,
+ VERSIONED_SHARED_LIBRARY,
+ OBJECT_FILE,
+ PIC_OBJECT_FILE);
/**
* The set of instrumented source file types; keep this in sync with the list above. Note that
* extension-less header files cannot currently be declared, so we cannot collect coverage for
* those.
*/
- static final InstrumentationSpec INSTRUMENTATION_SPEC = new InstrumentationSpec(
- FileTypeSet.of(CPP_SOURCE, C_SOURCE, CPP_HEADER, ASSEMBLER_WITH_C_PREPROCESSOR,
- ASSEMBLER))
- .withSourceAttributes("srcs", "hdrs")
- .withDependencyAttributes("deps", "data");
+ static final InstrumentationSpec INSTRUMENTATION_SPEC =
+ new InstrumentationSpec(
+ FileTypeSet.of(
+ CPP_SOURCE, C_SOURCE, CPP_HEADER, ASSEMBLER_WITH_C_PREPROCESSOR, ASSEMBLER))
+ .withSourceAttributes("srcs", "hdrs")
+ .withDependencyAttributes("deps", "data");
/** Implicit outputs for cc_binary rules. */
public static final SafeImplicitOutputsFunction CC_BINARY_STRIPPED =
@@ -119,9 +119,7 @@
/** Name of the feature that will be exempt from flag filtering when nocopts are used */
public static final String UNFILTERED_COMPILE_FLAGS_FEATURE_NAME = "unfiltered_compile_flags";
- /**
- * A string constant for the parse_headers feature.
- */
+ /** A string constant for the parse_headers feature. */
public static final String PARSE_HEADERS = "parse_headers";
/**
@@ -136,31 +134,25 @@
*/
public static final String RANDOM_SEED = "random_seed";
- /**
- * A string constant for the dependency_file feature. This feature generates the .d file.
- */
+ /** A string constant for the dependency_file feature. This feature generates the .d file. */
public static final String DEPENDENCY_FILE = "dependency_file";
- /**
- * A string constant for the module_map_home_cwd feature.
- */
+ /** A string constant for the module_map_home_cwd feature. */
public static final String MODULE_MAP_HOME_CWD = "module_map_home_cwd";
/**
* A string constant for the module_map_without_extern_module feature.
*
- * <p>This features is a transitional feature; enabling it means that generated module maps
- * will not have "extern module" declarations inside them; instead, the module maps need
- * to be passed via the dependent_module_map_files build variable.
+ * <p>This features is a transitional feature; enabling it means that generated module maps will
+ * not have "extern module" declarations inside them; instead, the module maps need to be passed
+ * via the dependent_module_map_files build variable.
*
* <p>This variable is phrased negatively to aid the roll-out: currently, the default is that
* "extern module" declarations are generated.
*/
public static final String MODULE_MAP_WITHOUT_EXTERN_MODULE = "module_map_without_extern_module";
- /**
- * A string constant for the layering_check feature.
- */
+ /** A string constant for the layering_check feature. */
public static final String LAYERING_CHECK = "layering_check";
/** A string constant for the header_modules feature. */
@@ -172,22 +164,18 @@
/** A string constant for the header_module_codegen feature. */
public static final String HEADER_MODULE_CODEGEN = "header_module_codegen";
- /**
- * A string constant for the compile_all_modules feature.
- */
+ /** A string constant for the compile_all_modules feature. */
public static final String COMPILE_ALL_MODULES = "compile_all_modules";
- /**
- * A string constant for the exclude_private_headers_in_module_maps feature.
- */
+ /** A string constant for the exclude_private_headers_in_module_maps feature. */
public static final String EXCLUDE_PRIVATE_HEADERS_IN_MODULE_MAPS =
"exclude_private_headers_in_module_maps";
/**
* A string constant for the use_header_modules feature.
*
- * <p>This feature is only used during rollout; we expect to default enable this once we
- * have verified that module-enabled compilation is stable enough.
+ * <p>This feature is only used during rollout; we expect to default enable this once we have
+ * verified that module-enabled compilation is stable enough.
*/
public static final String USE_HEADER_MODULES = "use_header_modules";
@@ -230,9 +218,7 @@
*/
public static final String DEFAULT_COMPILE_FLAGS = "default_compile_flags";
- /**
- * A string constant for the feature that makes us build per-object debug info files.
- */
+ /** A string constant for the feature that makes us build per-object debug info files. */
public static final String PER_OBJECT_DEBUG_INFO = "per_object_debug_info";
/**
@@ -246,17 +232,13 @@
/** A string constant for a feature that indicates that the toolchain can produce PIC objects. */
public static final String SUPPORTS_PIC = "supports_pic";
- /**
- * A string constant for the feature the represents preprocessor defines.
- */
+ /** A string constant for the feature the represents preprocessor defines. */
public static final String PREPROCESSOR_DEFINES = "preprocessor_defines";
/** A string constant for the includes feature. */
public static final String INCLUDES = "includes";
- /**
- * A string constant for the include_paths feature.
- */
+ /** A string constant for the include_paths feature. */
public static final String INCLUDE_PATHS = "include_paths";
/** A string constant for the feature signalling static linking mode. */
@@ -265,9 +247,7 @@
/** A string constant for the feature signalling dynamic linking mode. */
public static final String DYNAMIC_LINKING_MODE = "dynamic_linking_mode";
- /**
- * A string constant for the ThinLTO feature.
- */
+ /** A string constant for the ThinLTO feature. */
public static final String THIN_LTO = "thin_lto";
/*
@@ -368,27 +348,19 @@
*/
public static final String FDO_INSTRUMENT = "fdo_instrument";
- /**
- * A string constant for the fdo_optimize feature.
- */
+ /** A string constant for the fdo_optimize feature. */
public static final String FDO_OPTIMIZE = "fdo_optimize";
- /**
- * A string constant for the cache prefetch hints feature.
- */
+ /** A string constant for the cache prefetch hints feature. */
public static final String FDO_PREFETCH_HINTS = "fdo_prefetch_hints";
- /**
- * A string constant for the autofdo feature.
- */
+ /** A string constant for the autofdo feature. */
public static final String AUTOFDO = "autofdo";
/** A string constant for the xbinaryfdo feature. */
public static final String XBINARYFDO = "xbinaryfdo";
- /**
- * A string constant for the coverage feature.
- */
+ /** A string constant for the coverage feature. */
public static final String COVERAGE = "coverage";
/** Produce artifacts for coverage in llvm coverage mapping format. */
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppToolchainInfo.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppToolchainInfo.java
index 7bb1523..c75cf00 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppToolchainInfo.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppToolchainInfo.java
@@ -367,7 +367,8 @@
}
for (ArtifactCategory category : ArtifactCategory.values()) {
- if (!definedCategories.contains(category) && category.getDefaultPrefix() != null
+ if (!definedCategories.contains(category)
+ && category.getDefaultPrefix() != null
&& category.getDefaultExtension() != null) {
toolchainBuilder.addArtifactNamePattern(
ArtifactNamePattern.newBuilder()
@@ -379,31 +380,29 @@
}
ImmutableSet<String> featureNames =
- toolchain
- .getFeatureList()
- .stream()
+ toolchain.getFeatureList().stream()
.map(feature -> feature.getName())
.collect(ImmutableSet.toImmutableSet());
if (!featureNames.contains(CppRuleClasses.NO_LEGACY_FEATURES)) {
- String gccToolPath = "DUMMY_GCC_TOOL";
- String linkerToolPath = "DUMMY_LINKER_TOOL";
- String arToolPath = "DUMMY_AR_TOOL";
- String stripToolPath = "DUMMY_STRIP_TOOL";
- for (ToolPath tool : toolchain.getToolPathList()) {
- if (tool.getName().equals(CppConfiguration.Tool.GCC.getNamePart())) {
- gccToolPath = tool.getPath();
- linkerToolPath =
- crosstoolTopPathFragment
- .getRelative(PathFragment.create(tool.getPath()))
- .getPathString();
- }
- if (tool.getName().equals(CppConfiguration.Tool.AR.getNamePart())) {
- arToolPath = tool.getPath();
- }
- if (tool.getName().equals(CppConfiguration.Tool.STRIP.getNamePart())) {
- stripToolPath = tool.getPath();
- }
+ String gccToolPath = "DUMMY_GCC_TOOL";
+ String linkerToolPath = "DUMMY_LINKER_TOOL";
+ String arToolPath = "DUMMY_AR_TOOL";
+ String stripToolPath = "DUMMY_STRIP_TOOL";
+ for (ToolPath tool : toolchain.getToolPathList()) {
+ if (tool.getName().equals(CppConfiguration.Tool.GCC.getNamePart())) {
+ gccToolPath = tool.getPath();
+ linkerToolPath =
+ crosstoolTopPathFragment
+ .getRelative(PathFragment.create(tool.getPath()))
+ .getPathString();
}
+ if (tool.getName().equals(CppConfiguration.Tool.AR.getNamePart())) {
+ arToolPath = tool.getPath();
+ }
+ if (tool.getName().equals(CppConfiguration.Tool.STRIP.getNamePart())) {
+ stripToolPath = tool.getPath();
+ }
+ }
// TODO(b/30109612): Remove fragile legacyCompileFlags shuffle once there are no legacy
// crosstools.
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariables.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariables.java
index 8d30de4..6dc08c3 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariables.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariables.java
@@ -184,7 +184,8 @@
buildVariables.addStringVariable(
THINLTO_OBJECT_SUFFIX_REPLACE.getVariableName(),
Iterables.getOnlyElement(CppFileTypes.LTO_INDEXING_OBJECT_FILE.getExtensions())
- + ";" + objectFileExtension);
+ + ";"
+ + objectFileExtension);
if (thinltoMergedObjectFile != null) {
buildVariables.addStringVariable(
THINLTO_MERGED_OBJECT_FILE.getVariableName(), thinltoMergedObjectFile);
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java
index fd599d7..06272d0 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java
@@ -105,9 +105,7 @@
return featureConfiguration;
}
- /**
- * Returns the current type of link target set.
- */
+ /** Returns the current type of link target set. */
public LinkTargetType getLinkTargetType() {
return linkTargetType;
}
@@ -117,9 +115,7 @@
return linkingMode;
}
- /**
- * Returns the additional linker options for this link.
- */
+ /** Returns the additional linker options for this link. */
public ImmutableList<String> getLinkopts() {
if (variables.isAvailable(LinkBuildVariables.USER_LINK_FLAGS.getVariableName())) {
return CcToolchainVariables.toStringList(
@@ -144,17 +140,15 @@
return toolchainLibrariesSolibDir;
}
- /**
- * Returns true for libraries linked as native dependencies for other languages.
- */
+ /** Returns true for libraries linked as native dependencies for other languages. */
public boolean isNativeDeps() {
return nativeDeps;
}
/**
* Returns true if this link should use test-specific flags (e.g. $EXEC_ORIGIN as the root for
- * finding shared libraries or lazy binding); false by default. See bug "Please use
- * $EXEC_ORIGIN instead of $ORIGIN when linking cc_tests" for further context.
+ * finding shared libraries or lazy binding); false by default. See bug "Please use $EXEC_ORIGIN
+ * instead of $ORIGIN when linking cc_tests" for further context.
*/
public boolean useTestOnlyFlags() {
return useTestOnlyFlags;
@@ -182,9 +176,7 @@
}
private static Pair<List<String>, List<String>> splitCommandline(
- Artifact paramFile,
- List<String> args,
- LinkTargetType linkTargetType) {
+ Artifact paramFile, List<String> args, LinkTargetType linkTargetType) {
Preconditions.checkNotNull(paramFile);
if (linkTargetType.linkerOrArchiver() == LinkerOrArchiver.ARCHIVER) {
// Ar link commands can also generate huge command lines.
@@ -237,12 +229,7 @@
public Iterable<String> arguments() {
List<String> argv =
getRawLinkArgv(
- null,
- forcedToolPath,
- featureConfiguration,
- actionName,
- linkTargetType,
- variables);
+ null, forcedToolPath, featureConfiguration, actionName, linkTargetType, variables);
return splitCommandline(paramsFile, argv, linkTargetType).getSecond();
}
@@ -260,18 +247,11 @@
}
}
- /**
- * Returns just the .params file portion of the command-line as a {@link CommandLine}.
- */
+ /** Returns just the .params file portion of the command-line as a {@link CommandLine}. */
CommandLine paramCmdLine() {
Preconditions.checkNotNull(paramFile);
return new ParamFileCommandLine(
- paramFile,
- linkTargetType,
- forcedToolPath,
- featureConfiguration,
- actionName,
- variables);
+ paramFile, linkTargetType, forcedToolPath, featureConfiguration, actionName, variables);
}
public static void extractArgumentsForStaticLinkParamFile(
@@ -292,7 +272,7 @@
List<String> args, List<String> commandlineArgs, List<String> paramFileArgs) {
// Note, that it is not important that all linker arguments are extracted so that
// they can be moved into a parameter file, but the vast majority should.
- commandlineArgs.add(args.get(0)); // gcc command, must not be moved!
+ commandlineArgs.add(args.get(0)); // gcc command, must not be moved!
int argsSize = args.size();
for (int i = 1; i < argsSize; i++) {
String arg = args.get(i);
@@ -360,12 +340,7 @@
*/
public List<String> getRawLinkArgv(@Nullable ArtifactExpander expander) {
return getRawLinkArgv(
- expander,
- forcedToolPath,
- featureConfiguration,
- actionName,
- linkTargetType,
- variables);
+ expander, forcedToolPath, featureConfiguration, actionName, linkTargetType, variables);
}
private static List<String> getRawLinkArgv(
@@ -518,8 +493,8 @@
}
/**
- * Sets whether to use test-specific linker flags, e.g. {@code $EXEC_ORIGIN} instead of
- * {@code $ORIGIN} in the rpath or lazy binding.
+ * Sets whether to use test-specific linker flags, e.g. {@code $EXEC_ORIGIN} instead of {@code
+ * $ORIGIN} in the rpath or lazy binding.
*/
public Builder setUseTestOnlyFlags(boolean useTestOnlyFlags) {
this.useTestOnlyFlags = useTestOnlyFlags;
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java b/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java
index 857d7b9..9d14165 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java
@@ -76,22 +76,21 @@
* Returns true if a feature attached to the given toggling flags should be enabled.
*
* <ul>
- * <li>If both parameters are {@code NONE}, this indicates the feature is not
- * controlled by flags, and should thus be enabled.</li>
- * <li>If the {@code enablingFlag} parameter is non-{@code NONE}, this returns
- * true if and only if that flag is true. (This represents a feature that is only on
- * if a given flag is *on*).</li>
- * <li>If the {@code disablingFlag} parameter is non-{@code NONE}, this returns
- * true if and only if that flag is false. (This represents a feature that is only on
- * if a given flag is *off*).</li>
- * <li>It is illegal to pass both parameters as non-{@code NONE}.</li>
+ * <li>If both parameters are {@code NONE}, this indicates the feature is not controlled by
+ * flags, and should thus be enabled.
+ * <li>If the {@code enablingFlag} parameter is non-{@code NONE}, this returns true if and only
+ * if that flag is true. (This represents a feature that is only on if a given flag is
+ * *on*).
+ * <li>If the {@code disablingFlag} parameter is non-{@code NONE}, this returns true if and only
+ * if that flag is false. (This represents a feature that is only on if a given flag is
+ * *off*).
+ * <li>It is illegal to pass both parameters as non-{@code NONE}.
* </ul>
*/
public boolean isFeatureEnabledBasedOnTogglingFlags(
- FlagIdentifier enablingFlag,
- FlagIdentifier disablingFlag) {
- Preconditions.checkArgument(enablingFlag == FlagIdentifier.NONE
- || disablingFlag == FlagIdentifier.NONE,
+ FlagIdentifier enablingFlag, FlagIdentifier disablingFlag) {
+ Preconditions.checkArgument(
+ enablingFlag == FlagIdentifier.NONE || disablingFlag == FlagIdentifier.NONE,
"at least one of 'enablingFlag' or 'disablingFlag' must be NONE");
if (enablingFlag != FlagIdentifier.NONE) {
return enablingFlag.semanticsFunction.apply(this);