diff --git a/cli/src/api/new.ts b/cli/src/api/new.ts index a39dfb99..81abe67e 100644 --- a/cli/src/api/new.ts +++ b/cli/src/api/new.ts @@ -169,6 +169,7 @@ async function filterTargetsInGithubActions( const macOSAndWindowsTargets = new Set([ 'x86_64-pc-windows-msvc', + 'x86_64-pc-windows-gnu', 'aarch64-pc-windows-msvc', 'x86_64-apple-darwin', ]) diff --git a/cli/src/api/templates/js-binding.ts b/cli/src/api/templates/js-binding.ts index b0d4ac6f..fa311fc8 100644 --- a/cli/src/api/templates/js-binding.ts +++ b/cli/src/api/templates/js-binding.ts @@ -146,7 +146,11 @@ function requireNative() { } } else if (process.platform === 'win32') { if (process.arch === 'x64') { - ${requireTuple('win32-x64-msvc')} + if (process.report?.getReport?.()?.header?.osName?.startsWith?.('MINGW')) { + ${requireTuple('win32-x64-gnu')} + } else { + ${requireTuple('win32-x64-msvc')} + } } else if (process.arch === 'ia32') { ${requireTuple('win32-ia32-msvc')} } else if (process.arch === 'arm64') { diff --git a/cli/src/utils/__tests__/__snapshots__/target.spec.ts.md b/cli/src/utils/__tests__/__snapshots__/target.spec.ts.md index 19d0f442..fd6d6cf5 100644 --- a/cli/src/utils/__tests__/__snapshots__/target.spec.ts.md +++ b/cli/src/utils/__tests__/__snapshots__/target.spec.ts.md @@ -65,6 +65,13 @@ Generated by [AVA](https://avajs.dev). platformArchABI: 'win32-x64-msvc', triple: 'x86_64-pc-windows-msvc', }, + { + abi: 'gnu', + arch: 'x64', + platform: 'win32', + platformArchABI: 'win32-x64-gnu', + triple: 'x86_64-pc-windows-gnu', + }, { abi: 'gnu', arch: 'x64', diff --git a/cli/src/utils/__tests__/__snapshots__/target.spec.ts.snap b/cli/src/utils/__tests__/__snapshots__/target.spec.ts.snap index 311ec82a..c6583d6d 100644 Binary files a/cli/src/utils/__tests__/__snapshots__/target.spec.ts.snap and b/cli/src/utils/__tests__/__snapshots__/target.spec.ts.snap differ diff --git a/cli/src/utils/target.ts b/cli/src/utils/target.ts index f379f980..e4ad35a4 100644 --- a/cli/src/utils/target.ts +++ b/cli/src/utils/target.ts @@ -17,6 +17,7 @@ export const AVAILABLE_TARGETS = [ 'aarch64-pc-windows-msvc', 'x86_64-apple-darwin', 'x86_64-pc-windows-msvc', + 'x86_64-pc-windows-gnu', 'x86_64-unknown-linux-gnu', 'x86_64-unknown-linux-musl', 'x86_64-unknown-linux-ohos',