Skip to content

Commit

Permalink
Make configure not create -e files on Mac (tensorflow#8215)
Browse files Browse the repository at this point in the history
There is no cross platform way to use sed -i without backup files that
works in both GNU sed and Darwin sed. So a helper function has been
added to the configure script.

Closes tensorflow#7978
See tensorflow#8202
  • Loading branch information
jart authored and girving committed Mar 8, 2017
1 parent 2e8cf80 commit d53ac1c
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ function bazel_clean_and_fetch() {
-//tensorflow/examples/android/..."
}

function sed_hyphen_i() {
if is_macos; then
sed -i '' "$@"
else
sed -i "$@"
fi
}

# Delete any leftover BUILD files from the Makefile build, which would interfere
# with Bazel parsing.
MAKEFILE_DOWNLOAD_DIR=tensorflow/contrib/makefile/downloads
Expand Down Expand Up @@ -173,9 +181,9 @@ else
fi

if [ "$TF_NEED_JEMALLOC" == "1" ]; then
sed -i -e "s/WITH_JEMALLOC = False/WITH_JEMALLOC = True/" tensorflow/core/platform/default/build_config.bzl
sed_hyphen_i -e "s/WITH_JEMALLOC = False/WITH_JEMALLOC = True/" tensorflow/core/platform/default/build_config.bzl
else
sed -i -e "s/WITH_JEMALLOC = True/WITH_JEMALLOC = False/" tensorflow/core/platform/default/build_config.bzl
sed_hyphen_i -e "s/WITH_JEMALLOC = True/WITH_JEMALLOC = False/" tensorflow/core/platform/default/build_config.bzl
fi

while [ "$TF_NEED_GCP" == "" ]; do
Expand All @@ -202,10 +210,10 @@ if [ "$TF_NEED_GCP" == "1" ]; then
fi

# Update Bazel build configuration.
sed -i -e "s/WITH_GCP_SUPPORT = False/WITH_GCP_SUPPORT = True/" tensorflow/core/platform/default/build_config.bzl
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 -i -e "s/WITH_GCP_SUPPORT = True/WITH_GCP_SUPPORT = False/" tensorflow/core/platform/default/build_config.bzl
sed_hyphen_i -e "s/WITH_GCP_SUPPORT = True/WITH_GCP_SUPPORT = False/" tensorflow/core/platform/default/build_config.bzl
fi

while [ "$TF_NEED_HDFS" == "" ]; do
Expand All @@ -224,10 +232,10 @@ done

if [ "$TF_NEED_HDFS" == "1" ]; then
# Update Bazel build configuration.
sed -i -e "s/WITH_HDFS_SUPPORT = False/WITH_HDFS_SUPPORT = True/" tensorflow/core/platform/default/build_config.bzl
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 -i -e "s/WITH_HDFS_SUPPORT = True/WITH_HDFS_SUPPORT = False/" tensorflow/core/platform/default/build_config.bzl
sed_hyphen_i -e "s/WITH_HDFS_SUPPORT = True/WITH_HDFS_SUPPORT = False/" tensorflow/core/platform/default/build_config.bzl
fi

## Enable XLA.
Expand All @@ -243,10 +251,10 @@ done

if [ "$TF_ENABLE_XLA" == "1" ]; then
# Update Bazel build configuration.
sed -i -e "s/^WITH_XLA_SUPPORT = [FT].*/WITH_XLA_SUPPORT = True/" tensorflow/core/platform/default/build_config_root.bzl
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 -i -e "s/^WITH_XLA_SUPPORT = [FT].*/WITH_XLA_SUPPORT = False/" tensorflow/core/platform/default/build_config_root.bzl
sed_hyphen_i -e "s/^WITH_XLA_SUPPORT = [FT].*/WITH_XLA_SUPPORT = False/" tensorflow/core/platform/default/build_config_root.bzl
fi


Expand Down

0 comments on commit d53ac1c

Please sign in to comment.