aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Michael Case <mikecase@google.com>2018-01-05 14:09:41 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-01-05 14:13:39 -0800
commitd31531af15769f00e8026318167875e1969eac1c (patch)
tree4dac1da507ced2bfe60ea44768ae8fbaf0bb5af6
parentca6f0dd19b127c08e5e2cd7d0e6e9240881e6afa (diff)
Move some build configs to tools/bazel.rc from configure.py
Moving --config=android_arm --config=mkl and --config=monolithic build configs into tools/bazel.rc. These options are just always written the same way to .bazelrc when configure.py is run. This should trim down the scope of configure.py and make it easier to build TF without running configure.py prior. PiperOrigin-RevId: 180973131
-rw-r--r--configure.py60
-rw-r--r--tools/bazel.rc25
2 files changed, 41 insertions, 44 deletions
diff --git a/configure.py b/configure.py
index e4218b5651..7537e308b5 100644
--- a/configure.py
+++ b/configure.py
@@ -1098,17 +1098,18 @@ def set_computecpp_toolkit_path(environ_cp):
write_action_env_to_bazelrc('COMPUTECPP_TOOLKIT_PATH',
computecpp_toolkit_path)
+
def set_trisycl_include_dir(environ_cp):
- """Set TRISYCL_INCLUDE_DIR"""
+ """Set TRISYCL_INCLUDE_DIR."""
ask_trisycl_include_dir = ('Please specify the location of the triSYCL '
'include directory. (Use --config=sycl_trisycl '
'when building with Bazel) '
'[Default is %s]: '
- ) % (_DEFAULT_TRISYCL_INCLUDE_DIR)
+ ) % (_DEFAULT_TRISYCL_INCLUDE_DIR)
while True:
trisycl_include_dir = get_from_env_or_user_or_default(
- environ_cp, 'TRISYCL_INCLUDE_DIR', ask_trisycl_include_dir,
- _DEFAULT_TRISYCL_INCLUDE_DIR)
+ environ_cp, 'TRISYCL_INCLUDE_DIR', ask_trisycl_include_dir,
+ _DEFAULT_TRISYCL_INCLUDE_DIR)
if os.path.exists(trisycl_include_dir):
break
@@ -1178,46 +1179,10 @@ def set_other_mpi_vars(environ_cp):
raise ValueError('Cannot find the MPI library file in %s/lib' % mpi_home)
-def set_mkl():
- write_to_bazelrc('build:mkl --define using_mkl=true')
- write_to_bazelrc('build:mkl -c opt')
- print(
- 'Add "--config=mkl" to your bazel command to build with MKL '
- 'support.\nPlease note that MKL on MacOS or windows is still not '
- 'supported.\nIf you would like to use a local MKL instead of '
- 'downloading, please set the environment variable \"TF_MKL_ROOT\" every '
- 'time before build.\n')
-
-
-def set_monolithic():
- # Add --config=monolithic to your bazel command to use a mostly-static
- # build and disable modular op registration support (this will revert to
- # loading TensorFlow with RTLD_GLOBAL in Python). By default (without
- # --config=monolithic), TensorFlow will build with a dependence on
- # //tensorflow:libtensorflow_framework.so.
- write_to_bazelrc('build:monolithic --define framework_shared_object=false')
- # For projects which use TensorFlow as part of a Bazel build process, putting
- # nothing in a bazelrc will default to a monolithic build. The following line
- # opts in to modular op registration support by default:
- write_to_bazelrc('build --define framework_shared_object=true')
-
-
-def create_android_bazelrc_configs():
- # Flags for --config=android
- write_to_bazelrc('build:android --crosstool_top=//external:android/crosstool')
- write_to_bazelrc(
- 'build:android --host_crosstool_top=@bazel_tools//tools/cpp:toolchain')
- # Flags for --config=android_arm
- write_to_bazelrc('build:android_arm --config=android')
- write_to_bazelrc('build:android_arm --cpu=armeabi-v7a')
- # Flags for --config=android_arm64
- write_to_bazelrc('build:android_arm64 --config=android')
- write_to_bazelrc('build:android_arm64 --cpu=arm64-v8a')
-
-
def set_grpc_build_flags():
write_to_bazelrc('build --define grpc_no_ares=true')
+
def set_windows_build_flags():
if is_windows():
# The non-monolithic build is not supported yet
@@ -1228,6 +1193,11 @@ def set_windows_build_flags():
write_to_bazelrc('build --verbose_failures')
+def config_info_line(name, help_text):
+ """Helper function to print formatted help text for Bazel config options."""
+ print('\t--config=%-12s\t# %s' % (name, help_text))
+
+
def main():
# Make a copy of os.environ to be clear when functions and getting and setting
# environment variables.
@@ -1313,10 +1283,7 @@ def main():
set_grpc_build_flags()
set_cc_opt_flags(environ_cp)
- set_mkl()
- set_monolithic()
set_windows_build_flags()
- create_android_bazelrc_configs()
if workspace_has_any_android_rule():
print('The WORKSPACE file has at least one of ["android_sdk_repository", '
@@ -1334,6 +1301,11 @@ def main():
create_android_ndk_rule(environ_cp)
create_android_sdk_rule(environ_cp)
+ print('Preconfigured Bazel build configs. You can use any of the below by '
+ 'adding "--config=<>" to your build command. See tools/bazel.rc for '
+ 'more details.')
+ config_info_line('mkl', 'Build with MKL support.')
+ config_info_line('monolithic', 'Config for mostly static monolithic build.')
if __name__ == '__main__':
main()
diff --git a/tools/bazel.rc b/tools/bazel.rc
index 04c24d7511..44bfe9f0c2 100644
--- a/tools/bazel.rc
+++ b/tools/bazel.rc
@@ -1,3 +1,28 @@
+# Android configs
+build:android --crosstool_top=//external:android/crosstool
+build:android --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
+build:android_arm --config=android
+build:android_arm --cpu=armeabi-v7a
+build:android_arm64 --config=android
+build:android_arm64 --cpu=arm64-v8a
+
+# Config to use a mostly-static build and disable modular op registration
+# support (this will revert to loading TensorFlow with RTLD_GLOBAL in Python).
+# By default, TensorFlow will build with a dependence on
+# //tensorflow:libtensorflow_framework.so.
+build:monolithic --define framework_shared_object=false
+
+# For projects which use TensorFlow as part of a Bazel build process, putting
+# nothing in a bazelrc will default to a monolithic build. The following line
+# opts in to modular op registration support by default.
+build --define framework_shared_object=true
+
+# Please note that MKL on MacOS or windows is still not supported.
+# If you would like to use a local MKL instead of downloading, please set the
+# environment variable "TF_MKL_ROOT" every time before build.
+build:mkl --define=using_mkl=true
+build:mkl -c opt
+
build:cuda --crosstool_top=@local_config_cuda//crosstool:toolchain
build:cuda --define=using_cuda=true --define=using_cuda_nvcc=true