aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java44
1 files changed, 43 insertions, 1 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 375f735c72..4bbfeafc16 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
@@ -92,6 +92,18 @@ public final class CppConfiguration extends BuildConfiguration.Fragment
/** String constant for CC_FLAGS make variable name */
public static final String CC_FLAGS_MAKE_VARIABLE_NAME = "CC_FLAGS";
+ public boolean disableLegacyCrosstoolFields() {
+ return cppOptions.disableLegacyCrosstoolFields;
+ }
+
+ public boolean disableCompilationModeFlags() {
+ return cppOptions.disableCompilationModeFlags;
+ }
+
+ public boolean disableLinkingModeFlags() {
+ return cppOptions.disableLinkingModeFlags;
+ }
+
/**
* An enumeration of all the tools that comprise a toolchain.
*/
@@ -223,7 +235,12 @@ public final class CppConfiguration extends BuildConfiguration.Fragment
params.crosstoolTop.getPackageIdentifier().getPathUnderExecRoot();
CppToolchainInfo cppToolchainInfo =
CppToolchainInfo.create(
- crosstoolTopPathFragment, params.ccToolchainLabel, params.crosstoolInfo);
+ crosstoolTopPathFragment,
+ params.ccToolchainLabel,
+ params.crosstoolInfo,
+ cppOptions.disableLegacyCrosstoolFields,
+ cppOptions.disableCompilationModeFlags,
+ cppOptions.disableLinkingModeFlags);
CompilationMode compilationMode = params.commonOptions.compilationMode;
@@ -555,6 +572,7 @@ public final class CppConfiguration extends BuildConfiguration.Fragment
public ImmutableList<String> getCompilerOptions(Iterable<String> featuresNotUsedAnymore)
throws EvalException {
checkForToolchainSkylarkApiAvailability();
+ checkForLegacyCompilationApiAvailability();
return compilerFlags;
}
@@ -567,6 +585,7 @@ public final class CppConfiguration extends BuildConfiguration.Fragment
@Deprecated
public ImmutableList<String> getCOptionsForSkylark() throws EvalException {
checkForToolchainSkylarkApiAvailability();
+ checkForLegacyCompilationApiAvailability();
return getCOptions();
}
@@ -586,6 +605,7 @@ public final class CppConfiguration extends BuildConfiguration.Fragment
public ImmutableList<String> getCxxOptions(Iterable<String> featuresNotUsedAnymore)
throws EvalException {
checkForToolchainSkylarkApiAvailability();
+ checkForLegacyCompilationApiAvailability();
return cxxFlags;
}
@@ -603,6 +623,7 @@ public final class CppConfiguration extends BuildConfiguration.Fragment
public ImmutableList<String> getUnfilteredCompilerOptionsWithLegacySysroot(
Iterable<String> featuresNotUsedAnymore) throws EvalException {
checkForToolchainSkylarkApiAvailability();
+ checkForLegacyCompilationApiAvailability();
return getUnfilteredCompilerOptionsDoNotUse(nonConfiguredSysroot);
}
@@ -637,6 +658,7 @@ public final class CppConfiguration extends BuildConfiguration.Fragment
@Override
public ImmutableList<String> getLinkOptionsWithLegacySysroot() throws EvalException {
checkForToolchainSkylarkApiAvailability();
+ checkForLegacyLinkingApiAvailability();
return getLinkOptionsDoNotUse(nonConfiguredSysroot);
}
@@ -694,6 +716,7 @@ public final class CppConfiguration extends BuildConfiguration.Fragment
public ImmutableList<String> getFullyStaticLinkOptions(
Iterable<String> featuresNotUsedAnymore, Boolean sharedLib) throws EvalException {
checkForToolchainSkylarkApiAvailability();
+ checkForLegacyLinkingApiAvailability();
if (!sharedLib) {
throw new EvalException(
Location.BUILTIN, "fully_static_link_options is deprecated, new uses are not allowed.");
@@ -716,6 +739,7 @@ public final class CppConfiguration extends BuildConfiguration.Fragment
public ImmutableList<String> getMostlyStaticLinkOptions(
Iterable<String> featuresNotUsedAnymore, Boolean sharedLib) throws EvalException {
checkForToolchainSkylarkApiAvailability();
+ checkForLegacyLinkingApiAvailability();
if (sharedLib) {
return getSharedLibraryLinkOptions(
cppToolchainInfo.supportsEmbeddedRuntimes()
@@ -741,6 +765,7 @@ public final class CppConfiguration extends BuildConfiguration.Fragment
public ImmutableList<String> getDynamicLinkOptions(
Iterable<String> featuresNotUsedAnymore, Boolean sharedLib) throws EvalException {
checkForToolchainSkylarkApiAvailability();
+ checkForLegacyLinkingApiAvailability();
if (sharedLib) {
return getSharedLibraryLinkOptions(dynamicLinkFlags);
} else {
@@ -1173,6 +1198,23 @@ public final class CppConfiguration extends BuildConfiguration.Fragment
}
}
+ public void checkForLegacyCompilationApiAvailability() throws EvalException {
+ if (cppOptions.disableLegacyCompilationApi) {
+ throw new EvalException(
+ null,
+ "Skylark APIs accessing compilation flags has been removed. "
+ + "Use the new API on cc_common.");
+ }
+ }
+
+ public void checkForLegacyLinkingApiAvailability() throws EvalException {
+ if (cppOptions.disableLegacyLinkingApi) {
+ throw new EvalException(
+ null,
+ "Skylark APIs accessing linking flags has been removed. Use the new API on cc_common.");
+ }
+ }
+
public static PathFragment computeDefaultSysroot(String builtInSysroot) {
if (builtInSysroot.isEmpty()) {
return null;