[ntcoreffi] Use static runtime for ntcoreffi (#7422)

This avoids requiring users of this library to keep up to date with the latest MSVC runtimes.
This commit is contained in:
Thad House
2024-11-21 23:14:12 +00:00
committed by GitHub
parent 0a3ccf93c6
commit b4a8d33486
3 changed files with 31 additions and 1 deletions

View File

@@ -96,9 +96,16 @@ jobs:
task: "build"
outputs: "build/allOutputs"
- os: windows-2022
artifact-name: Win32
artifact-name: Win32FFI
architecture: x86
task: ":ntcoreffi:build"
build-options: "-Pntcoreffibuild \"-Dorg.gradle.jvmargs=-Xmx1096m\""
outputs: "ntcoreffi/build/outputs"
- os: windows-2022
artifact-name: Win64FFI
architecture: x64
task: ":ntcoreffi:build"
build-options: "-Pntcoreffibuild -Pbuildwinarm64"
outputs: "ntcoreffi/build/outputs"
name: "Build - ${{ matrix.artifact-name }}"
runs-on: ${{ matrix.os }}

View File

@@ -1,3 +1,5 @@
import org.gradle.internal.os.OperatingSystem
plugins {
id 'c'
id 'cpp'
@@ -119,6 +121,10 @@ task cppHeadersZip(type: Zip) {
}
}
if (OperatingSystem.current().isWindows() && !project.hasProperty('ntcoreffibuild')) {
return
}
build.dependsOn cppHeadersZip
addTaskToCopyAllOutputs(cppHeadersZip)

View File

@@ -41,6 +41,23 @@ nativeUtils.platformConfigs.each {
nativeUtils.platformConfigs.linuxathena.linker.args.add("-Wl,--fatal-warnings")
if (project.hasProperty('ntcoreffibuild')) {
// On windows, for ntcoreffi, use static runtime
nativeUtils.platformConfigs.each {
if (it.name.contains('windows')) {
it.cCompiler.releaseArgs.remove('/MD')
it.cppCompiler.releaseArgs.remove('/MD')
it.cCompiler.debugArgs.remove('/MDd')
it.cppCompiler.debugArgs.remove('/MDd')
it.cCompiler.releaseArgs.add('/MT')
it.cppCompiler.releaseArgs.add('/MT')
it.cCompiler.debugArgs.add('/MTd')
it.cppCompiler.debugArgs.add('/MTd')
}
}
}
model {
components {
all {