From e71deb897620230a4251b409ed96ba883976ceeb Mon Sep 17 00:00:00 2001 From: s1lent Date: Sun, 7 May 2017 01:19:06 +0700 Subject: [PATCH] Add support for VS2015/VS2017 in old gradle. --- getucrtinfo.bat | 19 +++++++++++++++++++ shared_msvc.gradle | 19 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 getucrtinfo.bat diff --git a/getucrtinfo.bat b/getucrtinfo.bat new file mode 100644 index 00000000..29f5bb16 --- /dev/null +++ b/getucrtinfo.bat @@ -0,0 +1,19 @@ +@echo off + +if defined VS150COMNTOOLS ( + if not exist "%VS150COMNTOOLS%vcvarsqueryregistry.bat" goto NoVS + call "%VS150COMNTOOLS%vcvarsqueryregistry.bat" + goto :run +) else if defined VS140COMNTOOLS ( + if not exist "%VS140COMNTOOLS%vcvarsqueryregistry.bat" goto NoVS + call "%VS140COMNTOOLS%vcvarsqueryregistry.bat" + goto :run +) + +:NoVS +echo Error: Visual Studio 2015 or 2017 required. +exit /b 1 + +:run +echo %UniversalCRTSdkDir% +echo %UCRTVersion% diff --git a/shared_msvc.gradle b/shared_msvc.gradle index ea8fe42e..260e5db7 100644 --- a/shared_msvc.gradle +++ b/shared_msvc.gradle @@ -114,5 +114,22 @@ rootProject.ext.createMsvcConfig = { boolean release, BinaryKind binKind -> } } + // Detect and setup UCRT paths + def ucrtInfo = "getucrtinfo.bat".execute().text + def m = ucrtInfo =~ /^(.*)\r\n(.*)?$/ + if (!m.find()) { + return cfg + } + + def kitPath = m.group(1) + def ucrtVersion = m.group(2) + def ucrtCheckFile = new File("${kitPath}Include/${ucrtVersion}/ucrt/stdio.h"); + if (!ucrtCheckFile.exists()) { + return cfg + } + + cfg.compilerOptions.args "/FS", "/I${kitPath}Include/${ucrtVersion}/ucrt"; + cfg.linkerOptions.args("/LIBPATH:${kitPath}Lib/${ucrtVersion}/ucrt/x86"); + return cfg -} \ No newline at end of file +}