diff --git a/buildscripts/kokoro/windows.bat b/buildscripts/kokoro/windows.bat index 842dfa79d9..d2b5bb22ce 100644 --- a/buildscripts/kokoro/windows.bat +++ b/buildscripts/kokoro/windows.bat @@ -12,32 +12,16 @@ cd /d %~dp0\..\.. set WORKSPACE=T:\src\github\grpc-java set ESCWORKSPACE=%WORKSPACE:\=\\% -mkdir grpc-java-helper - -cd grpc-java-helper @rem Clear JAVA_HOME to prevent a different Java version from being used set JAVA_HOME= set PATH=C:\Program Files\java\jdk1.8.0_152\bin;%PATH% -call "%VS120COMNTOOLS%\vsvars32.bat" || exit /b 1 -call "%WORKSPACE%\buildscripts\make_dependencies.bat" || exit /b 1 -cd "%WORKSPACE%" +cmd.exe /C "%WORKSPACE%\buildscripts\kokoro\windows32.bat" || exit /b 1 +cmd.exe /C "%WORKSPACE%\buildscripts\kokoro\windows64.bat" || exit /b 1 -echo targetArch=x86_32> gradle.properties -echo failOnWarnings=true>> gradle.properties -echo vcProtobufLibs=%ESCWORKSPACE%\\grpc-java-helper\\protobuf-%PROTOBUF_VER%\\cmake\\build\\Release>> gradle.properties -echo vcProtobufInclude=%ESCWORKSPACE%\\grpc-java-helper\\protobuf-%PROTOBUF_VER%\\cmake\\build\\include>> gradle.properties - -cmd.exe /C "%WORKSPACE%\gradlew.bat build" -set GRADLEEXIT=%ERRORLEVEL% - -@rem Rename test results .xml files to format parsable by Kokoro -@echo off -for /r %%F in (TEST-*.xml) do ( - mkdir "%%~dpnF" - move "%%F" "%%~dpnF\sponge_log.xml" >NUL +IF DEFINED MVN_ARTIFACTS ( + mkdir mvn-artifacts + move artifacts\x86_64 mvn-artifacts\x86_64 + move artifacts\x86_32 mvn-artifacts\x86_32 ) -@echo on - -exit /b %GRADLEEXIT% diff --git a/buildscripts/kokoro/windows.cfg b/buildscripts/kokoro/windows.cfg index 76a78e78de..98638606ef 100644 --- a/buildscripts/kokoro/windows.cfg +++ b/buildscripts/kokoro/windows.cfg @@ -5,6 +5,6 @@ build_file: "grpc-java/buildscripts/kokoro/windows.bat" timeout_mins: 45 action { define_artifacts { - regex: "**/build/test-results/**/*.xml" + regex: ["**/build/test-results/**/*.xml", "**/mvn-artifacts/**"] } } diff --git a/buildscripts/kokoro/windows32.bat b/buildscripts/kokoro/windows32.bat new file mode 100644 index 0000000000..a03a220a2a --- /dev/null +++ b/buildscripts/kokoro/windows32.bat @@ -0,0 +1,51 @@ +@rem ########################################################################## +@rem +@rem Runs tests and then builds artifacts to %WORKSPACE%\artifacts\ +@rem +@rem ########################################################################## + +type c:\VERSION + +@rem Enter repo root +cd /d %~dp0\..\.. + +set WORKSPACE=T:\src\github\grpc-java +set ESCWORKSPACE=%WORKSPACE:\=\\% + + +@rem Clear JAVA_HOME to prevent a different Java version from being used +set JAVA_HOME= +set PATH=C:\Program Files\java\jdk1.8.0_152\bin;%PATH% + +mkdir grpc-java-helper32 +cd grpc-java-helper32 +call "%VS120COMNTOOLS%\vsvars32.bat" || exit /b 1 +call "%WORKSPACE%\buildscripts\make_dependencies.bat" || exit /b 1 + +cd "%WORKSPACE%" + +SET TARGET_ARCH=x86_32 +SET FAIL_ON_WARNINGS=true +SET VC_PROTOBUF_LIBS=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\cmake\\build\\Release +SET VC_PROTOBUF_INCLUDE=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\cmake\\build\\include +SET GRADLE_FLAGS=-PtargetArch=%TARGET_ARCH% -PfailOnWarnings=%FAIL_ON_WARNINGS% -PvcProtobufLibs=%VC_PROTOBUF_LIBS% -PvcProtobufInclude=%VC_PROTOBUF_INCLUDE% + +cmd.exe /C "%WORKSPACE%\gradlew.bat %GRADLE_FLAGS% build" +set GRADLEEXIT=%ERRORLEVEL% + +@rem Rename test results .xml files to format parsable by Kokoro +@echo off +for /r %%F in (TEST-*.xml) do ( + mkdir "%%~dpnF" + move "%%F" "%%~dpnF\sponge_log.xml" >NUL +) +@echo on + +IF NOT %GRADLEEXIT% == 0 ( + exit /b %GRADLEEXIT% +) + +@rem make sure no daemons have any files open +cmd.exe /C "%WORKSPACE%\gradlew.bat --stop" + +cmd.exe /C "%WORKSPACE%\gradlew.bat %GRADLE_FLAGS% -Dorg.gradle.parallel=false -PrepositoryDir=%WORKSPACE%\artifacts\x86_32\ clean grpc-compiler:build grpc-compiler:uploadArchives" || exit /b 1 diff --git a/buildscripts/kokoro/windows64.bat b/buildscripts/kokoro/windows64.bat new file mode 100644 index 0000000000..43ee96c4b8 --- /dev/null +++ b/buildscripts/kokoro/windows64.bat @@ -0,0 +1,35 @@ +@rem ########################################################################## +@rem +@rem Builds artifacts for x86_64 into %WORKSPACE%\artifacts\ +@rem +@rem ########################################################################## + +type c:\VERSION + +@rem Enter repo root +cd /d %~dp0\..\.. + +set WORKSPACE=T:\src\github\grpc-java +set ESCWORKSPACE=%WORKSPACE:\=\\% + +@rem Clear JAVA_HOME to prevent a different Java version from being used +set JAVA_HOME= +set PATH=C:\Program Files\java\jdk1.8.0_152\bin;%PATH% + +mkdir grpc-java-helper64 +cd grpc-java-helper64 +call "%VS120COMNTOOLS%\..\..\VC\bin\amd64\vcvars64.bat" || exit /b 1 +call "%WORKSPACE%\buildscripts\make_dependencies.bat" || exit /b 1 + +cd "%WORKSPACE%" + +SET TARGET_ARCH=x86_64 +SET FAIL_ON_WARNINGS=true +SET VC_PROTOBUF_LIBS=%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\cmake\\build\\Release +SET VC_PROTOBUF_INCLUDE=%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\cmake\\build\\include +SET GRADLE_FLAGS=-PtargetArch=%TARGET_ARCH% -PfailOnWarnings=%FAIL_ON_WARNINGS% -PvcProtobufLibs=%VC_PROTOBUF_LIBS% -PvcProtobufInclude=%VC_PROTOBUF_INCLUDE% + +@rem make sure no daemons have any files open +cmd.exe /C "%WORKSPACE%\gradlew.bat --stop" + +cmd.exe /C "%WORKSPACE%\gradlew.bat %GRADLE_FLAGS% -Dorg.gradle.parallel=false -PrepositoryDir=%WORKSPACE%\artifacts\x86_64\ clean grpc-compiler:build grpc-compiler:uploadArchives" || exit /b 1 diff --git a/buildscripts/make_dependencies.bat b/buildscripts/make_dependencies.bat index 51557be60c..691520eaef 100644 --- a/buildscripts/make_dependencies.bat +++ b/buildscripts/make_dependencies.bat @@ -26,7 +26,16 @@ del protobuf.zip pushd protobuf-%PROTOBUF_VER%\cmake mkdir build cd build -cmake -Dprotobuf_BUILD_TESTS=OFF -G "Visual Studio %VisualStudioVersion:~0,2%" .. || exit /b 1 + +@rem cmake does not detect x86_64 from the vcvars64.bat variables. +@rem If vcvars64.bat has set PLATFORM to X64, then inform cmake to use the Win64 version of VS +if "%PLATFORM%" == "X64" ( + @rem Note the space + SET CMAKE_VSARCH= Win64 +) else ( + SET CMAKE_VSARCH= +) +cmake -Dprotobuf_BUILD_TESTS=OFF -G "Visual Studio %VisualStudioVersion:~0,2%%CMAKE_VSARCH%" .. || exit /b 1 msbuild /maxcpucount /p:Configuration=Release libprotoc.vcxproj || exit /b 1 call extract_includes.bat || exit /b 1 popd