-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-native-test.bat
70 lines (57 loc) · 1.61 KB
/
build-native-test.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
@echo off
REM **********************************************************************
REM * Builds native executables for testing purposes.
REM **********************************************************************
set DIR=%~dp0.
set CURR_DIR=%CD%
set BIN_DIR=%DIR%\src\test\resources\native\win32
set SRC_DIR=%DIR%\src\test\c
set OBJ_DIR=%DIR%\target\objs
cd /d "%DIR%"
goto setup
:setup
mkdir %BIN_DIR% 2>NUL
mkdir %OBJ_DIR% 2>NUL
goto build_all
:build_all
call :build stdin-1
call :build stderr-1
call :build stdout-1
echo Build complete.
goto done
:done
cd /d "%CURR_DIR%"
goto :EOF
:build %name%
setlocal ENABLEEXTENSIONS
set name=%~1
if not "x%OSSBUILD_DIR%" == "x" (
if exist "%OSSBUILD_DIR%\sys\opt\mingw-w64\x86\bin" (
call :build_full "%OSSBUILD_DIR%\sys\opt\mingw-w64\x86\bin\gcc.exe" "x86\bin\%name%.exe" %name%.o %name%.c
)
if exist "%OSSBUILD_DIR%\sys\opt\mingw-w64\x86_64\bin" (
call :build_full "%OSSBUILD_DIR%\sys\opt\mingw-w64\x86_64\bin\gcc.exe" "x86_64\bin\%name%.exe" %name%.o %name%.c
)
) else (
if not "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
call :build_full "gcc" "x86\bin\%name%.exe" %name%.o %name%.c
) else (
call :build_full "gcc" "x86_64\bin\%name%.exe" %name%.o %name%.c
)
)
endlocal
goto :EOF
:build_full %gcc% %exe% %obj% %src%
setlocal ENABLEEXTENSIONS
set gcc=%~1
set exe=%~2
set obj=%~3
set src=%~4
REM get executable directory and ensure it exists
for %%i in ("%BIN_DIR%\%exe%") do set exedir=%%~dpi
mkdir "%exedir%" 2>NUL
echo Building %exe%...
"%gcc%" "-I%SRC_DIR%" -o "%OBJ_DIR%\%obj%" -c "%SRC_DIR%\%src%"
"%gcc%" -o "%BIN_DIR%\%exe%" "%OBJ_DIR%\%obj%"
endlocal
goto :EOF