Skip to content

Commit d53ac1c

Browse files
jartgirving
authored andcommitted
Make configure not create -e files on Mac (tensorflow#8215)
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
1 parent 2e8cf80 commit d53ac1c

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

configure

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ function bazel_clean_and_fetch() {
4545
-//tensorflow/examples/android/..."
4646
}
4747

48+
function sed_hyphen_i() {
49+
if is_macos; then
50+
sed -i '' "$@"
51+
else
52+
sed -i "$@"
53+
fi
54+
}
55+
4856
# Delete any leftover BUILD files from the Makefile build, which would interfere
4957
# with Bazel parsing.
5058
MAKEFILE_DOWNLOAD_DIR=tensorflow/contrib/makefile/downloads
@@ -173,9 +181,9 @@ else
173181
fi
174182

175183
if [ "$TF_NEED_JEMALLOC" == "1" ]; then
176-
sed -i -e "s/WITH_JEMALLOC = False/WITH_JEMALLOC = True/" tensorflow/core/platform/default/build_config.bzl
184+
sed_hyphen_i -e "s/WITH_JEMALLOC = False/WITH_JEMALLOC = True/" tensorflow/core/platform/default/build_config.bzl
177185
else
178-
sed -i -e "s/WITH_JEMALLOC = True/WITH_JEMALLOC = False/" tensorflow/core/platform/default/build_config.bzl
186+
sed_hyphen_i -e "s/WITH_JEMALLOC = True/WITH_JEMALLOC = False/" tensorflow/core/platform/default/build_config.bzl
179187
fi
180188

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

204212
# Update Bazel build configuration.
205-
sed -i -e "s/WITH_GCP_SUPPORT = False/WITH_GCP_SUPPORT = True/" tensorflow/core/platform/default/build_config.bzl
213+
sed_hyphen_i -e "s/WITH_GCP_SUPPORT = False/WITH_GCP_SUPPORT = True/" tensorflow/core/platform/default/build_config.bzl
206214
else
207215
# Update Bazel build configuration.
208-
sed -i -e "s/WITH_GCP_SUPPORT = True/WITH_GCP_SUPPORT = False/" tensorflow/core/platform/default/build_config.bzl
216+
sed_hyphen_i -e "s/WITH_GCP_SUPPORT = True/WITH_GCP_SUPPORT = False/" tensorflow/core/platform/default/build_config.bzl
209217
fi
210218

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

225233
if [ "$TF_NEED_HDFS" == "1" ]; then
226234
# Update Bazel build configuration.
227-
sed -i -e "s/WITH_HDFS_SUPPORT = False/WITH_HDFS_SUPPORT = True/" tensorflow/core/platform/default/build_config.bzl
235+
sed_hyphen_i -e "s/WITH_HDFS_SUPPORT = False/WITH_HDFS_SUPPORT = True/" tensorflow/core/platform/default/build_config.bzl
228236
else
229237
# Update Bazel build configuration.
230-
sed -i -e "s/WITH_HDFS_SUPPORT = True/WITH_HDFS_SUPPORT = False/" tensorflow/core/platform/default/build_config.bzl
238+
sed_hyphen_i -e "s/WITH_HDFS_SUPPORT = True/WITH_HDFS_SUPPORT = False/" tensorflow/core/platform/default/build_config.bzl
231239
fi
232240

233241
## Enable XLA.
@@ -243,10 +251,10 @@ done
243251

244252
if [ "$TF_ENABLE_XLA" == "1" ]; then
245253
# Update Bazel build configuration.
246-
sed -i -e "s/^WITH_XLA_SUPPORT = [FT].*/WITH_XLA_SUPPORT = True/" tensorflow/core/platform/default/build_config_root.bzl
254+
sed_hyphen_i -e "s/^WITH_XLA_SUPPORT = [FT].*/WITH_XLA_SUPPORT = True/" tensorflow/core/platform/default/build_config_root.bzl
247255
else
248256
# Update Bazel build configuration.
249-
sed -i -e "s/^WITH_XLA_SUPPORT = [FT].*/WITH_XLA_SUPPORT = False/" tensorflow/core/platform/default/build_config_root.bzl
257+
sed_hyphen_i -e "s/^WITH_XLA_SUPPORT = [FT].*/WITH_XLA_SUPPORT = False/" tensorflow/core/platform/default/build_config_root.bzl
250258
fi
251259

252260

0 commit comments

Comments
 (0)