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.
This commit is contained in:
Edward Chen 2024-08-16 11:21:09 -07:00 committed by GitHub
parent a4bec3d374
commit 63e8849992
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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: