Merge pull request #27 from Fneufneu/master
[deb_libcec.git] / support / create-installer.cmd
1 @echo off
2
3 rem Check for NSIS
4 IF EXIST "%ProgramFiles%\NSIS\makensis.exe" (
5 set NSIS="%ProgramFiles%\NSIS\makensis.exe"
6 ) ELSE IF EXIST "%ProgramFiles(x86)%\NSIS\makensis.exe" (
7 set NSIS="%ProgramFiles(x86)%\NSIS\makensis.exe"
8 ) ELSE GOTO NONSIS
9
10 rem Check for the Windows DDK
11 IF NOT EXIST "C:\WinDDK\7600.16385.1" GOTO NODDK
12 set DDK="C:\WinDDK\7600.16385.1"
13
14 rem Check for VC10
15 IF "%VS100COMNTOOLS%"=="" (
16 set COMPILER10="%ProgramFiles%\Microsoft Visual Studio 10.0\Common7\IDE\VCExpress.exe"
17 ) ELSE IF EXIST "%VS100COMNTOOLS%\..\IDE\VCExpress.exe" (
18 set COMPILER10="%VS100COMNTOOLS%\..\IDE\VCExpress.exe"
19 ) ELSE IF EXIST "%VS100COMNTOOLS%\..\IDE\devenv.exe" (
20 set COMPILER10="%VS100COMNTOOLS%\..\IDE\devenv.exe"
21 ) ELSE GOTO NOSDK10
22
23 del /s /f /q ..\build
24 mkdir ..\build
25
26 IF EXIST "..\support\p8-usbcec-driver-installer.exe" (
27 copy "..\support\p8-usbcec-driver-installer.exe" "..\build\."
28 ) ELSE (
29 call create-driver-installer.cmd
30 )
31
32 mkdir ..\build\x64
33
34 cd ..\project
35
36 rem Skip to libCEC/x86 when we're running on win32
37 if "%PROCESSOR_ARCHITECTURE%"=="x86" if "%PROCESSOR_ARCHITEW6432%"=="" goto libcecx86
38
39 rem Compile libCEC and cec-client x64
40 echo. Cleaning libCEC (x64)
41 %COMPILER10% libcec.sln /clean "Release|x64"
42 echo. Compiling libCEC (x64)
43 %COMPILER10% libcec.sln /build "Release|x64" /project libcec
44 echo. Compiling cec-client (x64)
45 %COMPILER10% libcec.sln /build "Release|x64" /project testclient
46
47 :libcecx86
48 rem Compile libCEC and cec-client Win32
49 echo. Cleaning libCEC (x86)
50 %COMPILER10% libcec.sln /clean "Release|Win32"
51 echo. Compiling libCEC (x86)
52 %COMPILER10% libcec.sln /build "Release|Win32" /project libcec
53 echo. Compiling cec-client (x86)
54 %COMPILER10% libcec.sln /build "Release|Win32" /project testclient
55
56 rem Check for VC9
57 IF "%VS90COMNTOOLS%"=="" (
58 set COMPILER9="%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\VCExpress.exe"
59 ) ELSE IF EXIST "%VS90COMNTOOLS%\..\IDE\VCExpress.exe" (
60 set COMPILER9="%VS90COMNTOOLS%\..\IDE\VCExpress.exe"
61 ) ELSE IF EXIST "%VS90COMNTOOLS%\..\IDE\devenv.exe" (
62 set COMPILER9="%VS90COMNTOOLS%\..\IDE\devenv.exe"
63 ) ELSE GOTO NOSDK9
64
65 rem Skip to libCEC/x86 when we're running on win32
66 if "%PROCESSOR_ARCHITECTURE%"=="x86" if "%PROCESSOR_ARCHITEW6432%"=="" goto libcecsharpx86
67
68 rem Compile LibCecSharp (x64)
69 echo. Cleaning LibCecSharp (x64)
70 %COMPILER9% LibCecSharp.Net2.sln /clean "Release|x64"
71 echo. Compiling LibCecSharp (x64)
72 %COMPILER9% LibCecSharp.sln /build "Release|x64" /project LibCecSharp
73 %COMPILER9% LibCecSharp.sln /build "Release|x64" /project CecSharpTester
74 %COMPILER9% LibCecSharp.sln /build "Release|x64" /project cec-config-gui
75
76 copy ..\build\LibCecSharp.dll ..\build\x64\LibCecSharp.dll
77 copy ..\build\CecSharpTester.exe ..\build\x64\CecSharpTester.exe
78 copy ..\build\cec-config-gui.exe ..\build\x64\cec-config-gui.exe
79
80 :libcecsharpx86
81 rem Compile LibCecSharp (x86)
82 echo. Cleaning LibCecSharp (x86)
83 %COMPILER9% LibCecSharp.sln /clean "Release|x86"
84 echo. Compiling LibCecSharp (x86)
85 %COMPILER9% LibCecSharp.sln /build "Release|x86" /project LibCecSharp
86 %COMPILER9% LibCecSharp.sln /build "Release|x86" /project CecSharpTester
87 %COMPILER9% LibCecSharp.sln /build "Release|x86" /project cec-config-gui
88
89 :NOSDK9
90 rem Clean things up before creating the installer
91 del /q /f ..\build\LibCecSharp.pdb
92 del /q /f ..\build\CecSharpTester.pdb
93 del /q /f ..\build\cec-config-gui.pdb
94 del /q /f ..\build\cec-config-gui.vshost.exe.manifest
95 del /q /f ..\build\cec-config-gui.vshost.exe
96 copy ..\build\cec-client.x64.exe ..\build\x64\cec-client.x64.exe
97 del /q /f ..\build\cec-client.x64.exe
98 copy ..\build\libcec.x64.dll ..\build\x64\libcec.x64.dll
99 del /q /f ..\build\libcec.x64.dll
100 copy ..\build\libcec.x64.lib ..\build\x64\libcec.x64.lib
101 del /q /f ..\build\libcec.x64.lib
102
103 rem Check for sign-binary.cmd, only present on the Pulse-Eight production build system
104 rem Calls signtool.exe and signs the DLLs with Pulse-Eight's code signing key
105 IF NOT EXIST "..\support\private\sign-binary.cmd" GOTO CREATEINSTALLER
106 echo. Signing all binaries
107 CALL ..\support\private\sign-binary.cmd ..\build\cec-client.exe
108 CALL ..\support\private\sign-binary.cmd ..\build\CecSharpTester.exe
109 CALL ..\support\private\sign-binary.cmd ..\build\libcec.dll
110 CALL ..\support\private\sign-binary.cmd ..\build\LibCecSharp.dll
111 CALL ..\support\private\sign-binary.cmd ..\build\cec-config-gui.exe
112 CALL ..\support\private\sign-binary.cmd ..\build\x64\cec-client.x64.exe
113 CALL ..\support\private\sign-binary.cmd ..\build\x64\CecSharpTester.exe
114 CALL ..\support\private\sign-binary.cmd ..\build\x64\libcec.x64.dll
115 CALL ..\support\private\sign-binary.cmd ..\build\x64\LibCecSharp.dll
116 CALL ..\support\private\sign-binary.cmd ..\build\x64\cec-config-gui.exe
117
118 :CREATEINSTALLER
119 echo. Creating the installer
120 %NSIS% /V1 /X"SetCompressor /FINAL lzma" "libCEC.nsi"
121
122 IF NOT EXIST "..\build\libCEC-installer.exe" GOTO :ERRORCREATINGINSTALLER
123
124 rem Sign the installer if sign-binary.cmd exists
125 IF EXIST "..\support\private\sign-binary.cmd" (
126 echo. Signing the installer binaries
127 CALL ..\support\private\sign-binary.cmd ..\build\libCEC-installer.exe
128 )
129
130 echo. The installer can be found here: ..\build\libCEC-installer.exe
131
132 GOTO EXIT
133
134 :NOSDK10
135 echo. Both Visual Studio 2010 and Visual C++ Express 2010 were not found on your system.
136 GOTO EXIT
137
138 :NOSIS
139 echo. NSIS could not be found on your system.
140 GOTO EXIT
141
142 :NODDK
143 echo. Windows DDK could not be found on your system
144 GOTO EXIT
145
146 :ERRORCREATINGINSTALLER
147 echo. The installer could not be created. The most likely cause is that something went wrong while compiling.
148
149 :EXIT
150 del /q /f ..\build\cec-client.exe
151 del /q /f ..\build\CecSharpTester.exe
152 del /q /f ..\build\cec-config-gui.exe
153 del /q /f ..\build\*.dll
154 del /q /f ..\build\*.lib
155 del /q /f ..\build\*.exp
156 del /s /f /q ..\build\x64
157 rmdir ..\build\x64
158 cd ..\support