Skip to content

Commit

Permalink
[build] updated Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
cocoa-xu committed Mar 25, 2024
1 parent 9e66d68 commit 5c6e351
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ifndef MIX_APP_PATH
endif

PRIV_DIR = $(MIX_APP_PATH)/priv
OPENCV_CONFIG_CMAKE = $(PRIV_DIR)/lib/cmake/opencv4/OpenCVConfig.cmake
EVISION_SO = $(PRIV_DIR)/evision.so
WINDOWS_FIX_SO = $(PRIV_DIR)/windows_fix.so
SRC = $(shell pwd)/src
Expand Down Expand Up @@ -128,6 +129,9 @@ MAKE_BUILD_FLAGS ?= -j$(DEFAULT_JOBS)
EVISION_GENERATE_LANG ?= elixir
EVISION_PREFER_PRECOMPILED ?= false
EVISION_COMPILE_WITH_REBAR ?= false
ifeq ($(EVISION_PREFER_PRECOMPILED), true)
EVISION_GENERATE_LANG = elixir,erlang
endif
EVISION_PRECOMPILED_CACHE_DIR ?= $(shell pwd)/.cache
EVISION_MAKE ?= make

Expand Down Expand Up @@ -170,7 +174,7 @@ $(CONFIGURATION_PRIVATE_HPP): $(OPENCV_CONFIGURATION_PRIVATE_HPP)
fi

$(HEADERS_TXT): $(CONFIGURATION_PRIVATE_HPP)
@ if [ "$(EVISION_PREFER_PRECOMPILED)" != "true" ] && [ "$(EVISION_COMPILE_WITH_REBAR)" != "true" ]; then \
@ if [ "$(EVISION_PREFER_PRECOMPILED)" != "true" ]; then \
python3 "$(shell pwd)/patches/apply_patch.py" "$(OPENCV_DIR)" "$(OPENCV_VER)" ; \
mkdir -p "$(CMAKE_OPENCV_BUILD_DIR)" && \
cd "$(CMAKE_OPENCV_BUILD_DIR)" && \
Expand All @@ -194,6 +198,7 @@ $(HEADERS_TXT): $(CONFIGURATION_PRIVATE_HPP)
-D BUILD_ZLIB=ON \
-D BUILD_opencv_gapi=OFF \
-D BUILD_opencv_apps=OFF \
-D BUILD_opencv_java=OFF \
-D CMAKE_C_FLAGS=-DPNG_ARM_NEON_OPT=0 \
-D CMAKE_CXX_FLAGS=-DPNG_ARM_NEON_OPT=0 \
$(CMAKE_OPTIONS) "$(OPENCV_DIR)" && \
Expand All @@ -204,8 +209,7 @@ $(HEADERS_TXT): $(CONFIGURATION_PRIVATE_HPP)
xcodebuild BITCODE_GENERATION_MODE=bitcode XROS_DEPLOYMENT_TARGET=$(XROS_DEPLOYMENT_TARGET) ARCHS=$(VISIONOS_ARCH) -sdk visionos -configuration $(CMAKE_BUILD_TYPE) -parallelizeTargets -jobs $(DEFAULT_JOBS) -target ALL_BUILD build ; \
cmake -DBUILD_TYPE=$(CMAKE_BUILD_TYPE) -P cmake_install.cmake ; \
else \
make "$(MAKE_BUILD_FLAGS)" ; \
cd "$(CMAKE_OPENCV_BUILD_DIR)" && make install; \
make -j$(DEFAULT_JOBS) ; \
fi && \
if [ "$(OPENCV_HEADERS_TXT)" != "$(HEADERS_TXT)" ]; then \
cp -f "$(OPENCV_HEADERS_TXT)" "$(HEADERS_TXT)" ; \
Expand All @@ -217,10 +221,13 @@ $(C_SRC_HEADERS_TXT): $(HEADERS_TXT)
cp -f "$(HEADERS_TXT)" "$(C_SRC_HEADERS_TXT)" ; \
fi

opencv: $(C_SRC_HEADERS_TXT)
$(OPENCV_CONFIG_CMAKE):
@cd "$(CMAKE_OPENCV_BUILD_DIR)" && make install

opencv: $(C_SRC_HEADERS_TXT) $(OPENCV_CONFIG_CMAKE)
@echo > /dev/null

$(EVISION_SO): $(C_SRC_HEADERS_TXT)
$(EVISION_SO): $(C_SRC_HEADERS_TXT) $(OPENCV_CONFIG_CMAKE)
@ mkdir -p "$(EVISION_PRECOMPILED_CACHE_DIR)"
@ mkdir -p "$(PRIV_DIR)"
@ mkdir -p "$(GENERATED_ELIXIR_SRC_DIR)"
Expand All @@ -231,6 +238,7 @@ $(EVISION_SO): $(C_SRC_HEADERS_TXT)
erlc evision_precompiled.erl && \
erl -noshell -s evision_precompiled install_precompiled_binary_if_available -s init stop ; } || \
{ \
DEFAULT_JOBS=$(shell erl -noshell -eval "io:format('~p~n',[erlang:system_info(logical_processors_online)]), halt().") \
$(EVISION_MAKE) EVISION_PREFER_PRECOMPILED=false EVISION_COMPILE_WITH_REBAR=true ; } ; \
fi
@ if [ ! -f "${EVISION_SO}" ]; then \
Expand All @@ -248,7 +256,7 @@ $(EVISION_SO): $(C_SRC_HEADERS_TXT)
-D EVISION_GENERATE_LANG="$(EVISION_GENERATE_LANG)" \
-D EVISION_ENABLE_CONTRIB="$(EVISION_ENABLE_CONTRIB)" \
$(CMAKE_CONFIGURE_FLAGS) $(CMAKE_EVISION_OPTIONS) "$(shell pwd)" && \
make "$(MAKE_BUILD_FLAGS)" \
make "-j$(DEFAULT_JOBS)" \
|| { echo "\033[0;31mincomplete build of OpenCV found in '$(CMAKE_OPENCV_BUILD_DIR)', please delete that directory and retry\033[0m" && exit 1 ; } ; } \
&& if [ "$(EVISION_PREFER_PRECOMPILED)" != "true" ]; then \
cp "$(CMAKE_EVISION_BUILD_DIR)/evision.so" "$(EVISION_SO)" ; \
Expand Down
7 changes: 0 additions & 7 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
{"win32", compile, "nmake"}
]}.

{erl_opts, [deterministic,
{platform_define,
"(linux|solaris|freebsd|darwin|win32)",
'EVISION_GENERATE_LANG', "erlang"}
]
}.

{edoc_opts,
[
{doclet, edoc_doclet_chunks},
Expand Down

0 comments on commit 5c6e351

Please sign in to comment.