diff --git a/.gitignore b/.gitignore index 07dd1513806..01f06be1a90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .DS_Store .ipynb_checkpoints node_modules +/.bazelrc /bazel-* /third_party/py/numpy/numpy_include /tools/bazel.rc @@ -13,4 +14,4 @@ node_modules *.pyc __pycache__ *.swp -.vscode/ \ No newline at end of file +.vscode/ diff --git a/configure b/configure index 5bee5fd5e57..26ea13d6fb3 100755 --- a/configure +++ b/configure @@ -8,6 +8,9 @@ pushd `dirname $0` > /dev/null SOURCE_BASE_DIR=`pwd -P` popd > /dev/null +# This file contains customized config settings. +touch .bazelrc + PLATFORM="$(uname -s | tr 'A-Z' 'a-z')" function is_linux() { @@ -182,13 +185,12 @@ else TF_NEED_JEMALLOC=0 fi -if [ "$TF_NEED_JEMALLOC" == "1" ]; then - sed_hyphen_i -e "s/WITH_JEMALLOC = False/WITH_JEMALLOC = True/" tensorflow/core/platform/default/build_config.bzl -else - sed_hyphen_i -e "s/WITH_JEMALLOC = True/WITH_JEMALLOC = False/" tensorflow/core/platform/default/build_config.bzl +sed_hyphen_i -e "/with_jemalloc/d" .bazelrc +if [[ "$TF_NEED_JEMALLOC" == "1" ]]; then + echo 'build --define with_jemalloc=true' >>.bazelrc fi -while [ "$TF_NEED_GCP" == "" ]; do +while [[ "$TF_NEED_GCP" == "" ]]; do read -p "Do you wish to build TensorFlow with "\ "Google Cloud Platform support? [y/N] " INPUT case $INPUT in @@ -202,23 +204,12 @@ while [ "$TF_NEED_GCP" == "" ]; do esac done -if [ "$TF_NEED_GCP" == "1" ]; then - ## Verify that libcurl header files are available. - # Only check Linux, since on MacOS the header files are installed with XCode. - if is_linux && [[ ! -f "/usr/include/curl/curl.h" ]]; then - echo "ERROR: It appears that the development version of libcurl is not "\ -"available. Please install the libcurl3-dev package." - exit 1 - fi - - # Update Bazel build configuration. - sed_hyphen_i -e "s/WITH_GCP_SUPPORT = False/WITH_GCP_SUPPORT = True/" tensorflow/core/platform/default/build_config.bzl -else - # Update Bazel build configuration. - sed_hyphen_i -e "s/WITH_GCP_SUPPORT = True/WITH_GCP_SUPPORT = False/" tensorflow/core/platform/default/build_config.bzl +sed_hyphen_i -e "/with_gcp_support/d" .bazelrc +if [[ "$TF_NEED_GCP" == "1" ]]; then + echo 'build --define with_gcp_support=true' >>.bazelrc fi -while [ "$TF_NEED_HDFS" == "" ]; do +while [[ "$TF_NEED_HDFS" == "" ]]; do read -p "Do you wish to build TensorFlow with "\ "Hadoop File System support? [y/N] " INPUT case $INPUT in @@ -232,16 +223,13 @@ while [ "$TF_NEED_HDFS" == "" ]; do esac done -if [ "$TF_NEED_HDFS" == "1" ]; then - # Update Bazel build configuration. - sed_hyphen_i -e "s/WITH_HDFS_SUPPORT = False/WITH_HDFS_SUPPORT = True/" tensorflow/core/platform/default/build_config.bzl -else - # Update Bazel build configuration. - sed_hyphen_i -e "s/WITH_HDFS_SUPPORT = True/WITH_HDFS_SUPPORT = False/" tensorflow/core/platform/default/build_config.bzl +sed_hyphen_i -e "/with_hdfs_support/d" .bazelrc +if [[ "$TF_NEED_HDFS" == "1" ]]; then + echo 'build --define with_hdfs_support=true' >>.bazelrc fi ## Enable XLA. -while [ "$TF_ENABLE_XLA" == "" ]; do +while [[ "$TF_ENABLE_XLA" == "" ]]; do read -p "Do you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N] " INPUT case $INPUT in [Yy]* ) echo "XLA JIT support will be enabled for TensorFlow"; TF_ENABLE_XLA=1;; @@ -251,12 +239,9 @@ while [ "$TF_ENABLE_XLA" == "" ]; do esac done -if [ "$TF_ENABLE_XLA" == "1" ]; then - # Update Bazel build configuration. - sed_hyphen_i -e "s/^WITH_XLA_SUPPORT = [FT].*/WITH_XLA_SUPPORT = True/" tensorflow/core/platform/default/build_config_root.bzl -else - # Update Bazel build configuration. - sed_hyphen_i -e "s/^WITH_XLA_SUPPORT = [FT].*/WITH_XLA_SUPPORT = False/" tensorflow/core/platform/default/build_config_root.bzl +sed_hyphen_i -e "/with_xla_support/d" .bazelrc +if [[ "$TF_ENABLE_XLA" == "1" ]]; then + echo 'build --define with_xla_support=true' >>.bazelrc fi diff --git a/tensorflow/BUILD b/tensorflow/BUILD index d94515193a8..1eb5e1df6e6 100644 --- a/tensorflow/BUILD +++ b/tensorflow/BUILD @@ -110,6 +110,34 @@ config_setting( visibility = ["//visibility:public"], ) +# TODO(jhseu): Enable on other platforms other than Linux. +config_setting( + name = "with_jemalloc", + values = { + "cpu": "k8", + "define": "with_jemalloc=true", + }, + visibility = ["//visibility:public"], +) + +config_setting( + name = "with_gcp_support", + values = {"define": "with_gcp_support=true"}, + visibility = ["//visibility:public"], +) + +config_setting( + name = "with_hdfs_support", + values = {"define": "with_hdfs_support=true"}, + visibility = ["//visibility:public"], +) + +config_setting( + name = "with_xla_support", + values = {"define": "with_xla_support=true"}, + visibility = ["//visibility:public"], +) + package_group( name = "internal", packages = ["//tensorflow/..."], diff --git a/tensorflow/core/platform/default/build_config.bzl b/tensorflow/core/platform/default/build_config.bzl index 120d614a357..475f0ffb160 100644 --- a/tensorflow/core/platform/default/build_config.bzl +++ b/tensorflow/core/platform/default/build_config.bzl @@ -4,11 +4,6 @@ load("@protobuf//:protobuf.bzl", "cc_proto_library") load("@protobuf//:protobuf.bzl", "py_proto_library") load("//tensorflow:tensorflow.bzl", "if_not_mobile") -# configure may change the following lines -WITH_GCP_SUPPORT = False -WITH_HDFS_SUPPORT = False -WITH_JEMALLOC = False - # Appends a suffix to a list of deps. def tf_deps(deps, suffix): tf_deps = [] @@ -194,35 +189,30 @@ def tf_additional_test_srcs(): def tf_kernel_tests_linkstatic(): return 0 -# jemalloc only enabled on Linux for now. -# TODO(jhseu): Enable on other platforms. def tf_additional_lib_defines(): - defines = [] - if WITH_JEMALLOC: - defines += select({ - "//tensorflow:linux_x86_64": [ - "TENSORFLOW_USE_JEMALLOC" - ], - "//conditions:default": [], - }) - return defines + return select({ + "//tensorflow:with_jemalloc": ["TENSORFLOW_USE_JEMALLOC"], + "//conditions:default": [], + }) def tf_additional_lib_deps(): - deps = [] - if WITH_JEMALLOC: - deps += select({ - "//tensorflow:linux_x86_64": ["@jemalloc"], - "//conditions:default": [], - }) - return deps + return select({ + "//tensorflow:with_jemalloc": ["@jemalloc"], + "//conditions:default": [], + }) def tf_additional_core_deps(): - deps = [] - if WITH_GCP_SUPPORT: - deps.append("//tensorflow/core/platform/cloud:gcs_file_system") - if WITH_HDFS_SUPPORT: - deps.append("//tensorflow/core/platform/hadoop:hadoop_file_system") - return deps + return select({ + "//tensorflow:with_gcp_support": [ + "//tensorflow/core/platform/cloud:gcs_file_system", + ], + "//conditions:default": [], + }) + select({ + "//tensorflow:with_hdfs_support": [ + "//tensorflow/core/platform/hadoop:hadoop_file_system", + ], + "//conditions:default": [], + }) # TODO(jart, jhseu): Delete when GCP is default on. def tf_additional_cloud_op_deps(): diff --git a/tensorflow/core/platform/default/build_config_root.bzl b/tensorflow/core/platform/default/build_config_root.bzl index 23a7b9065a6..79f97c12347 100644 --- a/tensorflow/core/platform/default/build_config_root.bzl +++ b/tensorflow/core/platform/default/build_config_root.bzl @@ -2,8 +2,6 @@ # The functions in this file might be referred by tensorflow.bzl. They have to # be separate to avoid cyclic references. -WITH_XLA_SUPPORT = False - def tf_cuda_tests_tags(): return ["local"] @@ -11,16 +9,16 @@ def tf_sycl_tests_tags(): return ["local"] def tf_additional_plugin_deps(): - deps = [] - if WITH_XLA_SUPPORT: - deps.append("//tensorflow/compiler/jit") - return deps + return select({ + "//tensorflow:with_xla_support": ["//tensorflow/compiler/jit"], + "//conditions:default": [], + }) def tf_additional_xla_deps_py(): return [] def tf_additional_license_deps(): - licenses = [] - if WITH_XLA_SUPPORT: - licenses.append("@llvm//:LICENSE.TXT") - return licenses + return select({ + "//tensorflow:with_xla_support": ["@llvm//:LICENSE.TXT"], + "//conditions:default": [], + })