Skip to content

Commit

Permalink
Fix re-compilation issue and add CI test (#3)
Browse files Browse the repository at this point in the history
* Force build despite local installation

Signed-off-by: Chen Bainian <[email protected]>

* Add CI build

Signed-off-by: Chen Bainian <[email protected]>

* Add missing dependencies

Signed-off-by: Chen Bainian <[email protected]>

* Only test foxy environment in CI

Signed-off-by: Chen Bainian <[email protected]>
---------

Signed-off-by: Chen Bainian <[email protected]>
  • Loading branch information
Briancbn authored Feb 8, 2024
1 parent 0b7f34a commit 837c92c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 41 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on: [push, pull_request]

jobs:
industrial_ci:
strategy:
matrix:
env:
- {ROS_DISTRO: foxy, ROS_REPO: main}
- {ROS_DISTRO: foxy, ROS_REPO: testing}
env:
CCACHE_DIR: ~/.ccache
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
# step up caching
- uses: actions/cache@v2
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ matrix.env.ROS_DISTRO }}-${{ matrix.env.ROS_REPO }}
# Run industrial_ci
- uses: 'ros-industrial/industrial_ci@master'
env: ${{matrix.env}}
40 changes: 13 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ cmake_minimum_required(VERSION 3.13)

project(epd_onnxruntime_vendor)

option(FORCE_BUILD_VENDOR_PKG
"Build onnxruntime from source, even if system-installed package is available"
OFF)

find_package(ament_cmake REQUIRED)

macro(build_onnxruntime)
Expand Down Expand Up @@ -69,34 +65,24 @@ macro(build_onnxruntime)
)
endmacro()

# NO_CMAKE_PACKAGE_REGISTRY used to avoid finding the library downloaded in WORKSPACE B
# TODO(Briancbn): Verify force build vendor pkg with existing installation in /usr/local/lib
find_library(onnxruntime_LIBRARIES NAMES onnxruntime PATHS /usr/local/lib)

if(FORCE_BUILD_VENDOR_PKG OR onnxruntime_LIBRARIES STREQUAL onnxruntime_LIBRARIES-NOTFOUND)
build_onnxruntime()
build_onnxruntime()

# TODO(Briancbn): environment variables in Windows
if(WIN32)
ament_environment_hooks(env_hook/epd_onnxruntime_vendor_library_path.bat)
set(ENV_VAR_NAME "PATH")
set(ENV_VAR_VALUE "opt\\epd_onnxruntime_vendor\\bin")
# TODO(Briancbn): environment variables in Windows
if(WIN32)
ament_environment_hooks(env_hook/epd_onnxruntime_vendor_library_path.bat)
set(ENV_VAR_NAME "PATH")
set(ENV_VAR_VALUE "opt\\epd_onnxruntime_vendor\\bin")
else()
ament_environment_hooks(env_hook/epd_onnxruntime_vendor_library_path.sh)
if(APPLE)
set(ENV_VAR_NAME "DYLD_LIBRARY_PATH")
else()
ament_environment_hooks(env_hook/epd_onnxruntime_vendor_library_path.sh)
if(APPLE)
set(ENV_VAR_NAME "DYLD_LIBRARY_PATH")
else()
set(ENV_VAR_NAME "LD_LIBRARY_PATH")
endif()
set(ENV_VAR_VALUE "opt/epd_onnxruntime_vendor/lib")
set(ENV_VAR_NAME "LD_LIBRARY_PATH")
endif()
ament_environment_hooks(env_hook/epd_onnxruntime_vendor_library_path.dsv.in)
else()
message(WARNING "Found onnxruntime in path ${onnxruntime_LIBRARIES}")
set(ENV_VAR_VALUE "opt/epd_onnxruntime_vendor/lib")
endif()
ament_environment_hooks(env_hook/epd_onnxruntime_vendor_library_path.dsv.in)

ament_package(
CONFIG_EXTRAS "epd_onnxruntime_vendor-extras.cmake.in"
)


21 changes: 7 additions & 14 deletions epd_onnxruntime_vendor-extras.cmake.in
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
# Check local installation first
find_library(onnxruntime_LIBRARIES NAMES onnxruntime PATHS /usr/local/lib)
if(onnxruntime_LIBRARIES STREQUAL onnxruntime_LIBRARIES-NOTFOUND)
# add the local Modules directory to the modules path
# ONNXConfig.cmake is ignored for now, since it is not used by EPD
# TODO(anyone): Verify if ONNXConfig.cmake is needed as find_package(ONNX)
find_library(onnxruntime_LIBRARIES NAMES onnxruntime PATHS ${@PROJECT_NAME@_DIR}/../../../opt/epd_onnxruntime_vendor/lib)
# add the local Modules directory to the modules path
# ONNXConfig.cmake is ignored for now, since it is not used by EPD
# TODO(anyone): Verify if ONNXConfig.cmake is needed as find_package(ONNX)
find_library(onnxruntime_LIBRARIES NAMES onnxruntime PATHS ${@PROJECT_NAME@_DIR}/../../../opt/epd_onnxruntime_vendor/lib)

set(onnxruntime_INSTALL_PREFIX "${@PROJECT_NAME@_DIR}/../../../opt/epd_onnxruntime_vendor")
else()
# Using local installation
set(onnxruntime_INSTALL_PREFIX "/usr/local")
endif()
set(onnxruntime_opt "${@PROJECT_NAME@_DIR}/../../../opt/epd_onnxruntime_vendor")

message(WARNING "Find onnxruntime libraries at" ${onnxruntime_LIBRARIES})

set(epd_onnxruntime_vendor_LIBRARIES ${onnxruntime_LIBRARIES})
set(epd_onnxruntime_vendor_INCLUDE_DIRS
${onnxruntime_INSTALL_PREFIX}/include
${onnxruntime_INSTALL_PREFIX}/include/onnxruntime/core/session
${onnxruntime_opt}/include
${onnxruntime_opt}/include/onnxruntime/core/session
)
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<license>Apache License 2.0</license> <!-- the contents of this package are Apache 2.0 -->

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>git</buildtool_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down

0 comments on commit 837c92c

Please sign in to comment.