Skip to content

Commit

Permalink
Merge pull request #1451 from bhs-world/master
Browse files Browse the repository at this point in the history
Added nuget build for runtime-ubuntu-20.04-x64
  • Loading branch information
shimat committed Jul 23, 2022
2 parents f6b0fbc + 5f18528 commit 16342ee
Show file tree
Hide file tree
Showing 3 changed files with 211 additions and 0 deletions.
169 changes: 169 additions & 0 deletions .github/workflows/ubuntu20.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
name: Ubuntu 20.04

on:
pull_request:
types: [synchronize, opened]
push:
branches:
- master

env:
DEBIAN_FRONTEND: noninteractive
OPENCV_VERSION: 4.6.0

jobs:
build:

runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Install dependencies
run: |
pwd
echo ${GITHUB_WORKSPACE}
current_path=$(pwd)
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends \
apt-transport-https \
software-properties-common \
wget \
unzip \
ca-certificates \
build-essential \
cmake \
git \
libtbb-dev \
libatlas-base-dev \
libgtk2.0-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libdc1394-22-dev \
libxine2-dev \
libv4l-dev \
libtheora-dev \
libvorbis-dev \
libxvidcore-dev \
libopencore-amrnb-dev \
libopencore-amrwb-dev \
libavresample-dev \
x264 \
libtesseract-dev
- name: Cache OpenCV
id: opencv-cache
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/opencv_ubuntu/
key: opencv-${{ env.OPENCV_VERSION }}-rev1

- name: Build OpenCV
if: steps.opencv-cache.outputs.cache-hit != 'true'
run: |
wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip -Oopencv-${OPENCV_VERSION}.zip && unzip opencv-${OPENCV_VERSION}.zip
wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip -Oopencv_contrib-${OPENCV_VERSION}.zip && unzip opencv_contrib-${OPENCV_VERSION}.zip
cd opencv-${OPENCV_VERSION} && mkdir build && cd build
cmake \
-D CMAKE_BUILD_TYPE=Release \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${OPENCV_VERSION}/modules \
-D BUILD_SHARED_LIBS=OFF \
-D ENABLE_CXX11=ON \
-D BUILD_EXAMPLES=OFF \
-D BUILD_DOCS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_JAVA=OFF \
-D BUILD_opencv_apps=OFF \
-D BUILD_opencv_barcode=OFF \
-D BUILD_opencv_java_bindings_generator=OFF \
-D BUILD_opencv_python_bindings_generator=OFF \
-D BUILD_opencv_python_tests=OFF \
-D BUILD_opencv_ts=OFF \
-D BUILD_opencv_js=OFF \
-D BUILD_opencv_js_bindings_generator=OFF \
-D BUILD_opencv_bioinspired=OFF \
-D BUILD_opencv_ccalib=OFF \
-D BUILD_opencv_datasets=OFF \
-D BUILD_opencv_dnn_objdetect=OFF \
-D BUILD_opencv_dpm=OFF \
-D BUILD_opencv_fuzzy=OFF \
-D BUILD_opencv_gapi=ON \
-D BUILD_opencv_intensity_transform=OFF \
-D BUILD_opencv_mcc=OFF \
-D BUILD_opencv_objc_bindings_generator=OFF \
-D BUILD_opencv_rapid=OFF \
-D BUILD_opencv_reg=OFF \
-D BUILD_opencv_stereo=OFF \
-D BUILD_opencv_structured_light=OFF \
-D BUILD_opencv_surface_matching=OFF \
-D BUILD_opencv_wechat_qrcode=ON \
-D BUILD_opencv_videostab=OFF \
-D WITH_GSTREAMER=OFF \
-D WITH_ADE=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D CMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/opencv_ubuntu ..
make -j2
make install
sudo ldconfig
cd ${GITHUB_WORKSPACE}
ls
- name: Build OpenCvSharpExtern
run: |
ls ${GITHUB_WORKSPACE}/opencv_ubuntu
echo "-----"
ls ${GITHUB_WORKSPACE}/opencv_ubuntu/lib
echo "-----"
mkdir src/build && cd $_
cmake -D CMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/opencv_ubuntu ..
make -j2
ls OpenCvSharpExtern
cp OpenCvSharpExtern/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/nuget/
ldd OpenCvSharpExtern/libOpenCvSharpExtern.so
- name: Check OpenCvSharpExtern
run: |
cd ${GITHUB_WORKSPACE}/nuget/
ldd libOpenCvSharpExtern.so
nm libOpenCvSharpExtern.so
echo -ne "#include <stdio.h> \n int core_Mat_sizeof(); int main(){ int i = core_Mat_sizeof(); printf(\"sizeof(Mat) = %d\", i); return 0; }" > test.c
gcc -I./ -L./ test.c -o test -lOpenCvSharpExtern
LD_LIBRARY_PATH=. ./test
- name: Install .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'

- name: Create NuGet package
env:
BETA: ""
run: |
yyyymmdd=`date '+%Y%m%d'`
echo $yyyymmdd
sed -E --in-place=.bak "s/<version>[0-9]\.[0-9]{1,2}\.[0-9]{1,2}.[0-9]{8}(-beta[0-9]*)?<\/version>/<version>${OPENCV_VERSION}.${yyyymmdd}${BETA}<\/version>/" ${GITHUB_WORKSPACE}/nuget/OpenCvSharp4.runtime.ubuntu.20.04-x64.nuspec
cat ${GITHUB_WORKSPACE}/nuget/OpenCvSharp4.runtime.ubuntu.20.04-x64.nuspec
dotnet pack ${GITHUB_WORKSPACE}/nuget/OpenCvSharp4.runtime.ubuntu.20.04-x64.csproj -o ${GITHUB_WORKSPACE}/artifacts_ubuntu
ls ${GITHUB_WORKSPACE}/artifacts_ubuntu
- uses: actions/upload-artifact@v1
with:
name: artifacts_ubuntu_20
path: artifacts_ubuntu

- name: Test
run: |
cd ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests
dotnet build -c Release -f net6.0
cp ${GITHUB_WORKSPACE}/nuget/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests/bin/Release/net6.0/
cp ${GITHUB_WORKSPACE}/nuget/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests/
sudo cp ${GITHUB_WORKSPACE}/nuget/libOpenCvSharpExtern.so /usr/lib/
# ls ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests/bin/Release/net6.0/
# ls
LD_LIBRARY_PATH=. dotnet test OpenCvSharp.Tests.csproj -c Release -f net6.0 --runtime ubuntu.20.04-x64 --logger "trx;LogFileName=test-results.trx" < /dev/null
# ls
# ls TestResults
12 changes: 12 additions & 0 deletions nuget/OpenCvSharp4.runtime.ubuntu.20.04-x64.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp2.1;</TargetFrameworks>
<NoBuild>true</NoBuild>
<IncludeBuildOutput>false</IncludeBuildOutput>
<NuspecFile>OpenCvSharp4.runtime.ubuntu.20.04-x64.nuspec</NuspecFile>
<NuspecProperties></NuspecProperties>
<NuspecBasePath></NuspecBasePath>
<!--<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>-->
</PropertyGroup>
</Project>
30 changes: 30 additions & 0 deletions nuget/OpenCvSharp4.runtime.ubuntu.20.04-x64.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>OpenCvSharp4.runtime.ubuntu.20.04-x64</id>
<version>4.6.0.20220608</version>
<title>OpenCvSharp native bindings for ubuntu.20.04-x64</title>
<authors>shimat</authors>
<license type="expression">Apache-2.0</license>
<!--<licenseUrl>https://opensource.org/licenses/BSD-3-Clause</licenseUrl>-->
<projectUrl>https://github.com/shimat/opencvsharp</projectUrl>
<iconUrl>https://raw.githubusercontent.com/shimat/opencvsharp/master/nuget/icon/opencvsharp.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Internal implementation package for OpenCvSharp to work on Ubuntu 20.04</description>
<summary>Internal implementation package for OpenCvSharp to work on Ubuntu 20.04</summary>
<releaseNotes></releaseNotes>
<copyright>Copyright 2008-2019</copyright>
<tags>Image Processing OpenCV Wrapper FFI opencvsharp</tags>
<repository type="git" url="https://github.com/shimat/opencvsharp.git" />
<dependencies>
<group targetFramework="netstandard2.0"></group>
<group targetFramework="netstandard2.1"></group>
<group targetFramework="netcoreapp3.1"></group>
</dependencies>
<frameworkAssemblies>
</frameworkAssemblies>
</metadata>
<files>
<file src="libOpenCvSharpExtern.so" target="runtimes/ubuntu.20.04-x64/native" />
</files>
</package>

0 comments on commit 16342ee

Please sign in to comment.