mingw.nsh
来自「奇趣公司比较新的qt/emd版本」· NSH 代码 · 共 669 行 · 第 1/2 页
NSH
669 行
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 2007-2007 Trolltech ASA. All rights reserved.;;;; This file is part of the Windows installer of the Qt Toolkit.;;;; This file may be used under the terms of the GNU General Public;; License version 2.0 as published by the Free Software Foundation;; and appearing in the file LICENSE.GPL included in the packaging of;; this file. Please review the following information to ensure GNU;; General Public Licensing requirements will be met:;; http://trolltech.com/products/qt/licenses/licensing/opensource/;;;; If you are unsure which license is appropriate for your use, please;; review the following information:;; http://trolltech.com/products/qt/licenses/licensing/licensingoverview;; or contact the sales department at sales@trolltech.com.;;;; In addition, as a special exception, Trolltech gives you certain;; additional rights. These rights are described in the Trolltech GPL;; Exception version 1.0, which can be found at;; http://www.trolltech.com/products/qt/gplexception/ and in the file;; GPL_EXCEPTION.txt in this package.;;;; In addition, as a special exception, Trolltech, as the sole copyright;; holder for Qt Designer, grants users of the Qt/Eclipse Integration;; plug-in the right for the Qt/Eclipse Integration to link to;; functionality provided by Qt Designer and its related libraries.;;;; Trolltech reserves all rights not expressly granted herein.;;;; This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE;; WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;!ifdef MODULE_MINGW!macro MINGW_INITIALIZE!include "includes\qtcommon.nsh"!ifndef MODULE_MINGW_NAME !define MODULE_MINGW_NAME "Qt"!endif!ifndef MODULE_MINGW_VERSION !define MODULE_MINGW_VERSION "${PRODUCT_VERSION}"!endif!ifndef MODULE_MINGW_BUILDDIR !error "MODULE_MINGW_BUILDDIR not defined!"!endif!ifndef MODULE_MINGW_ROOT !error "MODULE_MINGW_ROOT not defined!"!endif!ifndef MODULE_MINGW_URL !define MODULE_MINGW_URL "ftp://ftp.trolltech.com/misc"!endif!ifndef MODULE_MINGW_COMPILERVERSION !define MODULE_MINGW_COMPILERVERSION "3.4.2"!endif!ifndef MODULE_MINGW_LICENSE !define MODULE_MINGW_LICENSE "C:\MinGW\COPYING"!endif!define MODULE_MINGW_DOWNLOADPAGE "gwdownload.ini"!define MODULE_MINGW_MIRRORPAGE "gwmirror.ini"!define MODULE_MINGW_RUNTIME_LIB "mingw*.dll"!define MODULE_MINGW_DOWNLOADFILE "MinGW-${MODULE_MINGW_COMPILERVERSION}"var MODULE_MINGW_DOWNLOADvar MODULE_MINGW_SOURCEDOWNLOADvar MODULE_MINGW_MIRRORSvar MODULE_MINGW_INSTOKvar MODULE_MINGW_COMPILERINSTDIRLangString ModuleMinGWTitle ${LANG_ENGLISH} "MinGW Installation"LangString ModuleMinGWDescription ${LANG_ENGLISH} "You need MinGW to be able to compile Qt applications."LangString ModuleMinGWMirrorTitle ${LANG_ENGLISH} "MinGW Download Mirror"LangString ModuleMinGWMirrorDescription ${LANG_ENGLISH} "Select a download mirror."Page custom ModuleMinGWDownloadPageEnter ModuleMinGWDownloadPageExit!define MUI_PAGE_CUSTOMFUNCTION_PRE ModuleMinGWLicensePageEnter!define MUI_PAGE_HEADER_TEXT "MinGW License Agreement"!define MUI_PAGE_HEADER_SUBTEXT "Please review the license terms before installing MinGW."!define MUI_LICENSEPAGE_TEXT_TOP "MinGW License Information"!insertmacro MUI_PAGE_LICENSE "${MODULE_MINGW_LICENSE}"Page custom ModuleMinGWMirrorPageEnter ModuleMinGWMirrorPageExit!include "includes\qtenv.nsh"!macroend!macro MINGW_SECTIONSSection "${MODULE_MINGW_NAME} ${MODULE_MINGW_VERSION}" MINGW_SEC01 strcmp "$MINGW_INSTDIR" "" 0 +5 StrCpy $MINGW_INSTDIR "$INSTDIR\${MODULE_MINGW_NAME} ${MODULE_MINGW_VERSION}" push $MINGW_INSTDIR call MakeQtDirectory pop $MINGW_INSTDIR WriteRegDWORD SHCTX "$PRODUCT_UNIQUE_KEY" "MINGWInstalled" 1 SetOutPath "$MINGW_INSTDIR" SetOverwrite ifnewer !insertmacro MODULE_MINGW_INSTALLFILES push "$MINGW_INSTDIR" call DeleteFloatingLicenseProgram push "$MINGW_INSTDIR\bin" call AddStartmenuApplication push ${MODULE_MINGW_BUILDDIR} push "$MINGW_INSTDIR" call PatchPrlFiles IfFileExists "$MINGW_INSTDIR\.qmake.cache" 0 +5 push "$MINGW_INSTDIR\.qmake.cache" push ${MODULE_MINGW_BUILDDIR} push $MINGW_INSTDIR call PatchPath IfFileExists "$MINGW_INSTDIR\mkspecs\default\qmake.conf" 0 +5 push "$MINGW_INSTDIR\mkspecs\default\qmake.conf" push ${MODULE_MINGW_BUILDDIR} push $MINGW_INSTDIR call PatchPath push $MINGW_INSTDIR call PatchCommonBinaryFiles push $MINGW_INSTDIR call PatchLicenseInformation WriteRegStr SHCTX "SOFTWARE\Trolltech\Common\${MODULE_MINGW_VERSION}\$LICENSE_PRODUCT" "Key" "$LICENSE_KEY" push $MINGW_INSTDIR call ModuleMinGWMakeEnvFile CreateShortCut "$SMPROGRAMS\$STARTMENU_STRING\${MODULE_MINGW_NAME} ${MODULE_MINGW_VERSION} Command Prompt.lnk" "%COMSPEC%" '/k "$MINGW_INSTDIR\bin\qtvars.bat"' CreateShortCut "$SMPROGRAMS\$STARTMENU_STRING\${MODULE_MINGW_NAME} ${MODULE_MINGW_VERSION} (Build Debug Libraries).lnk" "%COMSPEC%" '/k "$MINGW_INSTDIR\bin\qtvars.bat compile_debug"' push $0 strcmp $MODULE_MINGW_DOWNLOAD "no" DoneMinGWInstall DetailPrint "Installing MinGW into $MODULE_MINGW_COMPILERINSTDIR" WriteRegStr SHCTX "$PRODUCT_UNIQUE_KEY" "MinGWInstDir" "$MODULE_MINGW_COMPILERINSTDIR" nsExec::ExecToLog '"$MINGW_INSTDIR\downloads\${MODULE_MINGW_DOWNLOADFILE}.exe" /S /D=$MODULE_MINGW_COMPILERINSTDIR' pop $0 strcmp $MODULE_MINGW_SOURCEDOWNLOAD "no" DoneMinGWInstall DetailPrint "Installing MinGW sources into $MODULE_MINGW_COMPILERINSTDIR\src" WriteRegDWORD SHCTX "$PRODUCT_UNIQUE_KEY" "MinGWSources" 1 nsExec::ExecToLog '"$MINGW_INSTDIR\downloads\${MODULE_MINGW_DOWNLOADFILE}-src.exe" /S /D=$MODULE_MINGW_COMPILERINSTDIR\src' pop $0 DoneMinGWInstall: pop $0 DetailPrint "Copying MinGW runtime..." SetDetailsPrint none CopyFiles /SILENT "$MODULE_MINGW_COMPILERINSTDIR\bin\${MODULE_MINGW_RUNTIME_LIB}" "$MINGW_INSTDIR\bin" SetDetailsPrint bothSectionEndFunction EnableButtons Push $0 GetDlgItem $0 $HWNDPARENT 3 EnableWindow $0 1 GetDlgItem $0 $HWNDPARENT 1 EnableWindow $0 1 GetDlgItem $0 $HWNDPARENT 2 EnableWindow $0 1 Pop $0FunctionEndFunction DisableButtons Push $0 GetDlgItem $0 $HWNDPARENT 3 EnableWindow $0 0 GetDlgItem $0 $HWNDPARENT 1 EnableWindow $0 0 GetDlgItem $0 $HWNDPARENT 2 EnableWindow $0 0 Pop $0FunctionEndFunction ModuleMinGWDownloadPageEnter strcmp $MODULE_MINGW_INSTOK "yes" 0 +2 Abort !insertmacro MUI_HEADER_TEXT "$(ModuleMinGWTitle)" "$(ModuleMinGWTitleDescription)" Call UpdateCtrlStates !insertmacro MUI_INSTALLOPTIONS_DISPLAY "${MODULE_MINGW_DOWNLOADPAGE}" !insertmacro MUI_INSTALLOPTIONS_WRITE "${MODULE_MINGW_DOWNLOADPAGE}" "Field 8" "State" "0"FunctionEndFunction ModuleMinGWMirrorPageEnter strcmp $MODULE_MINGW_DOWNLOAD "yes" +2 Abort !insertmacro MUI_HEADER_TEXT "$(ModuleMinGWMirrorTitle)" "$(ModuleMinGWMirrorDescription)" !insertmacro MUI_INSTALLOPTIONS_DISPLAY "${MODULE_MINGW_MIRRORPAGE}"FunctionEndFunction ModuleMinGWLicensePageEnter strcmp $MODULE_MINGW_DOWNLOAD "yes" +2 AbortFunctionEndFunction UpdateCtrlStates push $0 push $1 push $2 !insertmacro MUI_INSTALLOPTIONS_READ $0 "${MODULE_MINGW_DOWNLOADPAGE}" "Field 8" "State" intop $0 $0 ! FindWindow $2 "#32770" "" $HWNDPARENT GetDlgItem $1 $2 1205 EnableWindow $1 $0 GetDlgItem $1 $2 1202 EnableWindow $1 $0 GetDlgItem $1 $2 1203 EnableWindow $1 $0 intop $0 $0 ! GetDlgItem $1 $2 1206 EnableWindow $1 $0 GetDlgItem $1 $2 1207 EnableWindow $1 $0 GetDlgItem $1 $2 1208 EnableWindow $1 $0 GetDlgItem $1 $HWNDPARENT 1 IntCmp $0 0 +3 SendMessage $1 ${WM_SETTEXT} 0 "STR:Next >" Goto +2 SendMessage $1 ${WM_SETTEXT} 0 "STR:Install" pop $2 pop $1 pop $0FunctionEndFunction ModuleMinGWDownloadPageExit push $0 push $1 !insertmacro MUI_INSTALLOPTIONS_READ $0 "${MODULE_MINGW_DOWNLOADPAGE}" "Settings" "State" strcmp "$0" "8" 0 NoNotify Call UpdateCtrlStates abort NoNotify: !insertmacro MUI_INSTALLOPTIONS_READ $0 "${MODULE_MINGW_DOWNLOADPAGE}" "Field 8" "State" strcmp "$0" "0" noDownload doDownloaddoDownload: !insertmacro MUI_INSTALLOPTIONS_READ $0 "${MODULE_MINGW_DOWNLOADPAGE}" "Field 6" "State" strcmp $0 "" 0 +3 MessageBox MB_ICONEXCLAMATION|MB_OK "You need to specify an installation directory!" goto tryAgain strcpy $MODULE_MINGW_COMPILERINSTDIR $0 strcpy $MODULE_MINGW_DOWNLOAD "yes" CreateDirectory "$MINGW_INSTDIR\downloads" Call DisableButtons InetLoad::load /BANNER "Mirror Download" "Downloading mirrors from server..." "${MODULE_MINGW_URL}/${MODULE_MINGW_DOWNLOADFILE}.mirrors" "$MINGW_INSTDIR\downloads\${MODULE_MINGW_DOWNLOADFILE}.mirrors" /END Pop $1 ;Get the return value Call EnableButtons StrCmp $1 "OK" +3 MessageBox MB_ICONEXCLAMATION|MB_RETRYCANCEL "Was not able to download mirror list ($1)." IDRETRY tryAgain 0 Quit call ModuleMinGWReadMirrors !insertmacro MUI_INSTALLOPTIONS_WRITE ${MODULE_MINGW_MIRRORPAGE} "Field 3" "ListItems" "$MODULE_MINGW_MIRRORS" goto donenoDownload: strcpy $MODULE_MINGW_DOWNLOAD "no" strcpy $MODULE_MINGW_SOURCEDOWNLOAD "no" call ModuleMinGWChecking strcmp $MODULE_MINGW_INSTOK "yes" done MessageBox MB_ICONEXCLAMATION|MB_YESNO "There is a problem with your MinGW installation:$\r$\n$MODULE_MINGW_INSTOK$\r$\nDo you still want to continue? (Your installation may not work)" IDNO tryAgain goto donetryAgain: pop $1 pop $0 Abortdone: pop $1 pop $0FunctionEndFunction ModuleMinGWMirrorPageExit push $0 push $2 push $1 !insertmacro MUI_INSTALLOPTIONS_READ $0 "${MODULE_MINGW_MIRRORPAGE}" "Field 3" "State" strcmp "$0" "" 0 +3 MessageBox MB_ICONEXCLAMATION|MB_OK "You must select a mirror to download from!" goto tryAgain push $0 call ModuleMinGWGetMirror pop $0 Call DisableButtons InetLoad::load /BANNER "MinGW Download" "Downloading MinGW from server..." "$0/${MODULE_MINGW_DOWNLOADFILE}.exe" "$MINGW_INSTDIR\downloads\${MODULE_MINGW_DOWNLOADFILE}.exe" /END Pop $2 ;get the return value Call EnableButtons StrCmp $2 "OK" +3 MessageBox MB_ICONEXCLAMATION|MB_OK "Was not able to download MinGW ($2). Please try another mirror." Goto tryAgain !insertmacro MUI_INSTALLOPTIONS_READ $1 "${MODULE_MINGW_MIRRORPAGE}" "Field 2" "State" strcmp "$1" "0" done Call DisableButtons InetLoad::load /BANNER "MinGW Sources Download" "Downloading MinGW Sources from server..." "$0/${MODULE_MINGW_DOWNLOADFILE}-src.exe" "$MINGW_INSTDIR\downloads\${MODULE_MINGW_DOWNLOADFILE}-src.exe" /END Pop $2 Call EnableButtons strcpy $MODULE_MINGW_SOURCEDOWNLOAD "yes" StrCmp $2 "OK" +3 MessageBox MB_ICONEXCLAMATION|MB_RETRYCANCEL "Was not able to download MinGW sources ($2). Please try another mirror?" IDRETRY tryAgain 0 Quit goto donetryAgain: pop $1 pop $2 pop $0 Abortdone:
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?