- 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 :custom_ops_test\n)\nif [[ \"${PLATFORM:-}\" != \"android-arm64\" ]]; then\n BAZEL_TARGETS+=(\n :java_proto_gen_sources\n :java_op_generator\n :java_api_import\n )\nelse\n BAZEL_SRCS=\"$(pwd -P)/bazel-tensorflow-core-api\"\n bazel fetch \"${BAZEL_TARGETS[@]}\"\n TF_C_BUILD_FILE=\"$BAZEL_SRCS/external/org_tensorflow/tensorflow/c/BUILD\"\n TF_C_BUILD_FILE=\"$TF_C_BUILD_FILE\" python3 - <<'PY'\nimport os\nfrom pathlib import Path\n\npath = Path(os.environ[\"TF_C_BUILD_FILE\"])\ntext = path.read_text(encoding=\"utf-8\")\nold = '''cc_library(\n name = \"tf_tensor\",\n srcs = [\"tf_tensor.cc\"],\n hdrs = [\"tf_tensor.h\"],\n visibility = [\"//visibility:public\"],\n deps = select({\n \"//tensorflow:android\": [\n \"//tensorflow/core:android_tensorflow_lib_lite\",\n ],\n \"//conditions:default\": [\n \":tf_datatype\",\n \":tf_status\",\n \":tf_status_helper\",\n \":tf_tensor_internal\",\n \"//tensorflow/core:framework\",\n \"//tensorflow/core:lib\",\n \"//tensorflow/core:protos_all_cc\",\n ],\n }),\n)'''\nnew = '''cc_library(\n name = \"tf_tensor\",\n srcs = [\n \"tf_tensor.cc\",\n \"tf_datatype.h\",\n \"tf_status.h\",\n \"tf_status_helper.h\",\n \"tf_tensor_internal.h\",\n ],\n hdrs = [\"tf_tensor.h\"],\n visibility = [\"//visibility:public\"],\n deps = select({\n \"//tensorflow:android\": [\n \":tf_datatype\",\n \":tf_status\",\n \":tf_status_helper\",\n \":tf_tensor_internal\",\n \"//tensorflow/core:framework\",\n \"//tensorflow/core:lib\",\n \"//tensorflow/core:protos_all_cc\",\n ],\n \"//conditions:default\": [\n \":tf_datatype\",\n \":tf_status\",\n \":tf_status_helper\",\n \":tf_tensor_internal\",\n \"//tensorflow/core:framework\",\n \"//tensorflow/core:lib\",\n \"//tensorflow/core:protos_all_cc\",\n ],\n }),\n)'''\nif old in text:\n text = text.replace(old, new, 1)\nelif '\"tf_status_helper.h\"' not in text:\n raise SystemExit(f\"tf_tensor rule not found in {path}\")\npath.write_text(text, encoding=\"utf-8\")\nPY\nfi\nbazel build $BUILD_FLAGS \"${BAZEL_TARGETS[@]}\"\n"""
0 commit comments