You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add the missing Android log linker flag, skip host-only op generation during the android-arm64 cross-build, and cache Maven/Bazel state so reruns are much faster.
old="""# Allows us to use ccache with Bazel on Mac\nexport BAZEL_USE_CPP_ONLY_TOOLCHAIN=1\n\nexport BAZEL_VC=\"${VCINSTALLDIR:-}\"\nif [[ -d $BAZEL_VC ]]; then\n # Work around compiler issues on Windows documented mainly in configure.py but also elsewhere\n export BUILD_FLAGS=\"--copt=//arch:AVX `#--copt=//arch:AVX2` --copt=-DWIN32_LEAN_AND_MEAN --host_copt=-DWIN32_LEAN_AND_MEAN --copt=-DNOGDI --host_copt=-DNOGDI --copt=-D_USE_MATH_DEFINES --host_copt=-D_USE_MATH_DEFINES --define=override_eigen_strong_inline=true\"\n # https://software.intel.com/en-us/articles/intel-optimization-for-tensorflow-installation-guide#wind_B_S\n export PATH=$PATH:$(pwd)/bazel-tensorflow-core-api/external/mkl_windows/lib/\n export PYTHON_BIN_PATH=$(which python.exe)\nelse\n export BUILD_FLAGS=\"--copt=-msse4.1 --copt=-msse4.2 --copt=-mavx `#--copt=-mavx2 --copt=-mfma` --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 --linkopt=-lstdc++ --host_linkopt=-lstdc++\"\n export PYTHON_BIN_PATH=$(which python3)\nfi\n"""
27
-
new="""# Allows us to use ccache with Bazel on Mac, but Android needs Bazel's Android crosstool.\nif [[ \"${PLATFORM:-}\" != \"android-arm64\" ]]; then\n export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1\nfi\n\nexport BAZEL_VC=\"${VCINSTALLDIR:-}\"\nif [[ \"${PLATFORM:-}\" == \"android-arm64\" ]]; then\n export TF_ANDROID_COMPAT_LIB_DIR=\"$(pwd)/android-compat-libs\"\n mkdir -p \"${TF_ANDROID_COMPAT_LIB_DIR}\"\n printf 'INPUT(-lc)\\n' > \"${TF_ANDROID_COMPAT_LIB_DIR}/libpthread.so\"\n printf 'INPUT(-lc)\\n' > \"${TF_ANDROID_COMPAT_LIB_DIR}/librt.so\"\n export BUILD_FLAGS=\"--config=android_arm64 --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --copt=-DANDROID --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 --cxxopt=-include --cxxopt=cstdint --host_cxxopt=-include --host_cxxopt=cstdint --copt=-Wno-error=array-parameter --host_copt=-Wno-error=array-parameter --copt=-Wno-error=array-bounds --host_copt=-Wno-error=array-bounds --linkopt=-L${TF_ANDROID_COMPAT_LIB_DIR}\"\n export PYTHON_BIN_PATH=$(which python3)\nelif [[ -d $BAZEL_VC ]]; then\n # Work around compiler issues on Windows documented mainly in configure.py but also elsewhere\n export BUILD_FLAGS=\"--copt=//arch:AVX `#--copt=//arch:AVX2` --copt=-DWIN32_LEAN_AND_MEAN --host_copt=-DWIN32_LEAN_AND_MEAN --copt=-DNOGDI --host_copt=-DNOGDI --copt=-D_USE_MATH_DEFINES --host_copt=-D_USE_MATH_DEFINES --define=override_eigen_strong_inline=true\"\n # https://software.intel.com/en-us/articles/intel-optimization-for-tensorflow-installation-guide#wind_B_S\n export PATH=$PATH:$(pwd)/bazel-tensorflow-core-api/external/mkl_windows/lib/\n export PYTHON_BIN_PATH=$(which python.exe)\nelse\n export BUILD_FLAGS=\"--copt=-msse4.1 --copt=-msse4.2 --copt=-mavx `#--copt=-mavx2 --copt=-mfma` --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 --linkopt=-lstdc++ --host_linkopt=-lstdc++\"\n export PYTHON_BIN_PATH=$(which python3)\nfi\n"""
27
+
new="""# Allows us to use ccache with Bazel on Mac, but Android needs Bazel's Android crosstool.\nif [[ \"${PLATFORM:-}\" != \"android-arm64\" ]]; then\n export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1\nfi\n\nexport BAZEL_VC=\"${VCINSTALLDIR:-}\"\nif [[ \"${PLATFORM:-}\" == \"android-arm64\" ]]; then\n export TF_ANDROID_COMPAT_LIB_DIR=\"$(pwd)/android-compat-libs\"\n mkdir -p \"${TF_ANDROID_COMPAT_LIB_DIR}\"\n printf 'INPUT(-lc)\\n' > \"${TF_ANDROID_COMPAT_LIB_DIR}/libpthread.so\"\n printf 'INPUT(-lc)\\n' > \"${TF_ANDROID_COMPAT_LIB_DIR}/librt.so\"\n export BUILD_FLAGS=\"--config=android_arm64 --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --copt=-DANDROID --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 --cxxopt=-include --cxxopt=cstdint --host_cxxopt=-include --host_cxxopt=cstdint --copt=-Wno-error=array-parameter --host_copt=-Wno-error=array-parameter --copt=-Wno-error=array-bounds --host_copt=-Wno-error=array-bounds --linkopt=-L${TF_ANDROID_COMPAT_LIB_DIR} --linkopt=-llog\"\n export PYTHON_BIN_PATH=$(which python3)\nelif [[ -d $BAZEL_VC ]]; then\n # Work around compiler issues on Windows documented mainly in configure.py but also elsewhere\n export BUILD_FLAGS=\"--copt=//arch:AVX `#--copt=//arch:AVX2` --copt=-DWIN32_LEAN_AND_MEAN --host_copt=-DWIN32_LEAN_AND_MEAN --copt=-DNOGDI --host_copt=-DNOGDI --copt=-D_USE_MATH_DEFINES --host_copt=-D_USE_MATH_DEFINES --define=override_eigen_strong_inline=true\"\n # https://software.intel.com/en-us/articles/intel-optimization-for-tensorflow-installation-guide#wind_B_S\n export PATH=$PATH:$(pwd)/bazel-tensorflow-core-api/external/mkl_windows/lib/\n export PYTHON_BIN_PATH=$(which python.exe)\nelse\n export BUILD_FLAGS=\"--copt=-msse4.1 --copt=-msse4.2 --copt=-mavx `#--copt=-mavx2 --copt=-mfma` --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 --linkopt=-lstdc++ --host_linkopt=-lstdc++\"\n export PYTHON_BIN_PATH=$(which python3)\nfi\n\nif [[ -n \"${BAZEL_REPOSITORY_CACHE:-}\" ]]; then\n export BUILD_FLAGS=\"$BUILD_FLAGS --repository_cache=${BAZEL_REPOSITORY_CACHE}\"\nfi\nif [[ -n \"${BAZEL_DISK_CACHE:-}\" ]]; then\n export BUILD_FLAGS=\"$BUILD_FLAGS --disk_cache=${BAZEL_DISK_CACHE}\"\nfi\n"""
28
+
text=replace_once(text, old, new, path)
29
+
old="""# Build C API of TensorFlow itself including a target to generate ops for Java\nbazel build $BUILD_FLAGS \\\n @org_tensorflow//tensorflow:tensorflow \\\n @org_tensorflow//tensorflow/tools/lib_package:jnilicenses_generate \\\n :java_proto_gen_sources \\\n :java_op_generator \\\n :java_api_import \\\n :custom_ops_test\n"""
30
+
new="""# Build C API of TensorFlow itself. Android cross-builds reuse the checked-in\n# generated Java sources because the generator is a host tool that loads the\n# produced TensorFlow library at build time.\nBAZEL_TARGETS=(\n @org_tensorflow//tensorflow:tensorflow\n @org_tensorflow//tensorflow/tools/lib_package:jnilicenses_generate\n :java_proto_gen_sources\n :custom_ops_test\n)\nif [[ \"${PLATFORM:-}\" != \"android-arm64\" ]]; then\n BAZEL_TARGETS+=(\n :java_op_generator\n :java_api_import\n )\nfi\nbazel build $BUILD_FLAGS \"${BAZEL_TARGETS[@]}\"\n"""
0 commit comments