Skip to content

Commit

Permalink
emscripten opencv changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitre authored Dec 17, 2024
2 parents 900b6b4 + 69d2697 commit b916528
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 41 deletions.
36 changes: 18 additions & 18 deletions apothecary/formulas/fmt/fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# https://github.com/fmtlib/fmt

FORMULA_TYPES=( "osx" "vs" "ios" "watchos" "catos" "xros" "tvos" "android" "emscripten" "linux64" "linuxaarch64" )
FORMULA_DEPENDS=( )
FORMULA_DEPENDS=( )

# define the version
VER=11.0.2
Expand All @@ -21,20 +21,20 @@ DEFINES=""
function download() {
. "$DOWNLOADER_SCRIPT"

git clone --branch $GIT_TAG --depth=1 $GIT_URL
git clone --branch $GIT_TAG --depth=1 $GIT_URL

# if [ "$TYPE" == "vs" ] ; then
# downloader "${URL}.zip"
# unzip -q "${VER}.zip"
# mv "fmt-${VER}" fmt
# rm "${VER}.zip"
# else
# else
# downloader "${URL}.tar.gz"
# tar -xf "${VER}.tar.gz"
# mv "fmt-${VER}" fmt
# rm "${VER}.tar.gz"
# fi


}

Expand All @@ -45,7 +45,7 @@ function prepare() {
# . "$DOWNLOADER_SCRIPT"
rm -f ./CMakeLists.txt
cp -v $FORMULA_DIR/CMakeLists.txt ./CMakeLists.txt

}

# executed inside the lib src dir
Expand All @@ -64,7 +64,7 @@ function build() {
-DFMT_SYSTEM_HEADERS=OFF \
-DCMAKE_INCLUDE_OUTPUT_DIRECTORY=include \
-DCMAKE_INSTALL_INCLUDEDIR=include"

if [[ "$TYPE" =~ ^(osx|ios|tvos|xros|catos|watchos)$ ]]; then
mkdir -p "build_${TYPE}_${PLATFORM}"
cd "build_${TYPE}_${PLATFORM}"
Expand All @@ -83,11 +83,11 @@ function build() {
-DCMAKE_VERBOSE_MAKEFILE=${VERBOSE_MAKEFILE} \
-DCMAKE_POSITION_INDEPENDENT_CODE=TRUE
cmake --build . --config Release --target install
cd ..
cd ..
elif [ "$TYPE" == "vs" ] ; then
echoVerbose "building $TYPE | $ARCH | $VS_VER | vs: $VS_VER_GEN"
echoVerbose "--------------------"
GENERATOR_NAME="Visual Studio ${VS_VER_GEN}"
GENERATOR_NAME="Visual Studio ${VS_VER_GEN}"

mkdir -p "build_${TYPE}_${ARCH}"
cd "build_${TYPE}_${ARCH}"
Expand All @@ -111,7 +111,7 @@ function build() {

cmake --build . --config Release --target install

cd ..
cd ..

elif [ "$TYPE" == "android" ] ; then

Expand Down Expand Up @@ -202,14 +202,14 @@ function build() {
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_INSTALL_PREFIX=Release \
-DCMAKE_INCLUDE_OUTPUT_DIRECTORY=include \
-DCMAKE_INSTALL_INCLUDEDIR=include \
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=. \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=. \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=.
-DCMAKE_INSTALL_INCLUDEDIR=include
# -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=. \
# -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=. \
# -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=.
cmake --build . --target install --config Release
cd ..
fi

}

# executed inside the lib src dir, first arg $1 is the dest libs dir root
Expand Down Expand Up @@ -240,7 +240,7 @@ function copy() {
mkdir -p $1/lib/$TYPE/$PLATFORM/
cp -v "build_${TYPE}_${PLATFORM}/Release/bin/libfmt.a" $1/lib/$TYPE/$PLATFORM/libfmt.a
secure $1/lib/$TYPE/$PLATFORM/libfmt.a fmt.pkl
cp -R "build_${TYPE}_${PLATFORM}/Release/include/" $1/include
cp -R "build_${TYPE}_${PLATFORM}/Release/include/" $1/include
fi

# copy license file
Expand All @@ -255,19 +255,19 @@ function copy() {
function clean() {
if [ "$TYPE" == "vs" ] ; then
if [ -d "build_${TYPE}_${ARCH}" ]; then
rm -r build_${TYPE}_${ARCH}
rm -r build_${TYPE}_${ARCH}
fi
elif [ "$TYPE" == "android" ] ; then
if [ -d "build_${TYPE}_${ABI}" ]; then
rm -r build_${TYPE}_${ABI}
rm -r build_${TYPE}_${ABI}
fi
elif [ "$TYPE" == "emscripten" ] ; then
if [ -d "build_${TYPE}" ]; then
rm -r build_${TYPE}
fi
elif [[ "$TYPE" =~ ^(osx|ios|tvos|xros|catos|watchos)$ ]]; then
if [ -d "build_${TYPE}_${PLATFORM}" ]; then
rm -r build_${TYPE}_${PLATFORM}
rm -r build_${TYPE}_${PLATFORM}
fi
else
echoVerbose "clean not setup for $TYPE"
Expand Down
50 changes: 27 additions & 23 deletions apothecary/formulas/opencv/opencv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ FORMULA_DEPENDS=( "zlib" "libpng" )

# define the version
VER=4.10.0
BUILD_ID=3
=3
DEFINES=""
FRAMEWORKS=""

Expand Down Expand Up @@ -42,7 +42,7 @@ function download() {
# prepare the build environment, executed inside the lib src dir
function prepare() {
: # noop

#no idea why we are building iOS stuff on Windows - but this might fix it
if [ "$TYPE" == "vs" ] ; then
rm -rf modules/objc_bindings_generator
Expand All @@ -59,7 +59,7 @@ function build() {

if [[ "$TYPE" =~ ^(osx|ios|tvos|xros|catos|watchos)$ ]]; then
# sed -i'' -e "s|return __TBB_machine_fetchadd4(ptr, 1) + 1L;|return __atomic_fetch_add(ptr, 1L, __ATOMIC_SEQ_CST) + 1L;|" 3rdparty/ittnotify/src/ittnotify/ittnotify_config.h

ZLIB_ROOT="$LIBS_ROOT/zlib/"
ZLIB_INCLUDE_DIR="$LIBS_ROOT/zlib/include"
ZLIB_LIBRARY="$LIBS_ROOT/zlib/lib/$TYPE/$PLATFORM/zlib.a"
Expand Down Expand Up @@ -87,7 +87,7 @@ function build() {
-DPNG_ROOT=${LIBPNG_ROOT} \
-DPNG_PNG_INCLUDE_DIR=${LIBPNG_INCLUDE_DIR} \
-DPNG_LIBRARY=${LIBPNG_LIBRARY}"

DEFS="
-DBUILD_DOCS=OFF \
-DENABLE_BUILD_HARDENING=ON \
Expand Down Expand Up @@ -173,9 +173,9 @@ function build() {

if [[ "$TYPE" =~ ^(tvos)$ ]]; then
EXTRA_DEFS="$EXTRA_DEFS -DBUILD_opencv_videoio=OFF -DBUILD_opencv_videostab=OFF"
else
else
EXTRA_DEFS="-DBUILD_opencv_videoio=ON -DBUILD_opencv_videostab=ON"
fi
fi

FRAMEWORKS="-framework Foundation -framework AVFoundation -framework CoreFoundation -framework CoreVideo"

Expand Down Expand Up @@ -203,7 +203,7 @@ function build() {
elif [ "$TYPE" == "vs" ] ; then
echoInfo "building $TYPE | $ARCH | $VS_VER | vs: $VS_VER_GEN"
echoInfo "--------------------"
GENERATOR_NAME="Visual Studio ${VS_VER_GEN}"
GENERATOR_NAME="Visual Studio ${VS_VER_GEN}"
mkdir -p "build_${TYPE}_${PLATFORM}"
cd "build_${TYPE}_${PLATFORM}"
rm -f CMakeCache.txt || true
Expand Down Expand Up @@ -318,10 +318,10 @@ function build() {

if [[ ${ARCH} == "arm64ec" || "${ARCH}" == "arm64" ]]; then
EXTRA_DEFS="-DCV_ENABLE_INTRINSICS=OFF -DBUILD_opencv_rgbd=OFF"
else
else
EXTRA_DEFS="-DCV_ENABLE_INTRINSICS=ON"
fi

cmake .. ${DEFS} \
-A "${PLATFORM}" \
-G "${GENERATOR_NAME}" \
Expand Down Expand Up @@ -369,7 +369,7 @@ function build() {
-DBUILD_WITH_STATIC_CRT=OFF \
${CMAKE_WIN_SDK}
cmake --build . --target install --config Release
cd ..
cd ..

elif [ "$TYPE" == "android" ]; then
export ANDROID_NDK=${NDK_ROOT}
Expand Down Expand Up @@ -397,19 +397,19 @@ function build() {
elif [ $ABI = "arm64-v8a" ]; then
export ARM_MODE="-DANDROID_FORCE_ARM_BUILD=FALSE"
elif [ "$ABI" = "x86_64" ]; then
export ARM_MODE="-DANDROID_FORCE_ARM_BUILD=FALSE"
export ARM_MODE="-DANDROID_FORCE_ARM_BUILD=FALSE"
elif [ "$ABI" = "x86" ]; then
export ARM_MODE="-DANDROID_FORCE_ARM_BUILD=FALSE"
fi

export ANDROID_NATIVE_API_LEVEL=21

echo ${ANDROID_NDK}
pwd

if [[ ${ABI} == "arm64-v8a" || "${ABI}" == "armeabi-v7a" ]]; then
EXTRA_DEFS="-DCV_ENABLE_INTRINSICS=OFF -DENABLE_SSE=OFF -DENABLE_SSE2=OFF -DENABLE_SSE3=OFF -DENABLE_SSE41=OFF -DENABLE_SSE42=OFF -DENABLE_SSSE3=OFF"
else
else
EXTRA_DEFS="-DCV_ENABLE_INTRINSICS=ON -DENABLE_SSE=ON -DENABLE_SSE2=ON -DENABLE_SSE3=ON -DENABLE_SSE41=ON -DENABLE_SSE42=ON -DENABLE_SSSE3=ON"
fi
rm -f CMakeCache.txt || true
Expand Down Expand Up @@ -520,7 +520,7 @@ function build() {
LIBPNG_LIBRARY="$LIBS_ROOT/libpng/lib/$TYPE/$PLATFORM/libpng.a"

export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}:${LIBPNG_ROOT}/lib/$TYPE/$PLATFORM:${ZLIB_ROOT}/lib/$TYPE/$PLATFORM"

mkdir -p build_${TYPE}_${PLATFORM}
cd build_${TYPE}_${PLATFORM}
find ./ -name "*.o" -type f -delete
Expand All @@ -531,18 +531,22 @@ function build() {
$EMSDK/upstream/emscripten/emcmake cmake .. \
-B build \
-DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_LIBDIR="lib" \
-DCMAKE_C_STANDARD=${C_STANDARD} \
-DCMAKE_CXX_STANDARD=${CPP_STANDARD} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
# -DCMAKE_CXX_FLAGS="-I/${EMSDK}/upstream/emscripten/system/lib/libcxxabi/include/ -msimd128 ${FLAG_RELEASE}" \
# -DCMAKE_C_FLAGS="-I/${EMSDK}/upstream/emscripten/system/lib/libcxxabi/include/ -msimd128 ${FLAG_RELEASE}" \
-DCMAKE_CXX_FLAGS="-I/${EMSDK}/upstream/emscripten/system/lib/libcxxabi/include/ ${FLAG_RELEASE}" \
-DCMAKE_C_FLAGS="-I/${EMSDK}/upstream/emscripten/system/lib/libcxxabi/include/ ${FLAG_RELEASE}" \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_LIBDIR="lib" \
-DCPU_BASELINE='' \
-DCPU_DISPATCH='' \
-DCV_TRACE=OFF \
-DOPENCV_ENABLE_NONFREE=OFF \
-DCMAKE_PREFIX_PATH="${LIBS_ROOT}" \
-DCMAKE_C_FLAGS="-I/${EMSDK}/upstream/emscripten/system/lib/libcxxabi/include/ -msimd128 ${FLAG_RELEASE}" \
-DCMAKE_CXX_FLAGS="-I/${EMSDK}/upstream/emscripten/system/lib/libcxxabi/include/ -msimd128 ${FLAG_RELEASE}" \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_DOCS=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_FAT_JAVA_LIB=OFF \
Expand Down Expand Up @@ -693,7 +697,7 @@ function copy() {
secure $1/lib/$TYPE/$PLATFORM/libopencv_core.a opencv.pkl

elif [ "$TYPE" == "vs" ] ; then

cp -Rv "build_${TYPE}_${PLATFORM}/Release/include/opencv2" $1/include/
mkdir -p $1/lib/$TYPE/$PLATFORM/

Expand Down Expand Up @@ -770,15 +774,15 @@ function copy() {
function clean() {
if [ "$TYPE" == "vs" ] ; then
if [ -d "build_${TYPE}_${ARCH}" ]; then
rm -r build_${TYPE}_${ARCH}
rm -r build_${TYPE}_${ARCH}
fi
elif [ "$TYPE" == "android" ] ; then
if [ -d "build_${TYPE}_${ABI}" ]; then
rm -r build_${TYPE}_${ABI}
rm -r build_${TYPE}_${ABI}
fi
elif [[ "$TYPE" =~ ^(osx|ios|tvos|xros|catos|watchos|emscripten)$ ]]; then
if [ -d "build_${TYPE}_${PLATFORM}" ]; then
rm -r build_${TYPE}_${PLATFORM}
rm -r build_${TYPE}_${PLATFORM}
fi
fi
}
Expand Down

0 comments on commit b916528

Please sign in to comment.