Skip to content

Commit 216990f

Browse files
committed
build: patch external tf repo after configured nobuild
1 parent a4e25e2 commit 216990f

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

scripts/patch_tfjava.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def patch_build_sh(path: Path) -> None:
5656
if [[ "${PLATFORM:-}" == "android-arm64" ]]; then
5757
export TF_ANDROID_COMPAT_LIB_DIR="$(pwd)/android-compat-libs"
5858
mkdir -p "${TF_ANDROID_COMPAT_LIB_DIR}"
59-
printf 'INPUT(-lc)\n' > "${TF_ANDROID_COMPAT_LIB_DIR}/libpthread.so"
60-
printf 'INPUT(-lc)\n' > "${TF_ANDROID_COMPAT_LIB_DIR}/librt.so"
59+
printf 'INPUT(-lc)\\n' > "${TF_ANDROID_COMPAT_LIB_DIR}/libpthread.so"
60+
printf 'INPUT(-lc)\\n' > "${TF_ANDROID_COMPAT_LIB_DIR}/librt.so"
6161
# tfjava builds TensorFlow as an external Bazel repository, so TensorFlow's
6262
# own .bazelrc does not inject framework_shared_object=true for us.
6363
export BUILD_FLAGS="--config=android_arm64 --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --define=framework_shared_object=true --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"
@@ -106,8 +106,8 @@ def patch_build_sh(path: Path) -> None:
106106
:java_api_import
107107
)
108108
else
109-
bazel fetch "${BAZEL_TARGETS[@]}"
110-
BAZEL_OUTPUT_BASE="$(bazel info output_base)"
109+
bazel build $BUILD_FLAGS --nobuild "${BAZEL_TARGETS[@]}"
110+
BAZEL_OUTPUT_BASE="$(bazel info $BUILD_FLAGS output_base)"
111111
TF_C_BUILD_FILE="$BAZEL_OUTPUT_BASE/external/org_tensorflow/tensorflow/c/BUILD"
112112
TF_C_BUILD_FILE="$TF_C_BUILD_FILE" python3 - <<'PY'
113113
import os
@@ -333,6 +333,11 @@ def patch_build_sh(path: Path) -> None:
333333
path.write_text(text, encoding="utf-8")
334334
PY
335335
336+
sed -n '/name = "tf_status_internal"/,/^)/p' "$TF_C_BUILD_FILE"
337+
echo '---'
338+
sed -n '/name = "tf_tensor"/,/^)/p' "$TF_C_BUILD_FILE"
339+
echo '---'
340+
336341
EAGER_BUILD_FILE="$BAZEL_OUTPUT_BASE/external/org_tensorflow/tensorflow/core/common_runtime/eager/BUILD"
337342
EAGER_BUILD_FILE="$EAGER_BUILD_FILE" python3 - <<'PY'
338343
import os
@@ -389,7 +394,7 @@ def patch_build_sh(path: Path) -> None:
389394
path.write_text(text, encoding="utf-8")
390395
PY
391396
fi
392-
bazel build $BUILD_FLAGS "${BAZEL_TARGETS[@]}"
397+
bazel build $BUILD_FLAGS --nofetch "${BAZEL_TARGETS[@]}"
393398
"""
394399
text = replace_once(text, old, new, path)
395400

0 commit comments

Comments
 (0)