mirror of https://github.com/grpc/grpc-java.git
compiler: Verify binary with native VS commands
This allows building release binaries on Windows without Bash and GCC.
This commit is contained in:
parent
83d710b6d7
commit
8bcb5cfac6
|
|
@ -37,6 +37,7 @@ def addLibraryIfNotLinked = { libName, argList ->
|
||||||
|
|
||||||
def String arch = rootProject.hasProperty('targetArch') ? rootProject.targetArch : osdetector.arch
|
def String arch = rootProject.hasProperty('targetArch') ? rootProject.targetArch : osdetector.arch
|
||||||
def boolean vcDisable = rootProject.hasProperty('vcDisable') ? rootProject.vcDisable : false
|
def boolean vcDisable = rootProject.hasProperty('vcDisable') ? rootProject.vcDisable : false
|
||||||
|
def boolean usingVisualCpp // Whether VisualCpp is actually available and selected
|
||||||
|
|
||||||
model {
|
model {
|
||||||
toolChains {
|
toolChains {
|
||||||
|
|
@ -104,6 +105,7 @@ model {
|
||||||
}
|
}
|
||||||
addEnvArgs("LDFLAGS", linker.args)
|
addEnvArgs("LDFLAGS", linker.args)
|
||||||
} else if (toolChain in VisualCpp) {
|
} else if (toolChain in VisualCpp) {
|
||||||
|
usingVisualCpp = true
|
||||||
cppCompiler.define("GRPC_VERSION", version)
|
cppCompiler.define("GRPC_VERSION", version)
|
||||||
cppCompiler.args "/EHsc", "/MT"
|
cppCompiler.args "/EHsc", "/MT"
|
||||||
if (rootProject.hasProperty('vcProtobufInclude')) {
|
if (rootProject.hasProperty('vcProtobufInclude')) {
|
||||||
|
|
@ -255,13 +257,44 @@ artifacts {
|
||||||
|
|
||||||
[
|
[
|
||||||
uploadArchives.repositories.mavenDeployer,
|
uploadArchives.repositories.mavenDeployer,
|
||||||
]*.beforeDeployment {
|
]*.beforeDeployment { it ->
|
||||||
def ret = exec {
|
if (!usingVisualCpp) {
|
||||||
executable 'bash'
|
def ret = exec {
|
||||||
args 'check-artifact.sh', osdetector.os, arch
|
executable 'bash'
|
||||||
}
|
args 'check-artifact.sh', osdetector.os, arch
|
||||||
if (ret.exitValue != 0) {
|
}
|
||||||
throw new GradleException("check-artifact.sh exited with " + ret.exitValue)
|
if (ret.exitValue != 0) {
|
||||||
|
throw new GradleException("check-artifact.sh exited with " + ret.exitValue)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
def exeName = "$artifactStagingPath/java_plugin/${protocPluginBaseName}.exe"
|
||||||
|
def os = new ByteArrayOutputStream()
|
||||||
|
def ret = exec {
|
||||||
|
executable 'dumpbin'
|
||||||
|
args '/nologo', '/dependents', exeName
|
||||||
|
standardOutput = os
|
||||||
|
}
|
||||||
|
if (ret.exitValue != 0) {
|
||||||
|
throw new GradleException("dumpbin exited with " + ret.exitValue)
|
||||||
|
}
|
||||||
|
def dlls = os.toString() =~ /Image has the following dependencies:\s+(.*)\s+Summary/
|
||||||
|
if (dlls[0][1] != "KERNEL32.dll") {
|
||||||
|
throw new Exception("unexpected dll deps: " + dlls[0][1]);
|
||||||
|
}
|
||||||
|
os.reset()
|
||||||
|
ret = exec {
|
||||||
|
executable 'dumpbin'
|
||||||
|
args '/nologo', '/headers', exeName
|
||||||
|
standardOutput = os
|
||||||
|
}
|
||||||
|
if (ret.exitValue != 0) {
|
||||||
|
throw new GradleException("dumpbin exited with " + ret.exitValue)
|
||||||
|
}
|
||||||
|
def machine = os.toString() =~ / machine \(([^)]+)\)/
|
||||||
|
def expectedArch = [x86_32: "x86", x86_64: "x64"][arch]
|
||||||
|
if (machine[0][1] != expectedArch) {
|
||||||
|
throw new Exception("unexpected architecture: " + machine[0][1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue