Skip to content

Commit

Permalink
Allow to build operators with run script
Browse files Browse the repository at this point in the history
Also:
- verify input validity using the improve listing from the last commit
- allow passing a path to the app/operator dir, for improve UX by leveraging
terminal autocompletion

Signed-off-by: Alexis Girault <[email protected]>
  • Loading branch information
agirault committed Dec 13, 2024
1 parent 7d08270 commit ba23d27
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -666,57 +666,67 @@ build() {
fi
done

echo "Building Holohub"

# Application to build
# Application or operator to build
if [ "$1" == "" ]; then
print_error "Please specify which application to build."
echo "You can run ./run list for a full list of applications."
print_error "Please specify which operator or application to build."
echo "You can run ./run list for a full list of options."
exit 1
fi
project=$(basename "$1")
opt_prefix=""
is_app=false
if list_apps | grep -Fxq "$project"; then
opt_prefix="-D APP_"
is_app=true
elif list_operators | grep -Fxq "$project"; then
opt_prefix="-D OP_"
else
print_error "Unknown application or operator: $1"
echo "You can run ./run list for a full list of options."
exit 1
fi
echo "Building $project"
opt_flag="$opt_prefix$project:BOOL=1"

# Assign default build path
if [ "$build_path" == "" ]; then
build_path="build/$1"
build_path="build/$project"
fi

local app_source_root_path
if [ $benchmark == true ]; then
app_source_root_path=$(get_app_source_root_dir $1)
if [ $benchmark == true ] && [ $is_app == true ]; then
app_source_root_path=$(get_app_source_root_dir $project)
run_command benchmarks/holoscan_flow_benchmarking/patch_application.sh ${app_source_root_path}
fi

echo "Building $1 application"
application="-DAPP_$1=1"

# We define the python path to make sure we grab the right one
cmake_extra_args="--no-warn-unused-cli -DPython3_EXECUTABLE=${HOLOHUB_PY_EXE} -DPython3_ROOT_DIR=${HOLOHUB_PY_LIB}"
cmake_extra_args="--no-warn-unused-cli -D Python3_EXECUTABLE=${HOLOHUB_PY_EXE} -D Python3_ROOT_DIR=${HOLOHUB_PY_LIB}"

# We set the data directory to be outside the build directory
cmake_extra_args="$cmake_extra_args $configure_args -DHOLOHUB_DATA_DIR:PATH=${SCRIPT_DIR}/data"
cmake_extra_args="$cmake_extra_args $configure_args -D HOLOHUB_DATA_DIR:PATH=${SCRIPT_DIR}/data"

# Sets the default path for cuda
export PATH=$PATH:/usr/local/cuda/bin
run_command cmake -S . -B ${build_path} ${cmake_extra_args} -DCMAKE_BUILD_TYPE=${build_type} ${holoscan_sdk} ${application}
run_command cmake -S . -B ${build_path} ${cmake_extra_args} -D CMAKE_BUILD_TYPE=${build_type} ${holoscan_sdk} ${opt_flag}
ret=$?
check_exit_code $ret "Error building application."
check_exit_code $ret "Error building $project."
# Job concurrency determined by the underlying build tool unless a number is specified
run_command cmake --build ${build_path} -j ${parallel_jobs}
ret=$?
check_exit_code $ret "Error building application."
check_exit_code $ret "Error building $project."

if [ $install == true ]; then
run_command cmake --install ${build_path}
ret=$?
check_exit_code $ret "Error installing application."
check_exit_code $ret "Error installing $project."
fi

if [ $benchmark == true ]; then
if [ $benchmark == true ] && [ $is_app == true ]; then
app_source_root_path=$(get_app_source_root_dir $1)
run_command benchmarks/holoscan_flow_benchmarking/restore_application.sh ${app_source_root_path}
fi

echo "Holohub build done."
echo "Build done."
}


Expand Down Expand Up @@ -937,7 +947,7 @@ autocompletion_list() {
for d in ${apps}; do
local appname=$(dirname $d | grep -Po '^'${SCRIPT_DIR}/applications/'\K[^ ]*')
filename="${appname%/*}"
# Deal with projectectories of applications
# Deal with subdirectories of applications
echo "${filename##*/}"
done
echo "build launch clear_cache cpp python install_lint_deps lint setup"
Expand Down

0 comments on commit ba23d27

Please sign in to comment.