From 63e88499923cc89bb01b9b6844ffe7bb79a0149d Mon Sep 17 00:00:00 2001 From: Edward Chen <18449977+edgchen1@users.noreply.github.com> Date: Fri, 16 Aug 2024 11:21:09 -0700 Subject: [PATCH] build_aar_package.py - Check that executable is present before trying to copy it. (#21730) Check that executable is present before trying to copy it. Accommodate builds where we skip building the test executables. --- tools/ci_build/github/android/build_aar_package.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/ci_build/github/android/build_aar_package.py b/tools/ci_build/github/android/build_aar_package.py index ee76bab762552..036db703ccf27 100644 --- a/tools/ci_build/github/android/build_aar_package.py +++ b/tools/ci_build/github/android/build_aar_package.py @@ -118,11 +118,16 @@ def _build_aar(args): os.symlink(os.path.join(abi_build_dir, build_config, lib_name), target_lib_name) # copy executables for each abi, in case we want to publish those as well + # some of them might not exist, e.g., if we skip building the tests abi_exe_dir = os.path.join(exe_dir, abi) for exe_name in ["libonnxruntime.so", "onnxruntime_perf_test", "onnx_test_runner"]: + src_exe_path = os.path.join(abi_build_dir, build_config, exe_name) + if not os.path.exists(src_exe_path): + continue + os.makedirs(abi_exe_dir, exist_ok=True) - target_exe_name = os.path.join(abi_exe_dir, exe_name) - shutil.copyfile(os.path.join(abi_build_dir, build_config, exe_name), target_exe_name) + dest_exe_path = os.path.join(abi_exe_dir, exe_name) + shutil.copyfile(src_exe_path, dest_exe_path) # we only need to define the header files path once if not header_files_path: