|
| 1 | +@rem ########################################################################## |
| 2 | +@rem |
| 3 | +@rem Runs tests and then builds artifacts to %WORKSPACE%\artifacts\ |
| 4 | +@rem |
| 5 | +@rem ########################################################################## |
| 6 | + |
| 7 | +type c:\VERSION |
| 8 | + |
| 9 | +@rem Enter repo root |
| 10 | +cd /d %~dp0\..\.. |
| 11 | + |
| 12 | +set WORKSPACE=T:\src\github\grpc-java |
| 13 | +set ESCWORKSPACE=%WORKSPACE:\=\\% |
| 14 | + |
| 15 | + |
| 16 | +@rem Clear JAVA_HOME to prevent a different Java version from being used |
| 17 | +set JAVA_HOME= |
| 18 | + |
| 19 | +mkdir grpc-java-helper32 |
| 20 | +cd grpc-java-helper32 |
| 21 | +call "%VS170COMNTOOLS%\..\..\VC\Auxiliary\Build\vcvars32.bat" || exit /b 1 |
| 22 | +call "%WORKSPACE%\buildscripts\make_dependencies.bat" || exit /b 1 |
| 23 | + |
| 24 | +cd "%WORKSPACE%" |
| 25 | + |
| 26 | +SET TARGET_ARCH=x86_32 |
| 27 | +SET FAIL_ON_WARNINGS=true |
| 28 | +SET PROTOBUF_VER=22.5 |
| 29 | +SET PKG_CONFIG_PATH=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\lib\\pkgconfig |
| 30 | +SET VC_PROTOBUF_LIBS=/LIBPATH:%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\lib |
| 31 | +SET VC_PROTOBUF_INCLUDE=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\include |
| 32 | +call :Get_Libs |
| 33 | +SET GRADLE_FLAGS=-PtargetArch=%TARGET_ARCH% -PfailOnWarnings=%FAIL_ON_WARNINGS% -PvcProtobufLibs=%VC_PROTOBUF_LIBS% -PvcProtobufInclude=%VC_PROTOBUF_INCLUDE% -PskipAndroid=true |
| 34 | +SET GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx1g'" |
| 35 | + |
| 36 | +cmd.exe /C "%WORKSPACE%\gradlew.bat %GRADLE_FLAGS% build" |
| 37 | +set GRADLEEXIT=%ERRORLEVEL% |
| 38 | + |
| 39 | +@rem Rename test results .xml files to format parsable by Kokoro |
| 40 | +@echo off |
| 41 | +for /r %%F in (TEST-*.xml) do ( |
| 42 | + mkdir "%%~dpnF" |
| 43 | + move "%%F" "%%~dpnF\sponge_log.xml" >NUL |
| 44 | +) |
| 45 | +@echo on |
| 46 | + |
| 47 | +IF NOT %GRADLEEXIT% == 0 ( |
| 48 | + exit /b %GRADLEEXIT% |
| 49 | +) |
| 50 | + |
| 51 | +@rem make sure no daemons have any files open |
| 52 | +cmd.exe /C "%WORKSPACE%\gradlew.bat --stop" |
| 53 | + |
| 54 | +cmd.exe /C "%WORKSPACE%\gradlew.bat %GRADLE_FLAGS% -Dorg.gradle.parallel=false -PrepositoryDir=%WORKSPACE%\artifacts clean grpc-compiler:build grpc-compiler:publish" || exit /b 1 |
| 55 | + |
| 56 | +goto :eof |
| 57 | +:Get_Libs |
| 58 | +SetLocal EnableDelayedExpansion |
| 59 | +set "libs_list=" |
| 60 | +for /f "tokens=*" %%a in ('pkg-config --libs protobuf') do ( |
| 61 | + for %%b in (%%a) do ( |
| 62 | + set lib=%%b |
| 63 | + set libfirst2char=!lib:~0,2! |
| 64 | + if !libfirst2char!==-l ( |
| 65 | + @rem remove the leading -l |
| 66 | + set lib=!lib:~2! |
| 67 | + @rem remove spaces |
| 68 | + set lib=!lib: =! |
| 69 | + @rem Because protobuf is specified as libprotobuf and elsewhere |
| 70 | + if !lib! NEQ protobuf ( |
| 71 | + set lib=!lib!.lib |
| 72 | + if "!libs_list!"=="" ( |
| 73 | + set libs_list=!lib! |
| 74 | + ) else ( |
| 75 | + set libs_list=!libs_list!,!lib! |
| 76 | + ) |
| 77 | + ) |
| 78 | + ) |
| 79 | + ) |
| 80 | +) |
| 81 | +EndLocal & set "VC_PROTOBUF_LIBS=%VC_PROTOBUF_LIBS%,%libs_list%" |
| 82 | +exit /b 0 |
| 83 | + |
0 commit comments