mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-11-06 05:17:42 +00:00
cl.exe cannot write GNU style dependency files directly. It has -showIncludes, which does make it print the dependencies, but they go to stdout, intermixed with the compiler's other output. This wrapper mscl converts the include records from the compiler's stdout into a .d file, written next to the object file as a byproduct of compilation. All other output is forwarded unchanged, with stderr kept on its original stream, and the compiler exit status is passed through. The source file name that cl.exe echoes on every compilation is dropped on the way, so the build output loses that noise as well. Dependency paths are rewritten relative to the current directory, making the .d files independent of how the environment maps Windows drives (MSYS, Cygwin and WSL all differ). Paths on another drive or share stay absolute. Spaces, '#' and '$' are escaped the same way gcc escapes them, and every header gets a -MP style dummy rule so that a header vanishing with a toolchain update marks the objects out of date instead of failing the build through stale .d files. VSLANG is forced to English so the include records keep their known form in every locale. Under WSL the variable is also listed in WSLENV, as that is the only way it reaches the Windows side. The wrapper is a native program because process creation is very expensive on Windows, a shell implementation adds several extra processes per compilation, which measurably slows down the whole build. The same source also builds on POSIX hosts, for driving cl-like cross compilers. When such a compiler reports Windows paths, as cl.exe does under WSL interop, each distinct drive or share root is translated once with wslpath or cygpath and reused for every path below it, so a compilation costs at most one or two extra processes. clang-cl and msvc-wine already report host paths and need none. Signed-off-by: Kacper Michajłow <kasper93@gmail.com>