Psi-Qt4-Windows Build Scripts

From PsiWiki

Disclaimer: These instructions are unofficial and may or may not work for you.

This page contains scripts for building Psi-Qt4 on Windows platform.

Notes:

  • If You were looking for scripts for building Psi on Windows, please consult Psi/Windows build scripts article.
  • These scripts may take the advantages of superior command-line cmd.exe found in Windows NT/2000/XP/Server 2003 and may not work properly on Windows 95/98/Me.

Contents

Main worker script

This script does the main job compiling Psi-Qt4 and is called from inside other scripts. Should not be called directly from the command-line. It must be placed in makewin_build.bat file in order for other scripts to work properly.

 @echo off
 
 if "%1" == "" goto NoArgs
 
 REM ----- Setup compilation and release process -----
 
 set name=Psi-Qt4 for Windows
 set project=psi.pro
 set outdir=psiwin
 set binary=Psi.exe
 
 set system=%windir%\system
 if "%OS%" == "Windows_NT" set system=%system%32
 
 call %1 > nul
 shift
 
 REM ----- Compile and link Psi -----
 
 echo This will compile, link and release %name%.
 echo STEP 1: Create Makefile for QCA
 title Creating Makefile for QCA...
 cd ..\qca2
 qmake qca.pro > ..\psi-qt4\makewin.log
 if errorlevel 1 goto NoQMake
 echo STEP 2: Compile QCA
 title Compiling QCA...
 %MAKE% qmake_all >> ..\psi-qt4\makewin.log
 cd src
 %MAKE% release >> ..\..\psi-qt4\makewin.log
 cd ..
 copy lib\qca2.lib ..\psi-qt4\src\ > nul
 copy lib\qca2.lib ..\qca2-openssl\ > nul
 cd ..\psi-qt4
 echo STEP 3: Create Makefile for %name%
 title Creating Makefile for %name%...
 qmake %project% > makewin.log
 if errorlevel 1 goto NoQMake
 echo STEP 4: Compile %name%
 title Compiling %name%...
 %MAKE% qmake_all >> makewin.log
 cd src
 %MAKE% release >> ..\makewin.log
 cd ..
 if errorlevel 1 goto CompileFailed
 echo STEP 5: Create Makefile for QCA-OpenSSL plugin for %name%
 title Creating Makefile for QCA-OpenSSL plugin for %name%...
 cd ..\qca2-openssl
 qmake qca-openssl.pro >> ..\psi-qt4\makewin.log
 echo STEP 6: Compile QCA-OpenSSL plugin for %name%
 title Compiling QCA-OpenSSL plugin for %name%...
 %MAKE% release >> ..\psi-qt4\makewin.log
 if errorlevel 1 goto CompileFailed
 cd ..
 
 REM ----- Copy output to single directory -----
 
 :Release
 echo STEP 7: Prepare for release of %name%
 title Preparing for release of %name%...
 if exist %outdir% rmdir /s /q %outdir%
 mkdir %outdir%
 copy src\release\%binary% %outdir% > nul
 copy %QTDIR%\bin\qt*4.dll %outdir% > nul
 del %outdir%\qt*d4.dll > nul
 mkdir %outdir%\crypto
 copy ..\qca2-openssl\release\qca-openssl.dll %outdir%\crypto > nul
 copy ..\qca2\lib\qca2.dll %outdir% > nul
 copy %system%\libeay32.dll %outdir% > nul
 copy %system%\ssleay32.dll %outdir% > nul
 xcopy /d /e certs %outdir%\certs\ > nul
 xcopy /d /e iconsets %outdir%\iconsets\ > nul
 xcopy /d /e sound %outdir%\sound\ > nul
 copy COPYING %outdir% > nul
 copy README %outdir% > nul
 
 REM ----- Process succeeded -----
 
 :Finished
 echo Seems that %name% is ready for distibution.
 title Done.
 goto End
 
 REM ----- Error handling -----
 
 :NoArgs
 echo No arguments at command line.
 goto End
 
 :NoQMake
 echo Failed to run 'qmake'. Are you sure you have Qt4 set up?
 goto End
 
 :CopyFailed
 echo Copy failed, stopping.
 goto End
 
 :CompileFailed
 echo Compile failed, stopping. See 'makewin.log' file for details.
 goto End
     
 REM ----- Cleanup -----
 
 :End
 set name=
 set project=
 set outdir=
 set binary=
 set system=

Compiler specific scripts

This section provides compiler-specific scripts - each compiler is provided with two scripts - one setup and one driver.

MinGW specific scripts

Setup script

This script sets up the environment for MinGW compiler. It must be named setup_g++.bat.

 @echo off
 :: Set paths for Qt 4.1.0/OpenSource
 set QTDIR=C:\Qt\4.1.0
 :: Set paths and variables for MinGW (g++)
 call "%QTDIR%\bin\qtvars.bat"
 
 :: Set names for some tools
 set MAKE=mingw-win32

Note:

  • You might need to change the location of Your Qt4/OpenSource installation (C:\Qt\4.1.0 here).

Driver script

This script drives the whole build process for MinGW compiler. I prefer it to be named makewin_g++.bat, but any name is good.

 @echo off
 call makewin_build.bat setup_g++.bat %1

You run this script to build Psi-Qt4/Windows using MinGW.

Microsoft Visual C++ .NET scripts

Setup script

This script sets up the environment for Microsoft Visual C++ .NET compiler. It must be named setup_msvc.net.bat.

 @echo off
 :: Set paths and variables for Microsoft Visual C++ .NET 2003
 call "%VS71COMNTOOLS%vsvars32.bat"
 :: Append Microsoft Platform SDK (comment out if not installed)
 set INCLUDE=C:\Progra~1\Micros~2\include;%INCLUDE%
 set LIB=C:\Progra~1\Micros~2\lib;%LIB%
 :: Set paths for Qt 4.1.0/OpenSource for VS.NET
 set QTDIR=C:\Qt\4.1.0
 set QMAKESPEC=win32-msvc.net
 set PATH=%QTDIR%\bin;%PATH%
 
 :: Set names for some tools
 set MAKE=nmake /nologo

Notes:

  • You might need to change the location of Your Qt4/OpenSource installation (C:\Qt\4.1.0 here).
  • If You use Microsoft Visual C++ .NET (a.k.a. Microsoft Visual C++ .NET 2002) compiler, You need to replace %VS71COMNTOOLS% with %VSCOMNTOOLS% in order for the script to work correctly.
  • If You have no Microsoft Platform SDK installed, delete following lines from the above script:
 :: Append Microsoft Platform SDK (comment out if not installed)
 set INCLUDE=C:\Progra~1\Micros~2\include;%INCLUDE%
 set LIB=C:\Progra~1\Micros~2\lib;%LIB%

Otherwise, You have to replace C:\Progra~1\Micros~2 with the short path to Microsoft Platform SDK installation directory. It can be obtained by running the following command:

 dir /x "%programfiles%\*Platform*"

%programfiles% is usually C:\Progra~1.

Driver script

This script drives the whole build process for Microsoft Visual C++ .NET compiler. I prefer it to be named makewin_msvc.net.bat, but any name is good.

 @echo off
 call makewin_build.bat setup_msvc.net.bat %1

You run this script to build Psi-Qt4/Windows using Microsoft Visual C++ .NET.

Microsoft Visual C++ 2005 scripts

Setup script

This script sets up the environment for Microsoft Visual C++ 2005 compiler. It must be named setup_msvc2005.bat.

 @echo off
 :: Set paths and variables for Microsoft Visual C++ 2005
 call "%VS80COMNTOOLS%vsvars32.bat"
 :: Set paths for Qt 4.1.0/OpenSource for VS2005
 set QTDIR=C:\Qt\4.1.0
 set QMAKESPEC=win32-msvc2005
 set PATH=%QTDIR%\bin;%PATH%
 
 :: Set names for some tools
 set MAKE=nmake /nologo

Notes:

  • You might need to change the location of Your Qt4/OpenSource installation (C:\Qt\4.1.0 here).

Driver script

This script drives the whole build process for Microsoft Visual C++ 2005 compiler. I prefer it to be named makewin_msvc2005.bat, but any name is good.

 @echo off
 call makewin_build.bat setup_msvc2005.bat %1

You run this script to build Psi-Qt4/Windows using Microsoft Visual C++ 2005.

Cleanup script

This script cleans up the source directories of Psi-Qt4, QCA2 and QCA-OpenSSL and prepares them for complete rebuild. I prefer it to be named makewin_clean.bat.

 @echo off
 
 if not exist lang goto psiwidgets
 cd lang
 if exist *.qm          del *.qm
 cd ..
 
 :psiwidgets
 if not exist libpsi\psiwidgets goto qca
 cd libpsi\psiwidgets
 if exist tmp           rmdir /s /q tmp
 if exist debug         rmdir /s /q debug
 if exist release       rmdir /s /q release
 if exist *.dll         del *.dll
 if exist *.exp         del *.exp
 if exist *.idb         del *.idb
 if exist *.lib         del *.lib
 if exist moc_*.*       del moc_*.*
 if exist *.moc         del *.moc
 if exist *.o           del *.o
 if exist *.obj         del *.obj
 if exist *.pdb         del *.pdb
 if exist *.so          del *.so
 if exist *.tds         del *.tds
 if exist Makefile      del Makefile
 if exist *.Debug       del *.Debug
 if exist *.Release     del *.Release
 cd ..\..
 
 :qca
 if not exist ..\qca2 goto tls
 cd ..\qca2
 for /r %%x in (.) do (
   if exist %%x\.moc      rmdir /s /q %%x\.moc
   if exist %%x\.obj      rmdir /s /q %%x\.obj
   if exist %%x\.ui       rmdir /s /q %%x\.ui
   if exist %%x\moc       rmdir /s /q %%x\moc
   if exist %%x\obj       rmdir /s /q %%x\obj
   if exist %%x\ui        rmdir /s /q %%x\ui
   if exist %%x\debug     rmdir /s /q %%x\debug
   if exist %%x\release   rmdir /s /q %%x\release
   if exist %%x\bin       rmdir /s /q %%x\bin
   if exist %%x\lib       rmdir /s /q %%x\lib
   if exist %%x\*.dll     del %%x\*.dll
   if exist %%x\*.exp     del %%x\*.exp
   if exist %%x\*.idb     del %%x\*.idb
   if exist %%x\*.lib     del %%x\*.lib
   if exist %%x\*.moc     del %%x\*.moc
   if exist %%x\*.o       del %%x\*.o
   if exist %%x\*.obj     del %%x\*.obj
   if exist %%x\*.pdb     del %%x\*.pdb
   if exist %%x\*.so      del %%x\*.so
   if exist %%x\*.tds     del %%x\*.tds
   if exist %%x\Makefile  del %%x\Makefile
   if exist %%x\*.Debug   del %%x\*.Debug
   if exist %%x\*.Release del %%x\*.Release
 )
 cd ..\psi-qt4
 
 :tls
 if not exist ..\qca2-openssl goto src
 cd ..\qca2-openssl
 if exist debug         rmdir /s /q debug
 if exist release       rmdir /s /q release
 if exist *.dll         del *.dll
 if exist *.exp         del *.exp
 if exist *.idb         del *.idb
 if exist *.lib         del *.lib
 if exist *.moc         del *.moc
 if exist *.o           del *.o
 if exist *.obj         del *.obj
 if exist *.pdb         del *.pdb
 if exist *.so          del *.so
 if exist *.tds         del *.tds
 if exist Makefile      del Makefile
 if exist *.Debug       del *.Debug
 if exist *.Release     del *.Release
 cd ..\psi-qt4
 
 :src
 if not exist src goto win32
 cd src
 for /r %%x in (.) do (
   if exist %%x\.moc      rmdir /s /q %%x\.moc
   if exist %%x\.obj      rmdir /s /q %%x\.obj
   if exist %%x\.rcc      rmdir /s /q %%x\.rcc
   if exist %%x\.ui       rmdir /s /q %%x\.ui
   if exist %%x\moc       rmdir /s /q %%x\moc
   if exist %%x\obj       rmdir /s /q %%x\obj
   if exist %%x\rcc       rmdir /s /q %%x\rcc
   if exist %%x\ui        rmdir /s /q %%x\ui
   if exist %%x\debug     rmdir /s /q %%x\debug
   if exist %%x\release   rmdir /s /q %%x\release
   if exist %%x\bin       rmdir /s /q %%x\bin
   if exist %%x\lib       rmdir /s /q %%x\lib
   if exist %%x\*.dll     del %%x\*.dll
   if exist %%x\*.exe     del %%x\*.exe
   if exist %%x\*.exp     del %%x\*.exp
   if exist %%x\*.idb     del %%x\*.idb
   if exist %%x\*.lib     del %%x\*.lib
   if exist %%x\*.moc     del %%x\*.moc
   if exist %%x\*.o       del %%x\*.o
   if exist %%x\*.obj     del %%x\*.obj
   if exist %%x\*.pdb     del %%x\*.pdb
   if exist %%x\*.so      del %%x\*.so
   if exist %%x\*.tds     del %%x\*.tds
   if exist %%x\Makefile  del %%x\Makefile
   if exist %%x\*.Debug   del %%x\*.Debug
   if exist %%x\*.Release del %%x\*.Release
 )
 cd ..
 
 :win32
 if not exist win32 goto root
 cd win32
 if exist *.res         del *.res
 cd ..
 
 :root
 if exist psiwin        rmdir /s /q psiwin
 if exist *.log         del *.log
 if exist Makefile      del Makefile
 if exist *.Debug       del *.Debug
 if exist *.Release     del *.Release

Links