1@echo off
2
3REM If using the x86, x64 or ia64 suffixes, make sure you have Visual Studio 2008 installed, including the
4REM x64 and ia64 cross compilers.
5
6setlocal
7
8set BUILD_DIR=%~dp0build.~
9set SOURCE_DIR=%~dp0src\win32\launcher
10set TARGET_EXE_PREFIX=%~dp0dist\bin
11set RES_TARGET=%BUILD_DIR%\launcher.res
12set OBJ_TARGET=%BUILD_DIR%\launcher.obj
13
14if "%1"=="console" goto console
15if "%1"=="windows" goto windows
16
17:printusage
18echo usage: %0 [console^|windows] ^<x86^|x64^|ia64^>
19goto end
20
21:console
22set SUBSYSTEM=CONSOLE
23goto arch
24
25:windows
26set SUBSYSTEM=WINDOWS
27goto arch
28
29:arch
30if "%2"=="" set TARGET_EXE=%TARGET_EXE_PREFIX%.exe & goto build
31if "%2"=="x86" set TARGET_EXE=%TARGET_EXE_PREFIX%_x86.exe & goto setvars_x86
32if "%2"=="x64" set TARGET_EXE=%TARGET_EXE_PREFIX%_x64.exe & goto setvars_x64
33if "%2"=="ia64" set TARGET_EXE=%TARGET_EXE_PREFIX%_ia64.exe & goto setvars_ia64
34
35echo Unknown architecture "%2"!
36goto printusage
37
38:setvars_x86
39if "%VS90COMNTOOLS%"=="" echo Can not find Visual Studio 9 (environment variable VS90COMNTOOLS)! & goto error
40pushd "%VS90COMNTOOLS%\..\..\VC"
41call vcvarsall.bat x86
42popd
43goto build
44
45:setvars_x64
46if "%VS90COMNTOOLS%"=="" echo Can not find Visual Studio 9 (environment variable VS90COMNTOOLS)! & goto error
47pushd "%VS90COMNTOOLS%\..\..\VC"
48call vcvarsall.bat x86_amd64
49popd
50goto build
51
52:setvars_ia64
53if "%VS90COMNTOOLS%"=="" echo Can not find Visual Studio 9 (environment variable VS90COMNTOOLS)! & goto error
54pushd "%VS90COMNTOOLS%\..\..\VC"
55call vcvarsall.bat x86_ia64
56popd
57goto build
58
59:build
60echo Cleaning build dir...
61if exist "%BUILD_DIR%" rmdir /s /q "%BUILD_DIR%"
62if exist "%BUILD_DIR%" echo Could not clean build dir! & goto error
63mkdir "%BUILD_DIR%"
64
65echo Compiling resources...
66rc /fo "%RES_TARGET%" "%SOURCE_DIR%\launcher.rc"
67if not "%ERRORLEVEL%"=="0" goto error
68
69echo Compiling source code...
70REM "/Fe%TARGET_EXE%"
71cl /c "/Fo%OBJ_TARGET%" "/IC:\Program Files\Java\jdk\include" "/IC:\Program Files\Java\jdk\include\win32" "%SOURCE_DIR%\launcher.cpp"
72if not "%ERRORLEVEL%"=="0" goto error
73
74echo Linking...
75link /defaultlib:user32 /defaultlib:shell32 /defaultlib:advapi32 /defaultlib:ole32 /subsystem:%SUBSYSTEM% /entry:mainCRTStartup "/out:%TARGET_EXE%" "%OBJ_TARGET%" "%RES_TARGET%"
76if not "%ERRORLEVEL%"=="0" goto error
77goto completed
78
79:completed
80echo Target generated at %TARGET_EXE%
81echo Done!
82goto end
83
84:error
85echo There were errors...
86goto end
87
88:end
89endlocal