-
Notifications
You must be signed in to change notification settings - Fork 37
/
buildllio_compile.bat
157 lines (128 loc) · 4.4 KB
/
buildllio_compile.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
@echo off
setlocal
set TARGET_PREFIX=%~dp0dist\lib\llio
set I386_ARCHID=i386
set AMD64_ARCHID=amd64
set IA64_ARCHID=ia64
set ARM_ARCHID=arm
set ARM64_ARCHID=arm64
set SOURCE_DIR=%~dp0src\win32\llio
set SOURCE_FILES="%SOURCE_DIR%\llio_common.c" "%SOURCE_DIR%\org_catacombae_storage_io_win32_ReadableWin32FileStream.c" "%SOURCE_DIR%\org_catacombae_storage_io_win32_Win32FileStream.c"
set "VS2019_BUILD_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build"
:start
if "%1"=="gcc" goto build_gcc
if "%1"=="vc" goto build_vc
if "%1"=="wdk" goto build_wdk
goto printusage
:printusage
echo usage: %0 gcc
echo OR
echo usage: %0 vc [x86^|x64^|ia64^|arm^|arm64]
echo OR
echo usage: %0 wdk [x86^|x64^|ia64]
goto end
:build_gcc
echo Compiling with gcc...
set TARGET_DLL=%TARGET_PREFIX%_%I386_ARCHID%.dll
gcc -Wall -D_JNI_IMPLEMENTATION_ -Wl,--kill-at -shared %SOURCE_FILES% -o "%TARGET_DLL%"
if not "%ERRORLEVEL%"=="0" goto error
goto completed
:build_vc
if "%2"=="x86" goto setvars_x86
if "%2"=="x64" goto setvars_x64
if "%2"=="ia64" goto setvars_ia64
if "%2"=="arm" goto setvars_arm
if "%2"=="arm64" goto setvars_arm64
goto printusage
:setvars_x86
if "%VS90COMNTOOLS%"=="" echo Can not find Visual Studio 9 (environment variable VS90COMNTOOLS)! & goto error
pushd "%VS90COMNTOOLS%\..\..\VC"
call vcvarsall.bat x86
popd
set TARGET_DLL=%TARGET_PREFIX%_%I386_ARCHID%.dll
goto compile_vc
:setvars_x64
if "%VS90COMNTOOLS%"=="" echo Can not find Visual Studio 9 (environment variable VS90COMNTOOLS)! & goto error
pushd "%VS90COMNTOOLS%\..\..\VC"
call vcvarsall.bat x86_amd64
popd
set TARGET_DLL=%TARGET_PREFIX%_%AMD64_ARCHID%.dll
goto compile_vc
:setvars_ia64
if "%VS90COMNTOOLS%"=="" echo Can not find Visual Studio 9 (environment variable VS90COMNTOOLS)! & goto error
pushd "%VS90COMNTOOLS%\..\..\VC"
call vcvarsall.bat x86_ia64
popd
set TARGET_DLL=%TARGET_PREFIX%_%IA64_ARCHID%.dll
goto compile_vc
:setvars_arm
if not exist "%VS2019_BUILD_PATH%" echo Can not find Visual Studio 2019! & goto error
pushd "%VS2019_BUILD_PATH%"
call vcvarsall.bat x86_arm
popd
set TARGET_DLL=%TARGET_PREFIX%_%ARM_ARCHID%.dll
goto compile_vc
:setvars_arm64
if not exist "%VS2019_BUILD_PATH%" echo Can not find Visual Studio 2019! & goto error
pushd "%VS2019_BUILD_PATH%"
call vcvarsall.bat x86_arm64
popd
set TARGET_DLL=%TARGET_PREFIX%_%ARM64_ARCHID%.dll
goto compile_vc
:build_wdk
set WDK_PATH=C:\WinDDK\7600.16385.1
if not exist "%WDK_PATH%\" echo Can not find WDK 7.1.0 at %WDK_PATH%! & goto error
set COMPILE_FLAGS="/I%WDK_PATH%\inc\crt"
if "%2"=="x86" goto setvars_wdk_x86
if "%2"=="x64" goto setvars_wdk_x64
if "%2"=="ia64" goto setvars_wdk_ia64
goto printusage
:setvars_wdk_x86
pushd "%WDK_PATH%"
call bin\setenv.bat %WDK_PATH% fre x86 WXP no_oacr
popd
set TARGET_DLL=%TARGET_PREFIX%_%I386_ARCHID%.dll
set LINK_FLAGS=/libpath:%SDK_LIB_DEST%\i386\ /libpath:%WDK_PATH%\lib\crt\i386\
goto compile_vc
:setvars_wdk_x64
pushd "%WDK_PATH%"
call bin\setenv.bat %WDK_PATH% fre x64 WNET no_oacr
popd
set TARGET_DLL=%TARGET_PREFIX%_%AMD64_ARCHID%.dll
set LINK_FLAGS=/libpath:%SDK_LIB_DEST%\amd64\ /libpath:%WDK_PATH%\lib\crt\amd64\
goto compile_vc
:setvars_wdk_ia64
pushd "%WDK_PATH%"
call bin\setenv.bat %WDK_PATH% fre ia64 WNET no_oacr
popd
set TARGET_DLL=%TARGET_PREFIX%_%IA64_ARCHID%.dll
set LINK_FLAGS=/libpath:%SDK_LIB_DEST%\ia64\ /libpath:%WDK_PATH%\lib\crt\ia64\
goto compile_vc
:compile_vc
if "%JAVA_HOME%"=="" echo JAVA_HOME environment variable not defined! & goto error
set JDK_PATH=%JAVA_HOME%
set BUILD_DIR=%~dp0build.~
echo Cleaning build dir...
if exist "%BUILD_DIR%" rmdir /s /q "%BUILD_DIR%"
if exist "%BUILD_DIR%" echo Could not clean build dir! & goto error
mkdir "%BUILD_DIR%"
if not "%ERRORLEVEL%"=="0" goto error
echo Compiling with Visual C++...
cl -c "/Fo%BUILD_DIR%\\" /W3 "/I%JDK_PATH%\include" "/I%JDK_PATH%\include\win32" %COMPILE_FLAGS% "%SOURCE_DIR%\*.c"
set EXIT_CODE=%ERRORLEVEL%
if not "%EXIT_CODE%"=="0" goto error
echo Linking...
REM "/libpath:%JDK_PATH%\lib"
link /dll "/out:%TARGET_DLL%" "/implib:%BUILD_DIR%\llio.lib" "/pdb:%BUILD_DIR%\llio.pdb" %LINK_FLAGS% "%BUILD_DIR%\*.obj"
set EXIT_CODE=%ERRORLEVEL%
if not "%EXIT_CODE%"=="0" goto error
goto completed
:completed
echo Target .dll generated at %TARGET_DLL%
echo Done!
goto end
:error
echo There were errors...
goto end
:end
endlocal