Updates the configure Python script to support building Bazel rules on Apple platforms.
PiperOrigin-RevId: 234053872
diff --git a/configure.py b/configure.py
index 14fca1f..61fa9fe 100644
--- a/configure.py
+++ b/configure.py
@@ -55,6 +55,12 @@
'lib64/', 'lib/powerpc64le-linux-gnu/', 'lib/x86_64-linux-gnu/', ''
]
+# List of files to be configured for using Bazel on Apple platforms.
+APPLE_BAZEL_FILES = [
+ 'tensorflow/lite/experimental/objc/BUILD',
+ 'tensorflow/lite/experimental/swift/BUILD'
+]
+
if platform.machine() == 'ppc64le':
_DEFAULT_TENSORRT_PATH_LINUX = '/usr/lib/powerpc64le-linux-gnu/'
else:
@@ -1534,6 +1540,23 @@
print('\t--config=%-12s\t# %s' % (name, help_text))
+def configure_apple_bazel_rules():
+ """Configures Bazel rules for building on Apple platforms.
+
+ Enables analyzing and building Apple Bazel rules on Apple platforms. This
+ function will only be executed if `is_macos()` is true.
+ """
+ if not is_macos():
+ return
+ for filepath in APPLE_BAZEL_FILES:
+ print(
+ 'Configuring %s file to analyze and build Bazel rules on Apple platforms.'
+ % filepath)
+ existing_filepath = os.path.join(_TF_WORKSPACE_ROOT, filepath + '.apple')
+ renamed_filepath = os.path.join(_TF_WORKSPACE_ROOT, filepath)
+ os.rename(existing_filepath, renamed_filepath)
+
+
def main():
global _TF_WORKSPACE_ROOT
global _TF_BAZELRC
@@ -1574,6 +1597,8 @@
if is_macos():
environ_cp['TF_NEED_TENSORRT'] = '0'
+ else:
+ environ_cp['TF_CONFIGURE_APPLE_BAZEL_RULES'] = '0'
# The numpy package on ppc64le uses OpenBLAS which has multi-threading
# issues that lead to incorrect answers. Set OMP_NUM_THREADS=1 at
@@ -1676,6 +1701,14 @@
create_android_ndk_rule(environ_cp)
create_android_sdk_rule(environ_cp)
+ if get_var(
+ environ_cp, 'TF_CONFIGURE_APPLE_BAZEL_RULES',
+ 'Configure Bazel rules for Apple platforms', False,
+ ('Would you like to configure Bazel rules for building on Apple platforms?'
+ ), 'Configuring Bazel rules for Apple platforms.',
+ 'Not configuring Bazel rules for Apple platforms.'):
+ configure_apple_bazel_rules()
+
print('Preconfigured Bazel build configs. You can use any of the below by '
'adding "--config=<>" to your build command. See .bazelrc for more '
'details.')