-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.bat
executable file
·184 lines (148 loc) · 6.85 KB
/
build.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
@echo off
set GHOST_TRAP_VERSION=1.5
set INNO_COMPILER=%programfiles(x86)%\Inno Setup 6\ISCC.exe
SETLOCAL ENABLEDELAYEDEXPANSION
set starttime=%time%
set startdir=%cd%
set gsversion=10.03.1
echo .-. ___ _ _ _____
echo (o o) / _ \ ^|__ ___ ___^| ^|/__ \_ __ __ _ _ __
echo ^| O \ / /_\/ '_ \ / _ \/ __^| __^|/ /\/ '__/ _` ^| '_ \
echo \ \ / /_\\^| ^| ^| ^| (_) \__ \ ^|_/ / ^| ^| ^| (_^| ^| ^|_) ^|
echo `~~~'\____/^|_^| ^|_^|\___/^|___/\__\/ ^|_^| \__,_^| .__/
echo ^|_^|
echo.
rem Make the current dir the script dir
cd %~dp0
if %errorlevel% NEQ 0 goto builderror
REM #
REM # Verify that our required dependencies exists
REM #
if exist "%~dp0third-party\ghostpdl\bin\gsdll64.dll" goto gsinsok
echo Error: Unable to locate the GhostPDL files
echo Please ensure its at:
echo %~dp0third-party\ghostpdl\bin\gsdll64.dll
goto builderror
:gsinsok
if exist %~dp0third-party\chromium\src\sandbox goto chromesrcok
echo Error: Unable to locate the chromium source.
echo Please ensure the chromium source is located at:
echo %~dp0third-party\chromium\src
goto builderror
:chromesrcok
if exist %~dp0src goto ghosttrapsrcok
echo Error: Unable to locate the Ghost Trap project source.
echo Please ensure the Ghost Trap source is located at:
echo %~dp0src
goto builderror
:ghosttrapsrcok
if exist %~dp0third-party\ghostpdl\psi\ goto ghostscriptsrcok
echo Error: Unable to locate the GhostPDL project source.
echo Please ensure the GhostPDL source is located at:
echo %~dp0third-party\ghostpdl
goto builderror
:ghostscriptsrcok
REM #
REM # Get Ghostscript version info
REM #
for /f "usebackq delims=" %%x in (`findstr /B /C:GS_VERSION_M %~dp0third-party\ghostpdl\base\version.mak`) do (set "%%x")
echo Ghostscript version is %GS_VERSION_MAJOR%.%GS_VERSION_MINOR%
echo.
REM #
REM # Build Ghost Trap
REM #
echo ==== Compiling 64-bit ====
REM Append extra build info to the BUILD.gn
>nul find "gsc-trapped" %~dp0third-party\chromium\src\sandbox\win\BUILD.gn && (
goto buildinfoexists
) || (
goto buildinfomissing
)
:buildinfomissing
echo.>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
echo executable("gsc-trapped") {>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
echo sources = [>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
echo "ghosttrap/gstrapped.cpp",>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
echo "ghosttrap/sandbox_procmgmt.cpp",>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
echo "ghosttrap/sandbox_procmgmt.h",>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
echo ]>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
echo.>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
echo include_dirs = [>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
echo "ghosttrap/ghostscript/psi",>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
echo "ghosttrap/ghostscript/base",>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
echo ]>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
echo.>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
echo deps = [>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
echo ":sandbox",>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
echo ]>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
echo }>>%~dp0third-party\chromium\src\sandbox\win\BUILD.gn
:buildinfoexists
REM Copy the Ghost Trap source code to the Chromium project
call mkdir %~dp0third-party\chromium\src\sandbox\win\ghosttrap > NUL
call xcopy %~dp0src %~dp0third-party\chromium\src\sandbox\win\ghosttrap\ /Y /E /S > NUL
REM Copy the Ghostscript source code to the Chromium project
call mkdir %~dp0third-party\chromium\src\sandbox\win\ghosttrap\ghostscript > NUL
call xcopy %~dp0third-party\ghostpdl %~dp0third-party\chromium\src\sandbox\win\ghosttrap\ghostscript\ /Y /E /S > NUL
REM #
REM # REM Start the build
REM #
call cd "%~dp0third-party\chromium\src\" > NUL
if %errorlevel% NEQ 0 goto builderror
call gn gen out\Default --args="is_debug=false" > NUL
if %errorlevel% NEQ 0 goto builderror
call autoninja -C out\Default sandbox/win:gsc-trapped > NUL
if %errorlevel% NEQ 0 goto builderror
REM #
REM # Test Ghost Trap
REM #
echo Testing Ghost Trap...
copy "%~dp0third-party\ghostpdl\bin\gsdll64.dll" "%~dp0third-party\chromium\src\out\Default\" /Y > NUL
call "%~dp0third-party\chromium\src\out\Default\gsc-trapped.exe" --test-sandbox -sOutputFile="C:\output\outputtest.txt" "C:\input\inputtest.txt"
if %errorlevel% NEQ 0 goto builderror
REM #
REM # Create target dir mirroring Ghostscript standard install.
REM #
rmdir /s /q "%~dp0target" > NUL
REM # Small sleep so we don't hit locked files.
ping -n 3 127.0.0.1 > NUL
echo Copying files...
mkdir "%~dp0target" > NUL
mkdir "%~dp0target\installfiles" > NUL
mkdir "%~dp0target\installfiles\bin" > NUL
REM # Ghost Trap exe, README and LICENSE files
copy "%~dp0third-party\chromium\src\out\Default\gsc-trapped.exe" "%~dp0target\installfiles\bin\gsc-trapped.exe" /Y > NUL
copy "%~dp0LICENSE*" "%~dp0target\installfiles" /Y > NUL
copy "%~dp0README*" "%~dp0target\installfiles" /Y > NUL
REM # Ghostscript files (mirroring standard install structure)
copy "%~dp0third-party\ghostpdl\bin\gswin64.exe" "%~dp0target\installfiles\bin\gs.exe" /Y > NUL
copy "%~dp0third-party\ghostpdl\bin\gswin64c.exe" "%~dp0target\installfiles\bin\gsc.exe" /Y > NUL
copy "%~dp0third-party\ghostpdl\bin\gsdll64.dll" "%~dp0target\installfiles\bin\" /Y > NUL
copy "%~dp0third-party\ghostpdl\bin\gpcl6win64.exe" "%~dp0target\installfiles\bin\pcl6.exe" /Y > NUL
copy "%~dp0third-party\ghostpdl\bin\gpcl6dll64.dll" "%~dp0target\installfiles\bin\" /Y > NUL
copy "%~dp0third-party\ghostpdl\bin\gxpswin64.exe" "%~dp0target\installfiles\bin\gxps.exe" /Y > NUL
copy "%~dp0third-party\ghostpdl\bin\gxpsdll64.dll" "%~dp0target\installfiles\bin\" /Y > NUL
xcopy "%~dp0third-party\ghostpdl\doc" "%~dp0target\installfiles\doc\" /Y /S > NUL
xcopy "%~dp0third-party\ghostpdl\examples" "%~dp0target\installfiles\examples\" /Y /S > NUL
xcopy "%~dp0third-party\ghostpdl\iccprofiles" "%~dp0target\installfiles\iccprofiles\" /Y /S > NUL
xcopy "%~dp0third-party\ghostpdl\lib" "%~dp0target\installfiles\lib\" /Y /S > NUL
xcopy "%~dp0third-party\ghostpdl\Resource" "%~dp0target\installfiles\Resource\" /Y /S > NUL
REM #
REM # Run Inno install script to build the installer
REM #
echo Building installer...
"%INNO_COMPILER%" "/dapp_version=%GHOST_TRAP_VERSION%" "/dgs_version=%GS_VERSION_MAJOR%.%GS_VERSION_MINOR%" "%~dp0installer\win\ghost-trap.iss" /q
if %errorlevel% NEQ 0 goto builderror
REM We've finished successfully
goto end
:builderror
echo ****************************************************
echo ************* Error running build ******************
echo ****************************************************
cd %startdir%
exit /B 1
:end
rem Change back to the original dir
cd %startdir%
echo Build complete.
echo started at: %starttime%
echo now it is : %time%