Skip to content

Commit

Permalink
Bump CI
Browse files Browse the repository at this point in the history
  • Loading branch information
twistedfall committed Jul 22, 2024
1 parent 0389f5c commit 3bcc741
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 9 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/opencv-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,21 @@ jobs:
matrix:
os-image:
- ubuntu-22.04
- macos-13
- macos-14
opencv-version:
- 3.4.20
- 4.10.0
linkage:
- dynamic
include:
- os-image: ubuntu-22.04
opencv-version: 4.10.0
linkage: static
- os-image: ubuntu-22.04
opencv-version: 3.4.20
linkage: dynamic
- os-image: macos-13
opencv-version: 3.4.20
linkage: dynamic
runs-on: ${{ matrix.os-image }}
env:
Atlas_ROOT_DIR: /usr/include/ # for cmake to find lapacke.h
Expand Down
6 changes: 5 additions & 1 deletion build/cmake_probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ pub struct LinkLib(pub Linkage, pub String);
impl LinkLib {
#[inline]
pub fn emit_cargo_rustc_link(&self) -> String {
format!("cargo:rustc-link-lib={}{}", self.0.as_cargo_rustc_link_spec(), self.1) // replace with cargo:: syntax when MSRV is 1.77
format!(
"cargo:rustc-link-lib={}{}",
self.0.as_cargo_rustc_link_spec_no_static(),
self.1
) // replace with cargo:: syntax when MSRV is 1.77
}

/// Returns Some(new_file_name) if some parts of the filename were removed, None otherwise
Expand Down
13 changes: 10 additions & 3 deletions build/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,18 @@ pub enum Linkage {

impl Linkage {
pub fn as_cargo_rustc_link_spec(self) -> &'static str {
// fixme: specifying static linkage breaks things in CI
match self {
Self::Default => "",
Self::Dynamic => "", // "dylib=",
Self::Static => "", // "static=",
Self::Dynamic => "dylib=",
Self::Static => "static=",
Self::Framework => "framework=",
}
}

pub fn as_cargo_rustc_link_spec_no_static(self) -> &'static str {
// fixme: specifying static linkage breaks things in CI
match self {
Self::Default | Self::Dynamic | Self::Static => "",
Self::Framework => "framework=",
}
}
Expand Down
1 change: 1 addition & 0 deletions ci/install-macos-brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ brew upgrade --force --display-times
brew list --versions
brew -v install --force --display-times opencv"$BREW_OPENCV_VERSION"
brew link opencv"$BREW_OPENCV_VERSION"
rustup-init -y
8 changes: 8 additions & 0 deletions ci/install-macos-framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -xeu

macos_version="$(sw_vers -productVersion)"

dist_dir="$HOME/dist/"
base_dir="$HOME/build/opencv/"
build_dir="$base_dir/opencv-$OPENCV_VERSION-build/"
Expand All @@ -23,7 +25,13 @@ if [ ! -d "$opencv_contrib_src" ]; then
curl -L "https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.tar.gz" | tar -xz -C "$dist_dir"
fi

if [[ "$OPENCV_VERSION" == "3.4.20" ]]; then # old OpenCV doesn't support choosing archs
arch_arg=
else
arch_arg="--macos_archs $(uname -m)"
fi
python "$opencv_src/platforms/osx/build_framework.py" \
--contrib "$opencv_contrib_src" \
--enable_nonfree \
$arch_arg \
"$build_dir"
13 changes: 10 additions & 3 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,17 @@ elif [[ "$os_family" == "macOS" ]]; then
elif [[ "${BREW_OPENCV_VERSION:-}" != "" ]]; then # brew build
true
else # framework build
opencv_build_path="$HOME/build/opencv/opencv-$OPENCV_VERSION-build"
export DYLD_FALLBACK_LIBRARY_PATH="$DYLD_FALLBACK_LIBRARY_PATH:$opencv_build_path/build/build-$(uname -m)-macosx/install/lib/"
clang_dir="$(clang --print-search-dirs | awk -F= '/^libraries: =/ { print $2 }')"
export OPENCV_LINK_PATHS="$HOME/build/opencv/opencv-$OPENCV_VERSION-build,$clang_dir/lib/darwin"
export OPENCV_LINK_LIBS="opencv2.framework,OpenCL.framework,Cocoa.framework,Accelerate.framework,AVFoundation.framework,CoreGraphics.framework,CoreMedia.framework,CoreVideo.framework,QuartzCore.framework,clang_rt.osx"
export OPENCV_INCLUDE_PATHS="$HOME/build/opencv/opencv-$OPENCV_VERSION-build"
if [[ "$OPENCV_VERSION" == "3.4.20" ]]; then
export OPENCV_LINK_PATHS="$opencv_build_path,$clang_dir/lib/darwin"
export OPENCV_LINK_LIBS="opencv2.framework,OpenCL.framework,Cocoa.framework,Accelerate.framework,AVFoundation.framework,CoreGraphics.framework,CoreMedia.framework,CoreVideo.framework,QuartzCore.framework,clang_rt.osx"
else
export OPENCV_LINK_PATHS="$opencv_build_path,$clang_dir/lib/darwin,$opencv_build_path/build/build-$(uname -m)-macosx/install/lib/"
export OPENCV_LINK_LIBS="opencv2.framework,OpenCL.framework,Cocoa.framework,Accelerate.framework,AVFoundation.framework,CoreGraphics.framework,CoreMedia.framework,CoreVideo.framework,QuartzCore.framework,clang_rt.osx,OrbbecSDK"
fi
export OPENCV_INCLUDE_PATHS="$opencv_build_path"
fi
echo "=== Installed brew packages:"
brew list --versions
Expand Down

0 comments on commit 3bcc741

Please sign in to comment.