Skip to content

Commit

Permalink
Add initial support for Bazel --config replacing ENV vars.
Browse files Browse the repository at this point in the history
Process of removing env variables TF_NEED_GCP, TF_NEED_HDFS,
TF_NEED_GDR, TF_NEED_VERSBS, and TF_ENABLE_XLA. These will be
replaced by Bazel build --config arguments such as
--config=xla.

This CL will make configure support both (env vars and --config)
and will print a deprecation warning if you use env vars.

PiperOrigin-RevId: 168736552
  • Loading branch information
Michael Case authored and tensorflower-gardener committed Sep 14, 2017
1 parent df27bb3 commit 98850a5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def get_var(environ_cp,


def set_build_var(environ_cp, var_name, query_item, option_name,
enabled_by_default):
enabled_by_default, bazel_config_name=None):
"""Set if query_item will be enabled for the build.
Ask user if query_item will be enabled. Default is used if no input is given.
Expand All @@ -372,12 +372,18 @@ def set_build_var(environ_cp, var_name, query_item, option_name,
System".
option_name: string for option to define in .bazelrc.
enabled_by_default: boolean for default behavior.
bazel_config_name: Name for Bazel --config argument to enable build feature.
"""

var = str(int(get_var(environ_cp, var_name, query_item, enabled_by_default)))
environ_cp[var_name] = var
if var == '1':
write_to_bazelrc('build --define %s=true' % option_name)
elif bazel_config_name is not None:
# TODO(mikecase): Migrate all users of configure.py to use --config Bazel
# options and not to set build configs through environment variables.
write_to_bazelrc('build:%s --define %s=true'
% (bazel_config_name, option_name))


def set_action_env_var(environ_cp,
Expand Down Expand Up @@ -978,15 +984,15 @@ def main():
set_build_var(environ_cp, 'TF_NEED_JEMALLOC', 'jemalloc as malloc',
'with_jemalloc', True)
set_build_var(environ_cp, 'TF_NEED_GCP', 'Google Cloud Platform',
'with_gcp_support', False)
'with_gcp_support', False, 'gcp')
set_build_var(environ_cp, 'TF_NEED_HDFS', 'Hadoop File System',
'with_hdfs_support', False)
'with_hdfs_support', False, 'hdfs')
set_build_var(environ_cp, 'TF_ENABLE_XLA', 'XLA JIT', 'with_xla_support',
False)
False, 'xla')
set_build_var(environ_cp, 'TF_NEED_GDR', 'GDR', 'with_gdr_support',
False)
False, 'gdr')
set_build_var(environ_cp, 'TF_NEED_VERBS', 'VERBS', 'with_verbs_support',
False)
False, 'verbs')

set_action_env_var(environ_cp, 'TF_NEED_OPENCL', 'OpenCL', False)
if environ_cp.get('TF_NEED_OPENCL') == '1':
Expand Down

0 comments on commit 98850a5

Please sign in to comment.