Brian Silverman | f7bd1c2 | 2015-12-24 16:07:11 -0800 | [diff] [blame^] | 1 | model { |
| 2 | toolChains { |
| 3 | visualCpp(VisualCpp) { |
| 4 | // Workaround for VS2015 adapted from https://github.com/couchbase/couchbase-lite-java-native/issues/23 |
| 5 | def VS_2015_INCLUDE_DIR = "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt" |
| 6 | def VS_2015_LIB_DIR = "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/ucrt" |
| 7 | def VS_2015_INSTALL_DIR = 'C:/Program Files (x86)/Microsoft Visual Studio 14.0' |
| 8 | def vsInstallDir = file(VS_2015_INSTALL_DIR) |
| 9 | |
| 10 | // If you ever happen to install and uninstall any other version of VS, Gradle will misdetect the compiler |
| 11 | // and linker to run. This fixes that by manually setting the install dir |
| 12 | if (vsInstallDir.exists()) { |
| 13 | installDir = vsInstallDir |
| 14 | } |
| 15 | |
| 16 | eachPlatform { |
| 17 | cppCompiler.withArguments { args -> |
| 18 | args << '/EHsc' << '/DNOMINMAX' << '/D_SCL_SECURE_NO_WARNINGS' << '/D_WINSOCK_DEPRECATED_NO_WARNINGS' |
| 19 | if (file(VS_2015_INCLUDE_DIR).exists()) { |
| 20 | args << "/I$VS_2015_INCLUDE_DIR" |
| 21 | } |
| 22 | } |
| 23 | linker.withArguments { args -> |
| 24 | if (file(VS_2015_LIB_DIR).exists()) { |
| 25 | if (platform.architecture.name == 'x86') { |
| 26 | args << "/LIBPATH:$VS_2015_LIB_DIR/x86" |
| 27 | } else { |
| 28 | args << "/LIBPATH:$VS_2015_LIB_DIR/x64" |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | ext.setupReleaseDefines = { cppCompiler, linker -> |
| 38 | cppCompiler.args '/O2', '/Zi', '/FS' |
| 39 | linker.args '/DEF:../ntcore.def' |
| 40 | } |
| 41 | |
| 42 | ext.setupDebugDefines = { cppCompiler, linker -> |
| 43 | cppCompiler.args '/Zi', '/FS' |
| 44 | linker.args '/DEBUG', '/DEF:../ntcore.def' |
| 45 | } |
| 46 | |
| 47 | // This is a noop on Windows. On gcc platforms, we strip the release binary and create a separate |
| 48 | // debug library, but Windows already separates debug symbols into a .pdb file. |
| 49 | ext.releaseSetup = {} |