Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sonic] Add OpenCV external #5747

Merged
merged 8 commits into from May 22, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions cmssw-tool-conf.spec
Expand Up @@ -87,6 +87,7 @@ Requires: valgrind-toolfile
Requires: cmsswdata-toolfile
Requires: zstd-toolfile
Requires: hls-toolfile
Requires: opencv-toolfile
Requires: onnxruntime-toolfile

Requires: hdf5-toolfile
Expand Down
27 changes: 27 additions & 0 deletions opencv-toolfile.spec
@@ -0,0 +1,27 @@
### RPM external opencv-toolfile 1.0
Requires: opencv
%prep

%build

%install

mkdir -p %i/etc/scram.d
cat << \EOF_TOOLFILE >%i/etc/scram.d/opencv.xml
<tool name="opencv" version="@TOOL_VERSION@">
<lib name="opencv_core"/>
<client>
<environment name="OPENCV_BASE" default="@TOOL_ROOT@"/>
<environment name="INCLUDE" default="$OPENCV_BASE/include"/>
<environment name="LIBDIR" default="$OPENCV_BASE/lib"/>
<environment name="BINDIR" default="$OPENCV_BASE/bin"/>
</client>
<use name="libpng"/>
<use name="libjpeg-turbo"/>
<use name="zlib"/>
<use name="eigen"/>
<use name="OpenBLAS"/>
</tool>
EOF_TOOLFILE

## IMPORT scram-tools-post
37 changes: 37 additions & 0 deletions opencv.spec
@@ -0,0 +1,37 @@
### RPM external opencv 4.3.0
## INITENV +PATH PYTHON27PATH %{i}/${PYTHON_LIB_SITE_PACKAGES}
## INITENV +PATH PYTHON3PATH %{i}/${PYTHON3_LIB_SITE_PACKAGES}
%define tag 01b2c5a77ca6dbef3baef24ebc0a5984579231d9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we not use a traditionally tagged release version?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1
01b2c5a77ca6dbef3baef24ebc0a5984579231d9 anyway points to tag 4.3.0. So we can just use %{realversion} instead of tag here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

%define branch master
%define github_user opencv

Source: git+https://github.com/%{github_user}/opencv.git?obj=%{branch}/%{tag}&export=%{n}-%{realversion}&output=/%{n}-%{realversion}-%{tag}.tgz
BuildRequires: cmake ninja
Requires: python python3 py2-numpy py3-numpy libpng libjpeg-turbo libtiff zlib eigen OpenBLAS

%prep
%setup -n %{n}-%{realversion}

%build
rm -rf ../build
mkdir ../build
cd ../build

cmake ../%{n}-%{realversion} \
-GNinja \
-DCMAKE_INSTALL_PREFIX="%{i}" \
-DCMAKE_INSTALL_LIBDIR=lib \
-DPYTHON2_EXECUTABLE:FILEPATH="${PYTHON_ROOT}/bin/python" \
-DPYTHON2_INCLUDE_DIR:PATH="${PYTHON_ROOT}/include/python2.7" \
-DPYTHON2_LIBRARY:FILEPATH="${PYTHON_ROOT}/lib/libpython2.7.so" \
-DPYTHON3_EXECUTABLE:FILEPATH="${PYTHON3_ROOT}/bin/python3" \
-DPYTHON3_INCLUDE_DIR:PATH="${PYTHON3_ROOT}/include/python3.8" \
-DPYTHON3_LIBRARY:FILEPATH="${PYTHON3_ROOT}/lib/libpython3.8.so" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="${LIBPNG_ROOT};${LIBTIFF_ROOT};${LIBJPEG_TURBO_ROOT};${ZLIB_ROOT};${PYTHON_ROOT};${PYTHON3_ROOT};${PY2_NUMPY_ROOT};${PY3_NUMPY_ROOT};${EIGEN_ROOT};${OPENBLAS_ROOT}"

ninja -v %{makeprocesses} -l $(getconf _NPROCESSORS_ONLN)

%install
cd ../build
ninja -v %{makeprocesses} -l $(getconf _NPROCESSORS_ONLN) install