diff options
author | hlopko <hlopko@google.com> | 2018-08-08 02:31:40 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-08-08 02:33:11 -0700 |
commit | b9c72697596af9ec650c29513c5057c9314c29f7 (patch) | |
tree | 37f0b060885d064b83ff111d0c4cc300a0cb81ec /src/main/java/com/google/devtools/build/lib/rules | |
parent | 1056e9451282a5f709d10ce473c817998874af56 (diff) |
Expose methods returning bare C++ options in Skylark
This cl exposes getters for flags passed by --copt, --cxxopt, --conlyopt, and
--linkopt Bazel options.
Fixes #5602.
While at it, I deprecated existing methods that are either migrated to the C++
toolchain, or to cc_common.
RELNOTES: None.
PiperOrigin-RevId: 207854692
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java index df698edc8f..10b65c1738 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java @@ -216,7 +216,7 @@ public final class CppConfiguration extends BuildConfiguration.Fragment private final ImmutableList<String> compilerFlags; private final ImmutableList<String> cxxFlags; private final ImmutableList<String> unfilteredCompilerFlags; - private final ImmutableList<String> cOptions; + private final ImmutableList<String> conlyopts; private final ImmutableList<String> mostlyStaticLinkFlags; private final ImmutableList<String> mostlyStaticSharedLinkFlags; @@ -224,7 +224,7 @@ public final class CppConfiguration extends BuildConfiguration.Fragment private final ImmutableList<String> copts; private final ImmutableList<String> cxxopts; - private final ImmutableList<String> linkOptions; + private final ImmutableList<String> linkopts; private final ImmutableList<String> ltoindexOptions; private final ImmutableList<String> ltobackendOptions; @@ -332,13 +332,13 @@ public final class CppConfiguration extends BuildConfiguration.Fragment ImmutableList<String> compilerFlags, ImmutableList<String> cxxFlags, ImmutableList<String> unfilteredCompilerFlags, - ImmutableList<String> cOptions, + ImmutableList<String> conlyopts, ImmutableList<String> mostlyStaticLinkFlags, ImmutableList<String> mostlyStaticSharedLinkFlags, ImmutableList<String> dynamicLinkFlags, ImmutableList<String> copts, ImmutableList<String> cxxopts, - ImmutableList<String> linkOptions, + ImmutableList<String> linkopts, ImmutableList<String> ltoindexOptions, ImmutableList<String> ltobackendOptions, CppOptions cppOptions, @@ -361,13 +361,13 @@ public final class CppConfiguration extends BuildConfiguration.Fragment this.compilerFlags = compilerFlags; this.cxxFlags = cxxFlags; this.unfilteredCompilerFlags = unfilteredCompilerFlags; - this.cOptions = cOptions; + this.conlyopts = conlyopts; this.mostlyStaticLinkFlags = mostlyStaticLinkFlags; this.mostlyStaticSharedLinkFlags = mostlyStaticSharedLinkFlags; this.dynamicLinkFlags = dynamicLinkFlags; this.copts = copts; this.cxxopts = cxxopts; - this.linkOptions = linkOptions; + this.linkopts = linkopts; this.ltoindexOptions = ltoindexOptions; this.ltobackendOptions = ltobackendOptions; this.cppOptions = cppOptions; @@ -602,7 +602,7 @@ public final class CppConfiguration extends BuildConfiguration.Fragment } public ImmutableList<String> getCOptions() { - return cOptions; + return conlyopts; } /** @@ -683,12 +683,9 @@ public final class CppConfiguration extends BuildConfiguration.Fragment @Deprecated ImmutableList<String> getLinkOptionsDoNotUse(@Nullable PathFragment sysroot) { if (sysroot == null) { - return linkOptions; + return linkopts; } else { - return ImmutableList.<String>builder() - .addAll(linkOptions) - .add("--sysroot=" + sysroot) - .build(); + return ImmutableList.<String>builder().addAll(linkopts).add("--sysroot=" + sysroot).build(); } } @@ -696,11 +693,11 @@ public final class CppConfiguration extends BuildConfiguration.Fragment if (dropFullyStaticLinkingMode()) { return false; } - return linkOptions.contains("-static"); + return linkopts.contains("-static"); } public boolean hasSharedLinkOption() { - return linkOptions.contains("-shared"); + return linkopts.contains("-shared"); } /** Returns the set of command-line LTO indexing options. */ @@ -1059,16 +1056,30 @@ public final class CppConfiguration extends BuildConfiguration.Fragment return cppOptions.experimentalOmitfp; } - /** Returns copts given at the Bazel command line. */ + /** Returns flags passed to Bazel by --copt option. */ + @Override public ImmutableList<String> getCopts() { return copts; } - /** Returns copts for c++ given at the Bazel command line. */ + /** Returns flags passed to Bazel by --cxxopt option. */ + @Override public ImmutableList<String> getCxxopts() { return cxxopts; } + /** Returns flags passed to Bazel by --conlyopt option. */ + @Override + public ImmutableList<String> getConlyopts() { + return conlyopts; + } + + /** Returns flags passed to Bazel by --linkopt option. */ + @Override + public ImmutableList<String> getLinkopts() { + return linkopts; + } + @Override public void reportInvalidOptions(EventHandler reporter, BuildOptions buildOptions) { CppOptions cppOptions = buildOptions.get(CppOptions.class); |