MYNT-EYE-S-SDK/scripts/win/winpack.sh

180 lines
5.4 KiB
Bash
Raw Permalink Normal View History

2018-11-01 14:03:23 +02:00
#!/usr/bin/env bash
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
BASE_DIR=$(cd "$(dirname "$0")" && pwd)
ROOT_DIR=$(realpath "$BASE_DIR/../..")
SCRIPTS_DIR=$(realpath "$BASE_DIR/..")
source "$SCRIPTS_DIR/common/echo.sh"
source "$SCRIPTS_DIR/common/detect.sh"
2018-11-01 17:12:36 +02:00
if [ ! -d "$ROOT_DIR/3rdparty/opencv" ]; then
_echo_e "3rdparty/opencv not found, please manually download it to here."
_echo_e
_echo_e " OpenCV Win pack 3.4.3: https://opencv.org/releases.html"
exit 1
fi
if ! _detect_cmd makensis; then
_echo_e "makensis not found, please manually download and install it."
_echo_e
_echo_e " NSIS: http://nsis.sourceforge.net"
exit 1
fi
export OpenCV_DIR="$ROOT_DIR/3rdparty/opencv/build"
_rm() {
2018-11-02 04:56:00 +02:00
[ -e "$1" ] && (rm -r "$1" && _echo_i "RM: $1")
2018-11-01 17:12:36 +02:00
}
_md() {
2018-11-02 04:56:00 +02:00
[ ! -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
2018-11-01 17:12:36 +02:00
}
################################################################################
# build release
2018-11-02 04:56:00 +02:00
make samples tools
2018-11-01 17:12:36 +02:00
################################################################################
# build debug
rm -r "$ROOT_DIR/_build"
rm -r "$ROOT_DIR/_output"
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"
################################################################################
# move to _install
# 3rdparty/opencv
_md "$ROOT_DIR/_install/3rdparty"
mv "$ROOT_DIR/3rdparty/opencv" "$ROOT_DIR/_install/3rdparty/opencv"
2018-11-02 04:56:00 +02:00
# 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"
2018-11-02 07:01:54 +02:00
# platforms/win
mv "$ROOT_DIR/platforms/win/README.txt" "$ROOT_DIR/_install"
2018-11-05 05:02:24 +02:00
_rm "$ROOT_DIR/platforms/projects/vs2017/mynteyes_demo/.vs"
_rm "$ROOT_DIR/platforms/projects/vs2017/mynteyes_demo/x64"
_rm "$ROOT_DIR/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/x64"
_rm "$ROOT_DIR/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/mynteyes_demo.vcxproj.user"
2018-11-05 04:49:43 +02:00
mv "$ROOT_DIR/platforms/projects" "$ROOT_DIR/_install/projects"
2018-11-02 04:56:00 +02:00
################################################################################
# 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/"
2018-11-01 17:12:36 +02:00
################################################################################
# archive exe
2018-11-01 17:34:52 +02:00
source "$ROOT_DIR/pkginfo.sh"
2018-11-02 04:56:00 +02:00
_pkgname="$1-opencv-$OpenCV_VERSION"
2018-11-05 09:13:23 +02:00
2018-11-02 04:56:00 +02:00
_rm "$ROOT_DIR/$_pkgname.exe"
2018-11-01 17:12:36 +02:00
mv "$ROOT_DIR/_install" "$ROOT_DIR/$_pkgname"
makensis "$ROOT_DIR/winpack.nsi"
2018-11-05 10:14:32 +02:00
if _detect_cmd git; then
_git_branch=`git symbolic-ref --short -q HEAD`
if [ "$_git_branch" == "develop" ]; then
_git_hash=`git rev-parse --short HEAD`
mv "$ROOT_DIR/$_pkgname.exe" "$ROOT_DIR/$_pkgname-dev-$_git_hash.exe"
fi
2018-11-05 09:13:23 +02:00
fi
2018-11-01 17:12:36 +02:00
mv "$ROOT_DIR/$_pkgname" "$ROOT_DIR/_install"
2018-11-02 04:56:00 +02:00
################################################################################
# remove from _install
_rm "$ROOT_DIR/_install/samples/generate.bat"
_rm "$ROOT_DIR/_install/tools/generate.bat"
2018-11-01 17:12:36 +02:00
################################################################################
# move back from _install
# 3rdparty/opencv
mv "$ROOT_DIR/_install/3rdparty/opencv" "$ROOT_DIR/3rdparty/opencv"
2018-11-02 04:56:00 +02:00
# 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"
2018-11-02 07:01:54 +02:00
# platforms/win
mv "$ROOT_DIR/_install/README.txt" "$ROOT_DIR/platforms/win"
2018-11-05 04:49:43 +02:00
mv "$ROOT_DIR/_install/projects" "$ROOT_DIR/platforms/projects"
2018-11-01 17:12:36 +02:00
################################################################################
# clean build
_rm "$ROOT_DIR/_build"
_rm "$ROOT_DIR/_output"
_echo_d "Win pack success"