Skip to content

Commit 69d7a0e

Browse files
hsbtclaude
andcommitted
Point mkmf at the vcpkg packages on mswin
The mswin builds from cache.ruby-lang.org keep the build machine's paths out of configure_args, so extconf.rb no longer finds the vcpkg headers and libraries that ruby-loco located through --with-opt-dir. Their RbConfig also has an empty PKG_CONFIG, so mkmf ran the MSYS2 pkg-config on PATH, which pointed fiddle at the MinGW libffi headers and broke the MSVC build. ruby-loco meant to set PKG_CONFIG to the vcpkg pkgconf, but its path missed a variable and pointed nowhere. #976 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1bb4f9b commit 69d7a0e

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

‎dist/index.js‎

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎windows.js‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ async function installVCPKG(url) {
215215
await common.measure('Extracting mswin vcpkg packages', async () =>
216216
exec.exec('7z', ['x', downloadPath, '-aoa', '-bd', `-o${extractPath}`], { silent: true }))
217217

218-
return await common.measure('Setting up MSVC environment', async () => {
218+
const paths = await common.measure('Setting up MSVC environment', async () => {
219219
const cmd = 'vswhere -latest -property installationPath'
220220
const vcVarsBat = os.arch() === 'arm64' ? 'vcvarsarm64.bat' : 'vcvars64.bat'
221221
const vcVars = `${cp.execSync(cmd).toString().trim()}\\VC\\Auxiliary\\Build\\${vcVarsBat}`
@@ -226,6 +226,23 @@ async function installVCPKG(url) {
226226

227227
return exportCommandEnv(`set "MAKE=nmake" && "${vcVars}"`)
228228
})
229+
230+
await core.group('Setting up vcpkg', async () => {
231+
// mswin Rubies do not record the vcpkg location in configure_args, so the compiler and linker find it through INCLUDE and LIB
232+
const vcpkgDir = `${extractPath}\\installed\\${os.arch()}-windows`
233+
exportEnv({
234+
INCLUDE: `${vcpkgDir}\\include;${process.env.INCLUDE}`,
235+
LIB: `${vcpkgDir}\\lib;${process.env.LIB}`
236+
})
237+
238+
// Without these, mkmf runs the MSYS2 pkg-config on PATH, whose MinGW flags break MSVC builds, and pkgconf only searches the missing tools\lib\pkgconfig
239+
exportEnv({
240+
PKG_CONFIG: `${vcpkgDir}\\tools\\pkgconf\\pkgconf.exe`,
241+
PKG_CONFIG_PATH: `${vcpkgDir}\\lib\\pkgconfig`
242+
})
243+
})
244+
245+
return paths
229246
}
230247

231248
// Run a cmd command, export its environment, and return new paths

0 commit comments

Comments
 (0)