Subversion Repositories gelsvn

Rev

Rev 286 | Blame | Compare with Previous | Last modification | View Log | RSS feed

!include "LogicLib.nsh" 
!include "WinMessages.NSH"

!define TEMP1 $R0 ;Temp variable

; The name of the installer
Name "GEL Externals"

; The file to write
OutFile "GELsetup.exe"

; The default installation directory
InstallDir H:\GEL

; Show install details
ShowInstDetails show

;Things that need to be extracted on startup (keep these lines before any File command!)
;Only useful for BZIP2 compression
;Use ReserveFile for your own InstallOptions INI files too!

ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
ReserveFile "custdir.ini"


;--------------------------------

; Pages

;Page directory
Page custom SetCustom "" ": Installation Folder"
Page components

InstType "Externals only"
InstType "Full"

Section "Externals" Externals_flag
SectionIn 1 2
SectionEnd

SectionGroup "GEL binary (ver. 0.1)"

Section "CGLA" CGLA_flag
SectionIn 2
SectionEnd


Section "Geometry" Geometry_flag
SectionIn 2
SectionEnd

Section "GLGraphics" GLGraphics_flag
SectionIn 2
SectionEnd

Section "HMesh" HMesh_flag
SectionIn 2
SectionEnd

Section "LinAlg" LinAlg_flag
SectionIn 2
SectionEnd

Section "Util" Util_flag
SectionIn 2
SectionEnd

SectionGroupEnd



Page instfiles

;--------------------------------



Section ""

  ReadINIStr $INSTDIR "$PLUGINSDIR\custdir.ini" "Field 2" "State"
   
  Var /GLOBAL Externals
  Var /GLOBAL CGLA
  Var /GLOBAL Geometry 
  Var /GLOBAL GLGraphics 
  Var /GLOBAL HMesh 
  Var /GLOBAL LinAlg
  Var /GLOBAL Util 
 
  # Get flags of each section into appropriate variables
  SectionGetFlags ${Externals_flag} $Externals
  SectionGetFlags ${CGLA_flag} $CGLA 
  SectionGetFlags ${Geometry_flag} $Geometry
  SectionGetFlags ${GLGraphics_flag} $GLGraphics
  SectionGetFlags ${HMesh_flag} $HMesh
  SectionGetFlags ${LinAlg_flag} $LinAlg
  SectionGetFlags ${Util_flag} $Util
  
  ;MessageBox MB_OK "Externals: $0 $\r$\n GEL: $1 $\r$\n "

  ${If} $Externals = 1
    SetOutPath $INSTDIR\bin
    File externals\bin\*.dll 
   
    SetOutPath $INSTDIR\lib
    File externals\lib\*.lib 

    SetOutPath $INSTDIR
    File /r externals\include
  ${EndIf}

  !macro GELModule mvar mstring
    ${If} ${mvar} = 1
      SetOutPath $INSTDIR\lib
      File current\lib\${mstring}.lib 

      SetOutPath $INSTDIR\include
      File /r current\include\${mstring}
    ${EndIf}
  !macroend

  !insertmacro GELModule $CGLA "CGLA"
  !insertmacro GELModule $Geometry "Geometry"
  !insertmacro GELModule $GLGraphics "GLGraphics"
  !insertmacro GELModule $HMesh "HMesh"
  !insertmacro GELModule $LinAlg "LinAlg"
  !insertmacro GELModule $Util "Util"

  # Create Environment variables

  ReadINIStr $R2 "$PLUGINSDIR\custdir.ini" "Field 3" "State"
  ReadINIStr $R3 "$PLUGINSDIR\custdir.ini" "Field 4" "State"

  ${If} $R2 = 0
    WriteRegExpandStr 'HKLM' "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "GEL_INCLUDE" "$INSTDIR\include"
    WriteRegExpandStr 'HKLM' "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "GEL_LIB" "$INSTDIR\lib"
    WriteRegExpandStr 'HKLM' "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "GEL_BIN" "$INSTDIR\bin"

  ${Else}
    WriteRegExpandStr 'HKCU' "Environment" "GEL_INCLUDE" "$INSTDIR\include"
    WriteRegExpandStr 'HKCU' "Environment" "GEL_LIB" "$INSTDIR\lib"
    WriteRegExpandStr 'HKCU' "Environment" "GEL_BIN" "$INSTDIR\bin"

  ${EndIf}

 ; ClearErrors
 ; FileOpen $0 $INSTDIR\bin\setenvvars.bat w
 ; IfErrors done
 ; FileWrite $0 "set GEL_INCLUDE=$INSTDIR\include"
 ; FileWriteByte $0 "13"
 ; FileWriteByte $0 "10"
 ; FileWrite $0 "set GEL_LIB=$INSTDIR\lib"
 ; FileWriteByte $0 "13"
 ; FileWriteByte $0 "10"
 ; FileWrite $0 "set GEL_BIN=$INSTDIR\bin"
 ; FileWriteByte $0 "13"
 ; FileWriteByte $0 "10"
 ; FileClose $0
 ; done:
  
  # Add %GEL_BIN% to path
  
  ${If} $R2 = 0
    ReadRegStr $1 'HKLM' "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH"
  ${Else}
    ReadRegStr $1 'HKCU' "Environment" "PATH"
  ${EndIf}

  StrCpy $2 $1 1 -1 # copy last char
  StrCmp $2 ";" 0 +2 # if last char == ;
    StrCpy $1 $1 -1 # remove last char
  StrCmp $1 "" AddToPath_NTdoIt
    StrCpy $0 "$1;$INSTDIR\bin"
  AddToPath_NTdoIt:
    ${If} $R2 = 0
      WriteRegExpandStr 'HKLM' "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $0
    ${Else}
      WriteRegExpandStr 'HKCU' "Environment" "PATH" $0
    ${EndIf}
    SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000


SectionEnd ; end the section

Function .onInit

  ;Extract InstallOptions files
  ;$PLUGINSDIR will automatically be removed when the installer closes

  InitPluginsDir
  File /oname=$PLUGINSDIR\custdir.ini "custdir.ini"
  WriteINIStr  "$PLUGINSDIR\custdir.ini" "Field 2" "State" $INSTDIR


FunctionEnd

Function SetCustom

  ;Display the InstallOptions dialog

  Push ${TEMP1}

    InstallOptions::dialog "$PLUGINSDIR\custdir.ini"
    Pop ${TEMP1}

  Pop ${TEMP1}

FunctionEnd