aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2018-06-20 18:30:27 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-20 18:32:02 -0700
commitf463dec7a03e5dbf9d40024b90b8620972f44c5f (patch)
treeb60ee0ebe6e8886b108e521ae2ee3ffd05caadd3 /src/test
parent98c09748044c27c3b6b57edc3f42b2323ead29ec (diff)
Add a minimum_os_version flag that is platform agnostic.
This corresponds to the os version in the clang target triple, though clang does have corresponding os_version_min flags for Apple platforms. Currently, Bazel has --XX_minimum_os flags for XX values corresponding to Apple platforms. This flag is the generic version of that (and can and will be set after the Apple split transition, and will eventually be set in the Android split as well) to support various Android API level improvements for native code. PiperOrigin-RevId: 201453961
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java
index 296a530f45..5e6ded37b1 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java
@@ -165,4 +165,29 @@ public class CompileBuildVariablesTest extends BuildViewTestCase {
assertThat(variables.getStringVariable(CcCommon.SYSROOT_VARIABLE_NAME))
.isEqualTo("/usr/local/custom-sysroot");
}
+
+ @Test
+ public void testPresenceOfMinOsVersionBuildVariable() throws Exception {
+ AnalysisMock.get()
+ .ccSupport()
+ .setupCrosstool(
+ mockToolsConfig,
+ "feature {"
+ + " name: 'min_os_version_flag'"
+ + " flag_set {"
+ + " action: 'c++-compile'"
+ + " expand_if_all_available: 'minimum_os_version'"
+ + " flag_group {"
+ + " flag: '-DMIN_OS=%{minimum_os_version}'"
+ + " }"
+ + " }"
+ + "}");
+ useConfiguration("--minimum_os_version=6");
+ scratch.file("x/BUILD", "cc_binary(name = 'bin', srcs = ['bin.cc'])");
+ scratch.file("x/bin.cc");
+
+ CcToolchainVariables variables = getCompileBuildVariables("//x:bin", "bin");
+ assertThat(variables.getStringVariable(CcCommon.MINIMUM_OS_VERSION_VARIABLE_NAME))
+ .isEqualTo("6");
+ }
}