mirror of
https://github.com/Cheviiot/Vintner.git
synced 2026-08-03 15:57:24 +00:00
Initial implementation of msvc-go-wine
A single-binary Go tool for cross compiling with the real MSVC toolchain on Linux via Wine. Behaves as cl/link/lib/rc/midl/mt/dumpbin/msbuild/ nmake/ml/ml64/armasm/armasm64/cmd/findstr depending on the name it's invoked as, plus download/install/env/version management subcommands. - download: fetches the MSVC/WinSDK installer manifest, resolves package selection and dependencies, downloads and verifies payloads, unpacks VSIX/MSI packages, and applies a handful of compatibility patches so VsDevCmd.bat and MSBuild's SDK detection work without a Windows Registry (which doesn't exist under Wine). - install: locates the installed toolchain/SDK versions, normalizes header/library name casing, lays out per-architecture tool symlinks with an env.json config each, and compiles a small native launcher (toolrelay.exe) that lets mt.exe's CMake-compatibility exit code survive Wine's own exit-code truncation. - The wrapper runtime rewrites absolute unix paths in tool arguments into Wine's z:\... form, runs the real .exe under wine, and rewrites the tool's output back to plain unix paths. Verified end-to-end against a real MSVC/WinSDK download: cl, link, mt and the resulting hello.exe all work under Wine, including through the toolrelay.exe relay path and with paths containing non-ASCII characters. Offline unit tests cover the wrapper's path-rewrite/output-filter logic, install-time header lowercasing, and download package-selection/ dependency-resolution.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
// Package wrapper implements the per-tool command dispatch (cl, link, lib,
|
||||
// ml, ml64, mc, midl, mt, rc, dumpbin, msbuild, nmake, armasm, armasm64, cmd,
|
||||
// findstr): loading each tool's environment, invoking it under Wine, and
|
||||
// filtering its output.
|
||||
package wrapper
|
||||
|
||||
import "github.com/Cheviiot/msvc-go-wine/internal/wineenv"
|
||||
|
||||
// dirKind selects which install directory a tool's real .exe lives in.
|
||||
type dirKind int
|
||||
|
||||
const (
|
||||
dirBin dirKind = iota // <bindir> - vc/tools/msvc/<ver>/bin/Host<host>/<arch>
|
||||
dirSDK // <sdkbindir> - kits/10/bin/<sdkver>/<host>
|
||||
dirMSBuild
|
||||
)
|
||||
|
||||
type spec struct {
|
||||
exeName string
|
||||
dir dirKind
|
||||
rawStdout bool // MSBuild: skip line filtering, inherit stdio directly
|
||||
stdoutFilter lineFilter
|
||||
stderrFilter lineFilter
|
||||
postProcess func(origArgs []string) // cl: fix up /P /Fi<file> output
|
||||
}
|
||||
|
||||
// Tools lists every multi-call name this binary answers to, besides its own
|
||||
// management-CLI name.
|
||||
var Tools = map[string]spec{
|
||||
"cl": {exeName: "cl.exe", dir: dirBin, stdoutFilter: clStdoutFilter, stderrFilter: clStderrFilter, postProcess: clPostProcess},
|
||||
"link": {exeName: "link.exe", dir: dirBin},
|
||||
"lib": {exeName: "lib.exe", dir: dirBin},
|
||||
"ml": {exeName: "ml.exe", dir: dirBin},
|
||||
"ml64": {exeName: "ml64.exe", dir: dirBin},
|
||||
"nmake": {exeName: "nmake.exe", dir: dirBin},
|
||||
"armasm": {exeName: "armasm.exe", dir: dirBin},
|
||||
"armasm64": {exeName: "armasm64.exe", dir: dirBin},
|
||||
"dumpbin": {exeName: "dumpbin.exe", dir: dirBin, stdoutFilter: dumpbinStdoutFilter},
|
||||
"mc": {exeName: "mc.exe", dir: dirSDK},
|
||||
"midl": {exeName: "midl.exe", dir: dirSDK},
|
||||
"mt": {exeName: "mt.exe", dir: dirSDK},
|
||||
"rc": {exeName: "rc.exe", dir: dirSDK},
|
||||
"msbuild": {exeName: "MSBuild.exe", dir: dirMSBuild, rawStdout: true},
|
||||
}
|
||||
|
||||
// nativeTools are handled entirely without Wine.
|
||||
var nativeTools = map[string]bool{"cmd": true, "findstr": true}
|
||||
|
||||
func (s spec) exeDir(p *wineenv.Paths) string {
|
||||
switch s.dir {
|
||||
case dirSDK:
|
||||
return p.SDKBinDir
|
||||
case dirMSBuild:
|
||||
return p.MSBuildBinDir
|
||||
default:
|
||||
return p.BinDir
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user