tools/installer/nsis/includes/qtenv.nsh
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       
     2 ;;
       
     3 ;; Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ;; All rights reserved.
       
     5 ;; Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 ;;
       
     7 ;; This file is part of the tools applications of the Qt Toolkit.
       
     8 ;;
       
     9 ;; $QT_BEGIN_LICENSE:LGPL$
       
    10 ;; No Commercial Usage
       
    11 ;; This file contains pre-release code and may not be distributed.
       
    12 ;; You may use this file in accordance with the terms and conditions
       
    13 ;; contained in the Technology Preview License Agreement accompanying
       
    14 ;; this package.
       
    15 ;;
       
    16 ;; GNU Lesser General Public License Usage
       
    17 ;; Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ;; General Public License version 2.1 as published by the Free Software
       
    19 ;; Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ;; packaging of this file.  Please review the following information to
       
    21 ;; ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ;; will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 ;;
       
    24 ;; In addition, as a special exception, Nokia gives you certain additional
       
    25 ;; rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ;; version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 ;;
       
    28 ;; If you have questions regarding the use of this file, please contact
       
    29 ;; Nokia at qt-info@nokia.com.
       
    30 ;;
       
    31 ;;
       
    32 ;;
       
    33 ;;
       
    34 ;;
       
    35 ;;
       
    36 ;;
       
    37 ;;
       
    38 ;; $QT_END_LICENSE$
       
    39 ;;
       
    40 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       
    41 !ifndef QTENV_INCLUDE
       
    42 !define QTENV_INCLUDE
       
    43 #
       
    44 # creates a qtvars.bat file in $QTDIR\bin
       
    45 # push "vs2003" #compiler
       
    46 # push "c:\qt"  #QTDIR
       
    47 # call MakeQtVarsFile
       
    48 #
       
    49 Function MakeQtVarsFile
       
    50   exch $1 ; QTDIR
       
    51   exch
       
    52   exch $3 ; vs version
       
    53   push $0 ; file handle
       
    54   push $2
       
    55   push $4
       
    56 
       
    57   push $3
       
    58   call GetMkSpec
       
    59   pop $2
       
    60 
       
    61   ClearErrors
       
    62   FileOpen $0 "$1\bin\qtvars.bat" w
       
    63   IfErrors done
       
    64   FileWrite $0 "@echo off$\r$\n"
       
    65   FileWrite $0 "rem$\r$\n"
       
    66   FileWrite $0 "rem This file is generated$\r$\n"
       
    67   FileWrite $0 "rem$\r$\n"
       
    68   FileWrite $0 "$\r$\n"
       
    69   FileWrite $0 "echo Setting up a Qt environment...$\r$\n"
       
    70   FileWrite $0 "echo -- QTDIR set to $1$\r$\n"
       
    71   FileWrite $0 "echo -- Added $1\bin to PATH$\r$\n"
       
    72   FileWrite $0 "echo -- QMAKESPEC set to $2$\r$\n"
       
    73   FileWrite $0 "$\r$\n"
       
    74   FileWrite $0 "set QTDIR=$1$\r$\n"
       
    75   FileWrite $0 "set PATH=$1\bin;%PATH%$\r$\n"
       
    76   FileWrite $0 "set QMAKESPEC=$2$\r$\n"
       
    77   
       
    78   call IsExpressVersion
       
    79   pop $4
       
    80   strcmp $4 "" noExpressVersion
       
    81   FileWrite $0 "$\r$\n"
       
    82   FileWrite $0 'regedit /e S$$D$$K$$ "HKEY_LOCAL_MACHINE\Software\Microsoft\MicrosoftSDK"$\r$\n'
       
    83   Filewrite $0 'if not exist S$$D$$K$$ goto ENDSDK\r$\n'
       
    84   FileWrite $0 'find "Install Dir" < S$$D$$K$$ > D$$I$$R$$$\r$\n'
       
    85   FileWrite $0 'del S$$D$$K$$$\r$\n'
       
    86   FileWrite $0 'for /f "tokens=2 delims==" %%i in (D$$I$$R$$) do call %%i\setenv$\r$\n'
       
    87   FileWrite $0 'del D$$I$$R$$$\r$\n'
       
    88   Filewrite $0 ':ENDSDK\r$\n'
       
    89   noExpressVersion:
       
    90 
       
    91   push $3
       
    92   call GetVSVarsFile
       
    93   pop $2
       
    94   strcmp $2 "" novsvars
       
    95     FileWrite $0 "$\r$\n"
       
    96     FileWrite $0 'if not "%1"=="vsvars" goto END$\r$\n'
       
    97     FileWrite $0 'call "$2"$\r$\n'
       
    98     FileWrite $0 ":END$\r$\n"
       
    99 
       
   100     FileWrite $0 "$\r$\n"
       
   101     FileWrite $0 'if not "%1"=="vsstart" goto ENDSTARTVS$\r$\n'
       
   102     FileWrite $0 'call "$2"$\r$\n'
       
   103 
       
   104     strcmp $3 "vc60" vc60startup
       
   105       FileWrite $0 "devenv /useenv$\r$\n"
       
   106       Goto donevsstartup
       
   107     vc60startup:
       
   108       FileWrite $0 "msdev /useenv$\r$\n"
       
   109     donevsstartup:
       
   110     
       
   111     FileWrite $0 ":ENDSTARTVS$\r$\n"
       
   112     
       
   113   novsvars:
       
   114   FileWrite $0 "$\r$\n"
       
   115   FileClose $0
       
   116   done:
       
   117   pop $4
       
   118   pop $2
       
   119   pop $0
       
   120   pop $3
       
   121   pop $1
       
   122 FunctionEnd
       
   123 
       
   124 Function GetMkSpec
       
   125   exch $0
       
   126   StrCmp $0 "mingw" MINGW
       
   127   StrCmp $0 "vs2005" VS2005
       
   128   StrCmp $0 "vs2003" VS2003
       
   129   StrCmp $0 "vs2002" VS2002
       
   130   StrCmp $0 "vc60" VS60
       
   131   StrCmp $0 "icc" ICC
       
   132 
       
   133   MINGW:
       
   134   pop $0
       
   135   push "win32-g++"
       
   136   goto done
       
   137 
       
   138   VS2005:
       
   139   pop $0
       
   140   push "win32-msvc2005"
       
   141   goto done
       
   142 
       
   143   VS2003:
       
   144   pop $0
       
   145   push "win32-msvc.net"
       
   146   goto done
       
   147 
       
   148   VS2002:
       
   149   pop $0
       
   150   push "win32-msvc.net"
       
   151   goto done
       
   152 
       
   153   VS60:
       
   154   pop $0
       
   155   push "win32-msvc"
       
   156   goto done
       
   157   
       
   158   ICC:
       
   159   pop $0
       
   160   push "win32-icc"
       
   161   goto done
       
   162 
       
   163   done:
       
   164 FunctionEnd
       
   165 
       
   166 !define AD_COMPILER_NAME_VS2005 "Visual Studio .NET 2005"
       
   167 !define AD_COMPILER_NAME_VS2005_EXPRESS "Visual C++ 2005 Express Edition"
       
   168 !define AD_COMPILER_NAME_VS2003 "Visual Studio .NET 2003"
       
   169 !define AD_COMPILER_NAME_VS2002 "Visual Studio .NET 2002"
       
   170 !define AD_COMPILER_NAME_VC60 "Visual Studio 6.0"
       
   171 !define AD_COMPILER_NAME_ICC "Intel C++ Compiler"
       
   172 !define AD_COMPILER_NAME_MINGW "MinGW (Must be in PATH!)"
       
   173 
       
   174 Function GetShortCompilerName
       
   175   exch $0
       
   176 
       
   177   strcmp "$0" "${AD_COMPILER_NAME_VS2005}" 0 +3
       
   178   strcpy $0 "vs2005"
       
   179   goto done
       
   180 
       
   181   strcmp "$0" "${AD_COMPILER_NAME_VS2005_EXPRESS}" 0 +3
       
   182   strcpy $0 "vs2005"
       
   183   goto done
       
   184   
       
   185   strcmp "$0" "${AD_COMPILER_NAME_VS2003}" 0 +3
       
   186   strcpy $0 "vs2003"
       
   187   goto done
       
   188 
       
   189   strcmp "$0" "${AD_COMPILER_NAME_VS2002}" 0 +3
       
   190   strcpy $0 "vs2002"
       
   191   goto done
       
   192 
       
   193   strcmp "$0" "${AD_COMPILER_NAME_VC60}" 0 +3
       
   194   strcpy $0 "vc60"
       
   195   goto done
       
   196 
       
   197   strcmp "$0" "${AD_COMPILER_NAME_ICC}" 0 +3
       
   198   strcpy $0 "icc"
       
   199   goto done
       
   200 
       
   201   strcmp "$0" "${AD_COMPILER_NAME_MINGW}" 0 +3
       
   202   strcpy $0 "mingw"
       
   203   goto done
       
   204 
       
   205   strcpy $0 "" ;this is bad!
       
   206 
       
   207   done:
       
   208   exch $0
       
   209 FunctionEnd
       
   210 
       
   211 Function IsExpressVersion
       
   212   push $0
       
   213   ReadRegStr $0 HKLM "Software\Microsoft\VCExpress\8.0" "InstallDir"
       
   214   ClearErrors
       
   215   exch $0
       
   216 FunctionEnd
       
   217 
       
   218 Function AutoDetectCompilers
       
   219   push $0
       
   220   push $1
       
   221   
       
   222   strcpy $1 ""
       
   223   
       
   224   ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\8.0" "InstallDir"
       
   225   strcmp $0 "" +2
       
   226   strcpy $1 "$1${AD_COMPILER_NAME_VS2005}|"
       
   227 
       
   228   ReadRegStr $0 HKLM "Software\Microsoft\VCExpress\8.0" "InstallDir"
       
   229   strcmp $0 "" +2
       
   230   strcpy $1 "$1${AD_COMPILER_NAME_VS2005_EXPRESS}|"
       
   231 
       
   232   ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\7.1" "InstallDir"
       
   233   strcmp $0 "" +2
       
   234   strcpy $1 "$1${AD_COMPILER_NAME_VS2003}|"
       
   235 
       
   236   ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\7.0" "InstallDir"
       
   237   strcmp $0 "" +2
       
   238   strcpy $1 "$1${AD_COMPILER_NAME_VS2002}|"
       
   239 
       
   240   ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\6.0\Setup" "VsCommonDir"
       
   241   strcmp $0 "" +2
       
   242   strcpy $1 "$1${AD_COMPILER_NAME_VC60}|"
       
   243 
       
   244   ReadRegStr $0 HKLM "Software\Intel\Compilers\C++\80" "Major Version"
       
   245   strcmp $0 "" +2
       
   246   strcpy $1 "$1${AD_COMPILER_NAME_ICC}|"
       
   247   
       
   248   strcpy $1 "$1${AD_COMPILER_NAME_MINGW}"
       
   249   
       
   250   exch
       
   251   pop $0
       
   252   exch $1
       
   253 FunctionEnd
       
   254 
       
   255 Function GetVSVarsFile
       
   256   exch $1
       
   257   push $0
       
   258 
       
   259   StrCmp $1 "vs2005" VS2005
       
   260   StrCmp $1 "vs2003" VS2003
       
   261   StrCmp $1 "vs2002" VS2002
       
   262   StrCmp $1 "vc60" VS60
       
   263 
       
   264   push "" ;empty string if not found
       
   265   goto done
       
   266 
       
   267   VS2005:
       
   268   ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\8.0\Setup\VS" "ProductDir"
       
   269   StrCmp $0 "" +1 foundVSDir ; found msvc.net 2005
       
   270 
       
   271   ReadRegStr $0 HKLM "Software\Microsoft\VCExpress\8.0\Setup\VS" "ProductDir"
       
   272   StrCmp $0 "" +1 foundVSDir ; found msvc.net 2005 epress
       
   273 
       
   274   VS2003:
       
   275   ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\7.1\Setup\VS" "ProductDir"
       
   276   StrCmp $0 "" +1 foundVSDir ; found msvc.net 2003
       
   277 
       
   278   VS2002:
       
   279   ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\7.0\Setup\VS" "ProductDir"
       
   280   StrCmp $0 "" +1 foundVSDir ; found msvc.net 2002
       
   281 
       
   282   VS60:
       
   283   ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++" "ProductDir"
       
   284   StrCmp $0 "" +1 foundVCDir ; found msvc 6.0
       
   285 
       
   286   push "" ;empty string if not found
       
   287   goto done
       
   288 
       
   289   foundVSDir:
       
   290     push "$0\Common7\Tools\vsvars32.bat"
       
   291     goto done
       
   292 
       
   293   foundVCDir:
       
   294     push "$0\bin\vcvars32.bat"
       
   295 
       
   296   done:
       
   297     exch
       
   298     pop $0
       
   299     exch
       
   300     pop $1
       
   301 FunctionEnd
       
   302 
       
   303 !endif ;QTENV_INCLUDE