Skip to content

Commit

Permalink
[ntcoreffi] Use static runtime for ntcoreffi (#7422)
Browse files Browse the repository at this point in the history
This avoids requiring users of this library to keep up to date with the latest MSVC runtimes.
  • Loading branch information
ThadHouse authored Nov 21, 2024
1 parent 0a3ccf9 commit b4a8d33
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
6 changes: 6 additions & 0 deletions ntcoreffi/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.gradle.internal.os.OperatingSystem

plugins {
id 'c'
id 'cpp'
Expand Down Expand Up @@ -119,6 +121,10 @@ task cppHeadersZip(type: Zip) {
}
}

if (OperatingSystem.current().isWindows() && !project.hasProperty('ntcoreffibuild')) {
return
}

build.dependsOn cppHeadersZip
addTaskToCopyAllOutputs(cppHeadersZip)

Expand Down
17 changes: 17 additions & 0 deletions shared/config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b4a8d33

Please sign in to comment.