Add win generate.bat

This commit is contained in:
John Zhao 2018-11-02 10:56:00 +08:00
parent 7475dc3dbe
commit 6fa55e9ad7
3 changed files with 90 additions and 11 deletions

View File

@ -70,7 +70,9 @@ macro(set_outdir ARCHIVE_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY RUNTIME_OUTPU
endforeach()
endmacro()
if(NOT __exe2bat_relative_path)
set(__exe2bat_relative_path false)
endif()
macro(exe2bat exe_name exe_dir dll_search_paths)
message(STATUS "Generating ${exe_name}.bat")

20
scripts/win/generate.bat Normal file
View File

@ -0,0 +1,20 @@
@echo off
setlocal
set _MY_DIR=%~dp0
set _VS_GEN="Visual Studio 15 2017 Win64"
REM set _VS_GEN="Visual Studio 14 2015 Win64"
cd %_MY_DIR%
mkdir _build
cd _build/
cmake -DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_PREFIX_PATH="%_MY_DIR%/../lib/cmake" ^
-DOpenCV_DIR="%_MY_DIR%/../3rdparty/opencv/build" ^
-G %_VS_GEN% ^
..
cd %_MY_DIR%
pause

View File

@ -37,17 +37,36 @@ fi
export OpenCV_DIR="$ROOT_DIR/3rdparty/opencv/build"
_rm() {
[ -e "$1" ] && (rm -r "$1" && _echo_in "RM: $1")
[ -e "$1" ] && (rm -r "$1" && _echo_i "RM: $1")
}
_md() {
[ ! -d "$1" ] && (mkdir -p "$1" && _echo_in "MD: $1")
[ ! -d "$1" ] && (mkdir -p "$1" && _echo_i "MD: $1")
}
# _mv_subs <srcdir> <dstdir> [sub1 sub2 ...]
_mv_subs() {
_src_dir="$1"; shift; _dst_dir="$1"; shift; _subs="$@";
if [ -z "$_subs" ]; then
_subs=`ls $_src_dir`
fi
for _sub in $_subs; do
_src="$_src_dir/$_sub"
[ ! -e "$_src" ] && (_echo_i "Not exist: $_src") && continue
_dst=
[ -f "$_src" ] && _dst="$_dst_dir"
[ -d "$_src" ] && _dst="$_dst_dir/$_sub"
[ -z "$_dst" ] && continue
# _echo "_src: $_src"
# _echo "_dst: $_dst"
mv "$_src" "$_dst"
done
}
################################################################################
# build release
make install
make samples tools
################################################################################
# build debug
@ -59,12 +78,6 @@ make build BUILD_TYPE=Debug
mv "$ROOT_DIR/_output/bin/mynteyed.dll" "$ROOT_DIR/_install/bin/mynteyed.dll"
mv "$ROOT_DIR/_output/lib/mynteyed.lib" "$ROOT_DIR/_install/lib/mynteyed.lib"
################################################################################
# copy to _install
cp -f "$ROOT_DIR/scripts/win/cmake/mynteye-targets.cmake" "$ROOT_DIR/_install/lib/cmake/mynteye/"
cp -f "$ROOT_DIR/scripts/win/cmake/mynteye-targets-release.cmake" "$ROOT_DIR/_install/lib/cmake/mynteye/"
################################################################################
# move to _install
@ -72,23 +85,67 @@ cp -f "$ROOT_DIR/scripts/win/cmake/mynteye-targets-release.cmake" "$ROOT_DIR/_in
_md "$ROOT_DIR/_install/3rdparty"
mv "$ROOT_DIR/3rdparty/opencv" "$ROOT_DIR/_install/3rdparty/opencv"
# cmake
mv "$ROOT_DIR/cmake" "$ROOT_DIR/_install/cmake"
# samples
mv "$ROOT_DIR/samples/_output/bin" "$ROOT_DIR/_install/bin/samples"
mv "$ROOT_DIR/samples/_output/lib" "$ROOT_DIR/_install/lib/samples"
_rm "$ROOT_DIR/samples/_build"
_rm "$ROOT_DIR/samples/_output"
mv "$ROOT_DIR/samples" "$ROOT_DIR/_install/samples"
# tools
mv "$ROOT_DIR/tools/_output/bin" "$ROOT_DIR/_install/bin/tools"
mv "$ROOT_DIR/tools/_output/lib" "$ROOT_DIR/_install/lib/tools"
_rm "$ROOT_DIR/tools/_build"
_rm "$ROOT_DIR/tools/_output"
mv "$ROOT_DIR/tools/linter" "$ROOT_DIR/3rdparty/linter"
mv "$ROOT_DIR/tools" "$ROOT_DIR/_install/tools"
################################################################################
# copy to _install
cp -f "$ROOT_DIR/scripts/win/cmake/mynteye-targets.cmake" "$ROOT_DIR/_install/lib/cmake/mynteye/"
cp -f "$ROOT_DIR/scripts/win/cmake/mynteye-targets-release.cmake" "$ROOT_DIR/_install/lib/cmake/mynteye/"
cp -f "$ROOT_DIR/scripts/win/generate.bat" "$ROOT_DIR/_install/samples/"
cp -f "$ROOT_DIR/scripts/win/generate.bat" "$ROOT_DIR/_install/tools/"
################################################################################
# archive exe
source "$ROOT_DIR/pkginfo.sh"
_pkgname=$1-opencv-$OpenCV_VERSION
_pkgname="$1-opencv-$OpenCV_VERSION"
_rm "$ROOT_DIR/$_pkgname.exe"
mv "$ROOT_DIR/_install" "$ROOT_DIR/$_pkgname"
makensis "$ROOT_DIR/winpack.nsi"
mv "$ROOT_DIR/$_pkgname" "$ROOT_DIR/_install"
################################################################################
# remove from _install
_rm "$ROOT_DIR/_install/samples/generate.bat"
_rm "$ROOT_DIR/_install/tools/generate.bat"
################################################################################
# move back from _install
# 3rdparty/opencv
mv "$ROOT_DIR/_install/3rdparty/opencv" "$ROOT_DIR/3rdparty/opencv"
# cmake
mv "$ROOT_DIR/_install/cmake" "$ROOT_DIR/cmake"
# samples
mv "$ROOT_DIR/_install/samples" "$ROOT_DIR/samples"
# tools
mv "$ROOT_DIR/_install/tools" "$ROOT_DIR/tools"
mv "$ROOT_DIR/3rdparty/linter" "$ROOT_DIR/tools/linter"
################################################################################
# clean build