Update winpack script
This commit is contained in:
parent
f923414660
commit
f803e3a75b
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -16,6 +16,10 @@ _output/
|
||||||
|
|
||||||
/plugins/
|
/plugins/
|
||||||
|
|
||||||
|
/3rdparty/opencv/
|
||||||
|
/*.nsi
|
||||||
|
/*.exe
|
||||||
|
|
||||||
# ros
|
# ros
|
||||||
|
|
||||||
/wrappers/ros/build
|
/wrappers/ros/build
|
||||||
|
|
|
@ -83,6 +83,13 @@ configure_file(
|
||||||
include/mynteye/mynteye.h @ONLY
|
include/mynteye/mynteye.h @ONLY
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(OS_WIN)
|
||||||
|
configure_file(
|
||||||
|
scripts/win/nsis/winpack.nsi.in
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/winpack.nsi @ONLY
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# targets
|
# targets
|
||||||
|
|
||||||
add_definitions(-DMYNTEYE_EXPORTS)
|
add_definitions(-DMYNTEYE_EXPORTS)
|
||||||
|
|
|
@ -214,7 +214,7 @@ endif
|
||||||
# Package
|
# Package
|
||||||
|
|
||||||
PKGVERSION := $(shell ./scripts/version.sh)
|
PKGVERSION := $(shell ./scripts/version.sh)
|
||||||
PKGNAME := mynteye-$(PKGVERSION)-$(HOST_OS)-$(HOST_ARCH)
|
PKGNAME := mynteye-s-$(PKGVERSION)-$(HOST_OS)-$(HOST_ARCH)
|
||||||
ifeq ($(HOST_OS),Linux)
|
ifeq ($(HOST_OS),Linux)
|
||||||
PKGNAME := $(PKGNAME)-gcc$(shell gcc -dumpversion | cut -c 1-1)
|
PKGNAME := $(PKGNAME)-gcc$(shell gcc -dumpversion | cut -c 1-1)
|
||||||
endif
|
endif
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -168,7 +168,7 @@ tools: install
|
||||||
pkg: clean
|
pkg: clean
|
||||||
@$(call echo,Make $@)
|
@$(call echo,Make $@)
|
||||||
ifeq ($(HOST_OS),Win)
|
ifeq ($(HOST_OS),Win)
|
||||||
@$(SH) ./scripts/win/winpack.sh
|
@$(SH) ./scripts/win/winpack.sh "$(PKGNAME)"
|
||||||
else
|
else
|
||||||
$(error "Can't make pkg on $(HOST_OS)")
|
$(error "Can't make pkg on $(HOST_OS)")
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -27,11 +27,13 @@ ECHO="echo -e"
|
||||||
# task colors
|
# task colors
|
||||||
COLOR_STRONG="1;35" # Magenta
|
COLOR_STRONG="1;35" # Magenta
|
||||||
COLOR_INFO="1;34" # Blue
|
COLOR_INFO="1;34" # Blue
|
||||||
|
COLOR_WARN="1;33" # Yellow
|
||||||
COLOR_DONE="1;32" # Green
|
COLOR_DONE="1;32" # Green
|
||||||
COLOR_ERROR="1;31" # Red
|
COLOR_ERROR="1;31" # Red
|
||||||
# action colors
|
# action colors
|
||||||
COLOR_STRONG_NORMAL="35"
|
COLOR_STRONG_NORMAL="35"
|
||||||
COLOR_INFO_NORMAL="34"
|
COLOR_INFO_NORMAL="34"
|
||||||
|
COLOR_WARN_NORMAL="33"
|
||||||
COLOR_DONE_NORMAL="32"
|
COLOR_DONE_NORMAL="32"
|
||||||
COLOR_ERROR_NORMAL="31"
|
COLOR_ERROR_NORMAL="31"
|
||||||
|
|
||||||
|
@ -59,6 +61,10 @@ _echo_i() {
|
||||||
_echo_ "$1" "$COLOR_INFO"
|
_echo_ "$1" "$COLOR_INFO"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_echo_w() {
|
||||||
|
_echo_ "$1" "$COLOR_WARN"
|
||||||
|
}
|
||||||
|
|
||||||
_echo_d() {
|
_echo_d() {
|
||||||
_echo_ "$1" "$COLOR_DONE"
|
_echo_ "$1" "$COLOR_DONE"
|
||||||
}
|
}
|
||||||
|
@ -75,6 +81,10 @@ _echo_in() {
|
||||||
_echo_ "$1" "$COLOR_INFO_NORMAL"
|
_echo_ "$1" "$COLOR_INFO_NORMAL"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_echo_wn() {
|
||||||
|
_echo_ "$1" "$COLOR_WARN_NORMAL"
|
||||||
|
}
|
||||||
|
|
||||||
_echo_dn() {
|
_echo_dn() {
|
||||||
_echo_ "$1" "$COLOR_DONE_NORMAL"
|
_echo_ "$1" "$COLOR_DONE_NORMAL"
|
||||||
}
|
}
|
||||||
|
|
29
scripts/win/cmake/mynteye-targets-release.cmake
Normal file
29
scripts/win/cmake/mynteye-targets-release.cmake
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#----------------------------------------------------------------
|
||||||
|
# Generated CMake target import file for configuration "Release".
|
||||||
|
#----------------------------------------------------------------
|
||||||
|
|
||||||
|
# Commands may need to know the format version.
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||||
|
|
||||||
|
# Import target "mynteye" for configuration "Release"
|
||||||
|
set_property(TARGET mynteye APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||||
|
set_target_properties(mynteye PROPERTIES
|
||||||
|
IMPORTED_IMPLIB_RELEASE "${MYNTEYES_SDK_ROOT}/lib/mynteye.lib"
|
||||||
|
IMPORTED_LOCATION_RELEASE "${MYNTEYES_SDK_ROOT}/bin/mynteye.dll"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Import target "mynteye" for configuration "Debug"
|
||||||
|
set_property(TARGET mynteye APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
||||||
|
set_target_properties(mynteye PROPERTIES
|
||||||
|
IMPORTED_IMPLIB_DEBUG "${MYNTEYES_SDK_ROOT}/lib/mynteyed.lib"
|
||||||
|
IMPORTED_LOCATION_DEBUG "${MYNTEYES_SDK_ROOT}/bin/mynteyed.dll"
|
||||||
|
)
|
||||||
|
|
||||||
|
list(APPEND _IMPORT_CHECK_TARGETS mynteye )
|
||||||
|
list(APPEND _IMPORT_CHECK_FILES_FOR_mynteye
|
||||||
|
"${MYNTEYES_SDK_ROOT}/lib/mynteye.lib" "${MYNTEYES_SDK_ROOT}/bin/mynteye.dll"
|
||||||
|
"${MYNTEYES_SDK_ROOT}/lib/mynteyed.lib" "${MYNTEYES_SDK_ROOT}/bin/mynteyed.dll"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Commands beyond this point should not need to know the version.
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION)
|
102
scripts/win/cmake/mynteye-targets.cmake
Normal file
102
scripts/win/cmake/mynteye-targets.cmake
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
# Generated by CMake
|
||||||
|
|
||||||
|
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
|
||||||
|
message(FATAL_ERROR "CMake >= 2.6.0 required")
|
||||||
|
endif()
|
||||||
|
cmake_policy(PUSH)
|
||||||
|
cmake_policy(VERSION 2.6)
|
||||||
|
#----------------------------------------------------------------
|
||||||
|
# Generated CMake target import file.
|
||||||
|
#----------------------------------------------------------------
|
||||||
|
|
||||||
|
# Commands may need to know the format version.
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||||
|
|
||||||
|
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
|
||||||
|
set(_targetsDefined)
|
||||||
|
set(_targetsNotDefined)
|
||||||
|
set(_expectedTargets)
|
||||||
|
foreach(_expectedTarget mynteye)
|
||||||
|
list(APPEND _expectedTargets ${_expectedTarget})
|
||||||
|
if(NOT TARGET ${_expectedTarget})
|
||||||
|
list(APPEND _targetsNotDefined ${_expectedTarget})
|
||||||
|
endif()
|
||||||
|
if(TARGET ${_expectedTarget})
|
||||||
|
list(APPEND _targetsDefined ${_expectedTarget})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
|
||||||
|
unset(_targetsDefined)
|
||||||
|
unset(_targetsNotDefined)
|
||||||
|
unset(_expectedTargets)
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION)
|
||||||
|
cmake_policy(POP)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
if(NOT "${_targetsDefined}" STREQUAL "")
|
||||||
|
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
|
||||||
|
endif()
|
||||||
|
unset(_targetsDefined)
|
||||||
|
unset(_targetsNotDefined)
|
||||||
|
unset(_expectedTargets)
|
||||||
|
|
||||||
|
|
||||||
|
if(NOT MYNTEYES_SDK_ROOT)
|
||||||
|
if(DEFINED ENV{MYNTEYES_SDK_ROOT})
|
||||||
|
set(MYNTEYES_SDK_ROOT $ENV{MYNTEYES_SDK_ROOT})
|
||||||
|
else()
|
||||||
|
get_filename_component(MYNTEYES_SDK_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# The installation prefix configured by this project.
|
||||||
|
set(_IMPORT_PREFIX "${MYNTEYES_SDK_ROOT}")
|
||||||
|
|
||||||
|
# Create imported target mynteye
|
||||||
|
add_library(mynteye SHARED IMPORTED)
|
||||||
|
|
||||||
|
set_target_properties(mynteye PROPERTIES
|
||||||
|
INTERFACE_COMPILE_DEFINITIONS "GLOG_NO_ABBREVIATED_SEVERITIES"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
|
||||||
|
INTERFACE_LINK_LIBRARIES "opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_shape;opencv_stitching;opencv_superres;opencv_video;opencv_videoio;opencv_videostab;opencv_world"
|
||||||
|
)
|
||||||
|
|
||||||
|
if(CMAKE_VERSION VERSION_LESS 2.8.12)
|
||||||
|
message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Load information for each installed configuration.
|
||||||
|
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
file(GLOB CONFIG_FILES "${_DIR}/mynteye-targets-*.cmake")
|
||||||
|
foreach(f ${CONFIG_FILES})
|
||||||
|
include(${f})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Cleanup temporary variables.
|
||||||
|
set(_IMPORT_PREFIX)
|
||||||
|
|
||||||
|
# Loop over all imported files and verify that they actually exist
|
||||||
|
foreach(target ${_IMPORT_CHECK_TARGETS} )
|
||||||
|
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
|
||||||
|
if(NOT EXISTS "${file}" )
|
||||||
|
message(FATAL_ERROR "The imported target \"${target}\" references the file
|
||||||
|
\"${file}\"
|
||||||
|
but this file does not exist. Possible reasons include:
|
||||||
|
* The file was deleted, renamed, or moved to another location.
|
||||||
|
* An install or uninstall procedure did not complete successfully.
|
||||||
|
* The installation package was faulty and contained
|
||||||
|
\"${CMAKE_CURRENT_LIST_FILE}\"
|
||||||
|
but not all the files it references.
|
||||||
|
")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
unset(_IMPORT_CHECK_FILES_FOR_${target})
|
||||||
|
endforeach()
|
||||||
|
unset(_IMPORT_CHECK_TARGETS)
|
||||||
|
|
||||||
|
# This file does not depend on other imported targets which have
|
||||||
|
# been exported from the same project but in a separate export set.
|
||||||
|
|
||||||
|
# Commands beyond this point should not need to know the version.
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION)
|
||||||
|
cmake_policy(POP)
|
350
scripts/win/nsis/Include/EnvVarUpdate.nsh
Normal file
350
scripts/win/nsis/Include/EnvVarUpdate.nsh
Normal file
|
@ -0,0 +1,350 @@
|
||||||
|
/**
|
||||||
|
* EnvVarUpdate.nsh
|
||||||
|
* : Environmental Variables: append, prepend, and remove entries
|
||||||
|
*
|
||||||
|
* WARNING: If you use StrFunc.nsh header then include it before this file
|
||||||
|
* with all required definitions. This is to avoid conflicts
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* ${EnvVarUpdate} "ResultVar" "EnvVarName" "Action" "RegLoc" "PathString"
|
||||||
|
*
|
||||||
|
* Credits:
|
||||||
|
* Version 1.0
|
||||||
|
* * Cal Turney (turnec2)
|
||||||
|
* * Amir Szekely (KiCHiK) and e-circ for developing the forerunners of this
|
||||||
|
* function: AddToPath, un.RemoveFromPath, AddToEnvVar, un.RemoveFromEnvVar,
|
||||||
|
* WriteEnvStr, and un.DeleteEnvStr
|
||||||
|
* * Diego Pedroso (deguix) for StrTok
|
||||||
|
* * Kevin English (kenglish_hi) for StrContains
|
||||||
|
* * Hendri Adriaens (Smile2Me), Diego Pedroso (deguix), and Dan Fuhry
|
||||||
|
* (dandaman32) for StrReplace
|
||||||
|
*
|
||||||
|
* Version 1.1 (compatibility with StrFunc.nsh)
|
||||||
|
* * techtonik
|
||||||
|
*
|
||||||
|
* http://nsis.sourceforge.net/Environmental_Variables:_append%2C_prepend%2C_and_remove_entries
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
!ifndef ENVVARUPDATE_FUNCTION
|
||||||
|
!define ENVVARUPDATE_FUNCTION
|
||||||
|
!verbose push
|
||||||
|
!verbose 3
|
||||||
|
!include "LogicLib.nsh"
|
||||||
|
!include "WinMessages.NSH"
|
||||||
|
!include "StrFunc.nsh"
|
||||||
|
|
||||||
|
; ---- Fix for conflict if StrFunc.nsh is already includes in main file -----------------------
|
||||||
|
!macro _IncludeStrFunction StrFuncName
|
||||||
|
!ifndef ${StrFuncName}_INCLUDED
|
||||||
|
${${StrFuncName}}
|
||||||
|
!endif
|
||||||
|
!ifndef Un${StrFuncName}_INCLUDED
|
||||||
|
${Un${StrFuncName}}
|
||||||
|
!endif
|
||||||
|
!define un.${StrFuncName} "${Un${StrFuncName}}"
|
||||||
|
!macroend
|
||||||
|
|
||||||
|
!insertmacro _IncludeStrFunction StrTok
|
||||||
|
!insertmacro _IncludeStrFunction StrStr
|
||||||
|
!insertmacro _IncludeStrFunction StrRep
|
||||||
|
|
||||||
|
; ---------------------------------- Macro Definitions ----------------------------------------
|
||||||
|
!macro _EnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString
|
||||||
|
Push "${EnvVarName}"
|
||||||
|
Push "${Action}"
|
||||||
|
Push "${RegLoc}"
|
||||||
|
Push "${PathString}"
|
||||||
|
Call EnvVarUpdate
|
||||||
|
Pop "${ResultVar}"
|
||||||
|
!macroend
|
||||||
|
!define EnvVarUpdate '!insertmacro "_EnvVarUpdateConstructor"'
|
||||||
|
|
||||||
|
!macro _unEnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString
|
||||||
|
Push "${EnvVarName}"
|
||||||
|
Push "${Action}"
|
||||||
|
Push "${RegLoc}"
|
||||||
|
Push "${PathString}"
|
||||||
|
Call un.EnvVarUpdate
|
||||||
|
Pop "${ResultVar}"
|
||||||
|
!macroend
|
||||||
|
!define un.EnvVarUpdate '!insertmacro "_unEnvVarUpdateConstructor"'
|
||||||
|
; ---------------------------------- Macro Definitions end-------------------------------------
|
||||||
|
|
||||||
|
;----------------------------------- EnvVarUpdate start----------------------------------------
|
||||||
|
!define hklm_all_users 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
|
||||||
|
!define hkcu_current_user 'HKCU "Environment"'
|
||||||
|
|
||||||
|
!macro EnvVarUpdate UN
|
||||||
|
|
||||||
|
Function ${UN}EnvVarUpdate
|
||||||
|
|
||||||
|
Push $0
|
||||||
|
Exch 4
|
||||||
|
Exch $1
|
||||||
|
Exch 3
|
||||||
|
Exch $2
|
||||||
|
Exch 2
|
||||||
|
Exch $3
|
||||||
|
Exch
|
||||||
|
Exch $4
|
||||||
|
Push $5
|
||||||
|
Push $6
|
||||||
|
Push $7
|
||||||
|
Push $8
|
||||||
|
Push $9
|
||||||
|
Push $R0
|
||||||
|
|
||||||
|
/* After this point:
|
||||||
|
-------------------------
|
||||||
|
$0 = ResultVar (returned)
|
||||||
|
$1 = EnvVarName (input)
|
||||||
|
$2 = Action (input)
|
||||||
|
$3 = RegLoc (input)
|
||||||
|
$4 = PathString (input)
|
||||||
|
$5 = Orig EnvVar (read from registry)
|
||||||
|
$6 = Len of $0 (temp)
|
||||||
|
$7 = tempstr1 (temp)
|
||||||
|
$8 = Entry counter (temp)
|
||||||
|
$9 = tempstr2 (temp)
|
||||||
|
$R0 = tempChar (temp) */
|
||||||
|
|
||||||
|
; Step 1: Read contents of EnvVarName from RegLoc
|
||||||
|
;
|
||||||
|
; Check for empty EnvVarName
|
||||||
|
${If} $1 == ""
|
||||||
|
SetErrors
|
||||||
|
DetailPrint "ERROR: EnvVarName is blank"
|
||||||
|
Goto EnvVarUpdate_Restore_Vars
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
; Check for valid Action
|
||||||
|
${If} $2 != "A"
|
||||||
|
${AndIf} $2 != "P"
|
||||||
|
${AndIf} $2 != "R"
|
||||||
|
SetErrors
|
||||||
|
DetailPrint "ERROR: Invalid Action - must be A, P, or R"
|
||||||
|
Goto EnvVarUpdate_Restore_Vars
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
${If} $3 == HKLM
|
||||||
|
ReadRegStr $5 ${hklm_all_users} $1 ; Get EnvVarName from all users into $5
|
||||||
|
${ElseIf} $3 == HKCU
|
||||||
|
ReadRegStr $5 ${hkcu_current_user} $1 ; Read EnvVarName from current user into $5
|
||||||
|
${Else}
|
||||||
|
SetErrors
|
||||||
|
DetailPrint 'ERROR: Action is [$3] but must be "HKLM" or HKCU"'
|
||||||
|
Goto EnvVarUpdate_Restore_Vars
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
; Check for empty PathString
|
||||||
|
${If} $4 == ""
|
||||||
|
SetErrors
|
||||||
|
DetailPrint "ERROR: PathString is blank"
|
||||||
|
Goto EnvVarUpdate_Restore_Vars
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
;;khc - here check if length is going to be greater then max string length
|
||||||
|
;; and abort if so - also abort if original path empty - may mean
|
||||||
|
;; it was too long as well- write message to say set it by hand
|
||||||
|
Push $6
|
||||||
|
Push $7
|
||||||
|
Push $8
|
||||||
|
StrLen $7 $4
|
||||||
|
StrLen $6 $5
|
||||||
|
IntOp $8 $6 + $7
|
||||||
|
${If} $5 == ""
|
||||||
|
${OrIf} $8 >= ${NSIS_MAX_STRLEN}
|
||||||
|
SetErrors
|
||||||
|
DetailPrint "Current $1 length ($6) too long to modify in NSIS; set manually if needed"
|
||||||
|
Pop $8
|
||||||
|
Pop $7
|
||||||
|
Pop $6
|
||||||
|
Goto EnvVarUpdate_Restore_Vars
|
||||||
|
${EndIf}
|
||||||
|
Pop $8
|
||||||
|
Pop $7
|
||||||
|
Pop $6
|
||||||
|
;;khc
|
||||||
|
|
||||||
|
; Make sure we've got some work to do
|
||||||
|
${If} $5 == ""
|
||||||
|
${AndIf} $2 == "R"
|
||||||
|
SetErrors
|
||||||
|
DetailPrint "$1 is empty - Nothing to remove"
|
||||||
|
Goto EnvVarUpdate_Restore_Vars
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
; Step 2: Scrub EnvVar
|
||||||
|
;
|
||||||
|
StrCpy $0 $5 ; Copy the contents to $0
|
||||||
|
; Remove spaces around semicolons (NOTE: spaces before the 1st entry or
|
||||||
|
; after the last one are not removed here but instead in Step 3)
|
||||||
|
${If} $0 != "" ; If EnvVar is not empty ...
|
||||||
|
${Do}
|
||||||
|
${${UN}StrStr} $7 $0 " ;"
|
||||||
|
${If} $7 == ""
|
||||||
|
${ExitDo}
|
||||||
|
${EndIf}
|
||||||
|
${${UN}StrRep} $0 $0 " ;" ";" ; Remove '<space>;'
|
||||||
|
${Loop}
|
||||||
|
${Do}
|
||||||
|
${${UN}StrStr} $7 $0 "; "
|
||||||
|
${If} $7 == ""
|
||||||
|
${ExitDo}
|
||||||
|
${EndIf}
|
||||||
|
${${UN}StrRep} $0 $0 "; " ";" ; Remove ';<space>'
|
||||||
|
${Loop}
|
||||||
|
${Do}
|
||||||
|
${${UN}StrStr} $7 $0 ";;"
|
||||||
|
${If} $7 == ""
|
||||||
|
${ExitDo}
|
||||||
|
${EndIf}
|
||||||
|
${${UN}StrRep} $0 $0 ";;" ";"
|
||||||
|
${Loop}
|
||||||
|
|
||||||
|
; Remove a leading or trailing semicolon from EnvVar
|
||||||
|
StrCpy $7 $0 1 0
|
||||||
|
${If} $7 == ";"
|
||||||
|
StrCpy $0 $0 "" 1 ; Change ';<EnvVar>' to '<EnvVar>'
|
||||||
|
${EndIf}
|
||||||
|
StrLen $6 $0
|
||||||
|
IntOp $6 $6 - 1
|
||||||
|
StrCpy $7 $0 1 $6
|
||||||
|
${If} $7 == ";"
|
||||||
|
StrCpy $0 $0 $6 ; Change ';<EnvVar>' to '<EnvVar>'
|
||||||
|
${EndIf}
|
||||||
|
; DetailPrint "Scrubbed $1: [$0]" ; Uncomment to debug
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
/* Step 3. Remove all instances of the target path/string (even if "A" or "P")
|
||||||
|
$6 = bool flag (1 = found and removed PathString)
|
||||||
|
$7 = a string (e.g. path) delimited by semicolon(s)
|
||||||
|
$8 = entry counter starting at 0
|
||||||
|
$9 = copy of $0
|
||||||
|
$R0 = tempChar */
|
||||||
|
|
||||||
|
${If} $5 != "" ; If EnvVar is not empty ...
|
||||||
|
StrCpy $9 $0
|
||||||
|
StrCpy $0 ""
|
||||||
|
StrCpy $8 0
|
||||||
|
StrCpy $6 0
|
||||||
|
|
||||||
|
${Do}
|
||||||
|
${${UN}StrTok} $7 $9 ";" $8 "0" ; $7 = next entry, $8 = entry counter
|
||||||
|
|
||||||
|
${If} $7 == "" ; If we've run out of entries,
|
||||||
|
${ExitDo} ; were done
|
||||||
|
${EndIf} ;
|
||||||
|
|
||||||
|
; Remove leading and trailing spaces from this entry (critical step for Action=Remove)
|
||||||
|
${Do}
|
||||||
|
StrCpy $R0 $7 1
|
||||||
|
${If} $R0 != " "
|
||||||
|
${ExitDo}
|
||||||
|
${EndIf}
|
||||||
|
StrCpy $7 $7 "" 1 ; Remove leading space
|
||||||
|
${Loop}
|
||||||
|
${Do}
|
||||||
|
StrCpy $R0 $7 1 -1
|
||||||
|
${If} $R0 != " "
|
||||||
|
${ExitDo}
|
||||||
|
${EndIf}
|
||||||
|
StrCpy $7 $7 -1 ; Remove trailing space
|
||||||
|
${Loop}
|
||||||
|
${If} $7 == $4 ; If string matches, remove it by not appending it
|
||||||
|
StrCpy $6 1 ; Set 'found' flag
|
||||||
|
${ElseIf} $7 != $4 ; If string does NOT match
|
||||||
|
${AndIf} $0 == "" ; and the 1st string being added to $0,
|
||||||
|
StrCpy $0 $7 ; copy it to $0 without a prepended semicolon
|
||||||
|
${ElseIf} $7 != $4 ; If string does NOT match
|
||||||
|
${AndIf} $0 != "" ; and this is NOT the 1st string to be added to $0,
|
||||||
|
StrCpy $0 $0;$7 ; append path to $0 with a prepended semicolon
|
||||||
|
${EndIf} ;
|
||||||
|
|
||||||
|
IntOp $8 $8 + 1 ; Bump counter
|
||||||
|
${Loop} ; Check for duplicates until we run out of paths
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
; Step 4: Perform the requested Action
|
||||||
|
;
|
||||||
|
${If} $2 != "R" ; If Append or Prepend
|
||||||
|
${If} $6 == 1 ; And if we found the target
|
||||||
|
DetailPrint "Target is already present in $1. It will be removed and"
|
||||||
|
${EndIf}
|
||||||
|
${If} $0 == "" ; If EnvVar is (now) empty
|
||||||
|
StrCpy $0 $4 ; just copy PathString to EnvVar
|
||||||
|
${If} $6 == 0 ; If found flag is either 0
|
||||||
|
${OrIf} $6 == "" ; or blank (if EnvVarName is empty)
|
||||||
|
DetailPrint "$1 was empty and has been updated with the target"
|
||||||
|
${EndIf}
|
||||||
|
${ElseIf} $2 == "A" ; If Append (and EnvVar is not empty),
|
||||||
|
StrCpy $0 $0;$4 ; append PathString
|
||||||
|
${If} $6 == 1
|
||||||
|
DetailPrint "appended to $1"
|
||||||
|
${Else}
|
||||||
|
DetailPrint "Target was appended to $1"
|
||||||
|
${EndIf}
|
||||||
|
${Else} ; If Prepend (and EnvVar is not empty),
|
||||||
|
StrCpy $0 $4;$0 ; prepend PathString
|
||||||
|
${If} $6 == 1
|
||||||
|
DetailPrint "prepended to $1"
|
||||||
|
${Else}
|
||||||
|
DetailPrint "Target was prepended to $1"
|
||||||
|
${EndIf}
|
||||||
|
${EndIf}
|
||||||
|
${Else} ; If Action = Remove
|
||||||
|
${If} $6 == 1 ; and we found the target
|
||||||
|
DetailPrint "Target was found and removed from $1"
|
||||||
|
${Else}
|
||||||
|
DetailPrint "Target was NOT found in $1 (nothing to remove)"
|
||||||
|
${EndIf}
|
||||||
|
${If} $0 == ""
|
||||||
|
DetailPrint "$1 is now empty"
|
||||||
|
${EndIf}
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
; Step 5: Update the registry at RegLoc with the updated EnvVar and announce the change
|
||||||
|
;
|
||||||
|
ClearErrors
|
||||||
|
${If} $3 == HKLM
|
||||||
|
WriteRegExpandStr ${hklm_all_users} $1 $0 ; Write it in all users section
|
||||||
|
${ElseIf} $3 == HKCU
|
||||||
|
WriteRegExpandStr ${hkcu_current_user} $1 $0 ; Write it to current user section
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
IfErrors 0 +4
|
||||||
|
MessageBox MB_OK|MB_ICONEXCLAMATION "Could not write updated $1 to $3"
|
||||||
|
DetailPrint "Could not write updated $1 to $3"
|
||||||
|
Goto EnvVarUpdate_Restore_Vars
|
||||||
|
|
||||||
|
; "Export" our change
|
||||||
|
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
|
||||||
|
|
||||||
|
EnvVarUpdate_Restore_Vars:
|
||||||
|
;
|
||||||
|
; Restore the user's variables and return ResultVar
|
||||||
|
Pop $R0
|
||||||
|
Pop $9
|
||||||
|
Pop $8
|
||||||
|
Pop $7
|
||||||
|
Pop $6
|
||||||
|
Pop $5
|
||||||
|
Pop $4
|
||||||
|
Pop $3
|
||||||
|
Pop $2
|
||||||
|
Pop $1
|
||||||
|
Push $0 ; Push my $0 (ResultVar)
|
||||||
|
Exch
|
||||||
|
Pop $0 ; Restore his $0
|
||||||
|
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
!macroend ; EnvVarUpdate UN
|
||||||
|
!insertmacro EnvVarUpdate ""
|
||||||
|
!insertmacro EnvVarUpdate "un."
|
||||||
|
;----------------------------------- EnvVarUpdate end----------------------------------------
|
||||||
|
|
||||||
|
!verbose pop
|
||||||
|
!endif
|
BIN
scripts/win/nsis/mynt.ico
Normal file
BIN
scripts/win/nsis/mynt.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
197
scripts/win/nsis/winpack.nsi.in
Normal file
197
scripts/win/nsis/winpack.nsi.in
Normal file
|
@ -0,0 +1,197 @@
|
||||||
|
; winpack.nsi
|
||||||
|
|
||||||
|
!addincludedir scripts\win\nsis\Include
|
||||||
|
!include EnvVarUpdate.nsh
|
||||||
|
|
||||||
|
!addplugindir scripts\win\nsis\Plugins
|
||||||
|
|
||||||
|
!include WinMessages.nsh
|
||||||
|
|
||||||
|
!define VERSION "@mynteye_VERSION@"
|
||||||
|
!define OpenCV_VERSION "@OpenCV_VERSION@"
|
||||||
|
|
||||||
|
!define DSETDIR "$APPDATA"
|
||||||
|
;!define DSETDIR "$PROGRAMFILES64"
|
||||||
|
|
||||||
|
; HKLM (all users) vs HKCU (current user) defines
|
||||||
|
!define ENV_HKLM 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
|
||||||
|
!define ENV_HKCU 'HKCU "Environment"'
|
||||||
|
|
||||||
|
;--------------------------------
|
||||||
|
|
||||||
|
; The name of the installer
|
||||||
|
Name "MYNTEYE S SDK ${VERSION}"
|
||||||
|
|
||||||
|
; The icon of the installer
|
||||||
|
Icon "scripts\win\nsis\mynt.ico"
|
||||||
|
|
||||||
|
; The file to write
|
||||||
|
OutFile "mynteye-s-${VERSION}-win-x64-opencv-${OpenCV_VERSION}.exe"
|
||||||
|
|
||||||
|
; The default installation directory
|
||||||
|
InstallDir ${DSETDIR}\Slightech\MYNTEYES\SDK\${VERSION}
|
||||||
|
|
||||||
|
; Registry key to check for directory (so if you install again, it will
|
||||||
|
; overwrite the old one automatically)
|
||||||
|
InstallDirRegKey HKLM "Software\MYNTEYESSDK" "Install_Dir"
|
||||||
|
|
||||||
|
; Request application privileges for Windows Vista
|
||||||
|
;RequestExecutionLevel user
|
||||||
|
RequestExecutionLevel admin
|
||||||
|
|
||||||
|
;--------------------------------
|
||||||
|
|
||||||
|
; Pages
|
||||||
|
|
||||||
|
Page components
|
||||||
|
Page directory
|
||||||
|
Page instfiles
|
||||||
|
|
||||||
|
UninstPage uninstConfirm
|
||||||
|
UninstPage instfiles
|
||||||
|
|
||||||
|
;--------------------------------
|
||||||
|
|
||||||
|
; The stuff to install
|
||||||
|
Section "SDK (required)"
|
||||||
|
|
||||||
|
SectionIn RO
|
||||||
|
|
||||||
|
; Set output path to the installation directory.
|
||||||
|
SetOutPath $INSTDIR
|
||||||
|
|
||||||
|
; Put file there
|
||||||
|
File /r "mynteye-s-${VERSION}-win-x64\*"
|
||||||
|
|
||||||
|
; Write the installation path into the registry
|
||||||
|
WriteRegStr HKLM "SOFTWARE\MYNTEYESSDK" "Install_Dir" "$INSTDIR"
|
||||||
|
|
||||||
|
; Write the uninstall keys for Windows
|
||||||
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MYNTEYESSDK" "DisplayName" "MYNTEYE S SDK"
|
||||||
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MYNTEYESSDK" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||||
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MYNTEYESSDK" "NoModify" 1
|
||||||
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MYNTEYESSDK" "NoRepair" 1
|
||||||
|
WriteUninstaller "uninstall.exe"
|
||||||
|
|
||||||
|
; Set variables for local machine
|
||||||
|
WriteRegExpandStr ${ENV_HKLM} MYNTEYES_SDK_ROOT "$INSTDIR"
|
||||||
|
|
||||||
|
;${EnvVarUpdate} $0 "PATH" "P" "HKLM" "%MYNTEYES_SDK_PATH%"
|
||||||
|
${EnvVarUpdate} $0 "PATH" "P" "HKLM" "$INSTDIR\bin;$INSTDIR\3rdparty\opencv\build\x64\vc15\bin"
|
||||||
|
|
||||||
|
; Push "%MYNTEYES_SDK_PATH%"
|
||||||
|
; Call AddToPath
|
||||||
|
|
||||||
|
; Make sure windows knows about the change
|
||||||
|
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
; Optional section (can be disabled by the user)
|
||||||
|
Section "Desktop Shortcuts"
|
||||||
|
|
||||||
|
CreateShortcut "$DESKTOP\MYNTEYE S SDK ${VERSION}.lnk" "$INSTDIR" "" "$INSTDIR" 0
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Function .onInstSuccess
|
||||||
|
|
||||||
|
;WriteRegStr "HKLM" "SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" "View README" \
|
||||||
|
; "cmd.exe /c start /max notepad.exe $INSTDIR\README"
|
||||||
|
|
||||||
|
MessageBox MB_OKCANCEL "Reboot your system now?" /SD IDOK IDCANCEL NoReboot
|
||||||
|
Reboot
|
||||||
|
NoReboot:
|
||||||
|
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
Function .onInstFailed
|
||||||
|
MessageBox MB_OK "Install failed."
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
;--------------------------------
|
||||||
|
|
||||||
|
; Uninstaller
|
||||||
|
|
||||||
|
Section "Uninstall"
|
||||||
|
|
||||||
|
; Remove registry keys
|
||||||
|
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MYNTEYESSDK"
|
||||||
|
DeleteRegKey HKLM "SOFTWARE\MYNTEYESSDK"
|
||||||
|
|
||||||
|
; Remove install stuff
|
||||||
|
RMDir /r "$INSTDIR"
|
||||||
|
|
||||||
|
; Remove shortcuts, if any
|
||||||
|
Delete "$DESKTOP\MYNTEYE S SDK ${VERSION}.lnk"
|
||||||
|
|
||||||
|
; Remove directories used
|
||||||
|
StrCpy $0 "${DSETDIR}\Slightech\MYNTEYES"
|
||||||
|
Call un.DeleteDirIfEmpty
|
||||||
|
StrCpy $0 "${DSETDIR}\Slightech"
|
||||||
|
Call un.DeleteDirIfEmpty
|
||||||
|
|
||||||
|
RMDir /r "$APPDATA\Slightech\MYNTEYES"
|
||||||
|
StrCpy $0 "$APPDATA\Slightech"
|
||||||
|
Call un.DeleteDirIfEmpty
|
||||||
|
|
||||||
|
; Delete variables
|
||||||
|
DeleteRegValue ${ENV_HKLM} MYNTEYES_SDK_ROOT
|
||||||
|
|
||||||
|
;${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "%MYNTEYES_SDK_PATH%"
|
||||||
|
${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\bin"
|
||||||
|
${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\3rdparty\opencv\build\x64\vc15\bin"
|
||||||
|
|
||||||
|
; Push "%MYNTEYES_SDK_PATH%"
|
||||||
|
; Call un.RemoveFromPath
|
||||||
|
|
||||||
|
; Make sure windows knows about the change
|
||||||
|
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Function un.onUninstSuccess
|
||||||
|
MessageBox MB_OK "Uninstall success."
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
Function un.onUninstFailed
|
||||||
|
MessageBox MB_OK "Uninstall failed."
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
;--------------------------------
|
||||||
|
|
||||||
|
; DeleteDirIfEmpty - Delete dir only if empty
|
||||||
|
|
||||||
|
Function un.DeleteDirIfEmpty
|
||||||
|
FindFirst $R0 $R1 "$0\*.*"
|
||||||
|
strcmp $R1 "." 0 NoDelete
|
||||||
|
FindNext $R0 $R1
|
||||||
|
strcmp $R1 ".." 0 NoDelete
|
||||||
|
ClearErrors
|
||||||
|
FindNext $R0 $R1
|
||||||
|
IfErrors 0 NoDelete
|
||||||
|
FindClose $R0
|
||||||
|
Sleep 1000
|
||||||
|
RMDir "$0"
|
||||||
|
NoDelete:
|
||||||
|
FindClose $R0
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
;--------------------------------
|
||||||
|
|
||||||
|
; Path Manipulation
|
||||||
|
; http://nsis.sourceforge.net/Path_Manipulation
|
||||||
|
; Environmental Variables: append, prepend, and remove entries
|
||||||
|
; http://nsis.sourceforge.net/Environmental_Variables:_append%2C_prepend%2C_and_remove_entries
|
||||||
|
; Setting Environment Variables
|
||||||
|
; http://nsis.sourceforge.net/Setting_Environment_Variables
|
||||||
|
; Setting Environment Variables to Active Installer Process
|
||||||
|
; http://nsis.sourceforge.net/Setting_Environment_Variables_to_Active_Installer_Process
|
||||||
|
|
||||||
|
; Delete files and subdirectories
|
||||||
|
; http://nsis.sourceforge.net/Delete_files_and_subdirectories
|
||||||
|
; Delete dir only if empty
|
||||||
|
; http://nsis.sourceforge.net/Delete_dir_only_if_empty
|
||||||
|
|
||||||
|
;https://gist.github.com/azalea/deb3c1ed2a984eadf96be77b81dd49b1
|
||||||
|
;!include ProcessEnvPrependPath.nsh
|
|
@ -20,4 +20,79 @@ SCRIPTS_DIR=$(realpath "$BASE_DIR/..")
|
||||||
source "$SCRIPTS_DIR/common/echo.sh"
|
source "$SCRIPTS_DIR/common/echo.sh"
|
||||||
source "$SCRIPTS_DIR/common/detect.sh"
|
source "$SCRIPTS_DIR/common/detect.sh"
|
||||||
|
|
||||||
_echo_s "winpack.sh"
|
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() {
|
||||||
|
[ -e "$1" ] && (rm -r "$1" && _echo_in "RM: $1")
|
||||||
|
}
|
||||||
|
|
||||||
|
_md() {
|
||||||
|
[ ! -d "$1" ] && (mkdir -p "$1" && _echo_in "MD: $1")
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# build release
|
||||||
|
|
||||||
|
make install
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# 3rdparty/opencv
|
||||||
|
_md "$ROOT_DIR/_install/3rdparty"
|
||||||
|
mv "$ROOT_DIR/3rdparty/opencv" "$ROOT_DIR/_install/3rdparty/opencv"
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# archive exe
|
||||||
|
|
||||||
|
_pkgname=$1
|
||||||
|
mv "$ROOT_DIR/_install" "$ROOT_DIR/$_pkgname"
|
||||||
|
|
||||||
|
makensis "$ROOT_DIR/winpack.nsi"
|
||||||
|
|
||||||
|
mv "$ROOT_DIR/$_pkgname" "$ROOT_DIR/_install"
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# move back from _install
|
||||||
|
|
||||||
|
# 3rdparty/opencv
|
||||||
|
mv "$ROOT_DIR/_install/3rdparty/opencv" "$ROOT_DIR/3rdparty/opencv"
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# clean build
|
||||||
|
|
||||||
|
_rm "$ROOT_DIR/_build"
|
||||||
|
_rm "$ROOT_DIR/_output"
|
||||||
|
|
||||||
|
|
||||||
|
_echo_d "Win pack success"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user