diff options
author | 2016-03-29 18:23:11 -0800 | |
---|---|---|
committer | 2016-03-29 19:33:33 -0700 | |
commit | 80a5a3e653f3b10e2680fe2ea9bc511e8801e273 (patch) | |
tree | 6d205c779cde774c46e6aa328a8f7ef0f85a1461 /tensorflow/tensorflow.bzl | |
parent | e3a0d6fb61cbb1dd9864684c20e49ef3fa385bb6 (diff) |
Merge changes from github.
Change: 118532471
Diffstat (limited to 'tensorflow/tensorflow.bzl')
-rw-r--r-- | tensorflow/tensorflow.bzl | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index 09f29bd0e0..27b66bd7c6 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -1,5 +1,31 @@ # -*- Python -*- +# Parse the bazel version string from `native.bazel_version`. +def _parse_bazel_version(bazel_version): + # Remove commit from version. + version = bazel_version.split(" ", 1)[0] + + # Split into (release, date) parts and only return the release + # as a tuple of integers. + parts = version.split('-', 1) + + # Turn "release" into a tuple of integers + version_tuple = () + for number in parts[0].split('.'): + version_tuple += (int(number),) + return version_tuple + + +# Check that a specific bazel version is being used. +def check_version(bazel_version): + if "bazel_version" in dir(native): + current_bazel_version = _parse_bazel_version(native.bazel_version) + minimum_bazel_version = _parse_bazel_version(bazel_version) + if minimum_bazel_version > current_bazel_version: + fail("\nCurrent Bazel version is {}, expected at least {}\n".format( + native.bazel_version, bazel_version)) + pass + # Return the options to use for a C++ library or binary build. # Uses the ":optmode" config_setting to pick the options. |