Add wslc shell script for WSL interop#40142
Add wslc shell script for WSL interop#40142benhillis wants to merge 2 commits intofeature/wsl-for-appsfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a Windows-installed wslc POSIX shell wrapper so users inside WSL can run wslc (no .exe) and have it forward to the adjacent wslc.exe, and wires it into MSI packaging + a basic smoke test.
Changes:
- Add
src/windows/wslc/wslcwrapper script and enforce LF line endings via.gitattributes. - Include the script in the MSI (
package.wix.in) and ensure MSI rebuilds when it changes (msipackage/CMakeLists.txt). - Add a Windows smoke test validating
wslcvswslc.exeoutput in WSL.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/windows/SimpleTests.cpp | Adds smoke test comparing wslc.exe version vs wslc version output inside WSL. |
| src/windows/wslc/wslc | New shell wrapper that locates wslc.exe next to itself and forwards args. |
| src/windows/wslc/.gitattributes | Forces LF for the wrapper script so it runs correctly under WSL. |
| msipackage/package.wix.in | Adds the wslc script file to the MSI installation payload. |
| msipackage/CMakeLists.txt | Ensures MSI packaging rebuilds when the wrapper script changes. |
|
The thing to be aware of here is that from inside of WSL, when you call |
Yeah that's valid, but that's an existing issue unrelated to this pr. |
| WSL_PATH="$(dirname "$(realpath "$0")")" | ||
| WSLC_EXE="$WSL_PATH/wslc.exe" | ||
|
|
||
| "$WSLC_EXE" "$@" |
There was a problem hiding this comment.
nit: We could exec to avoid creating an additional process
|
Need to close on if this is a good idea or not. |
Add a shell script that allows WSL users to run 'wslc' without the .exe extension, similar to how VS Code ships a 'code' script alongside code.exe. The script resolves wslc.exe relative to its own location and forwards all arguments. - src/windows/wslc/wslc: new shell script - msipackage: include the script in the MSI package - test/windows/SimpleTests.cpp: add WslcShellScript smoke test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address PR feedback: assert that stderr output is identical between the shell script and direct .exe invocation, fixing unused variable warnings that would fail MSVC /WX builds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
79a98a3 to
ad0e370
Compare
| "$WSLC_EXE" "$@" | ||
| exit $? |
There was a problem hiding this comment.
The wrapper runs wslc.exe as a child process and then explicitly exit $?. Using exec "$WSLC_EXE" "$@" would replace the shell process with wslc.exe, avoiding an extra process and ensuring signal/exit-code behavior matches the underlying CLI more directly (e.g., Ctrl-C / SIGINT handling).
| "$WSLC_EXE" "$@" | |
| exit $? | |
| exec "$WSLC_EXE" "$@" |
Summary
Add a shell script that allows WSL users to run
wslcinstead ofwslc.exefrom within a WSL distribution, similar to how VS Code ships acodescript alongsidecode.exe.Changes
src/windows/wslc/wslc— New shell script that resolveswslc.exerelative to its own location and forwards all argumentssrc/windows/wslc/.gitattributes— Enforces LF line endings so the script works in WSLmsipackage/package.wix.in— Adds the script to the MSI package (installed toProgram Files\WSL)msipackage/CMakeLists.txt— Adds the script as a build dependency for the MSItest/windows/SimpleTests.cpp— AddsWslcShellScriptsmoke test that verifieswslcandwslc.exeproduce identical output inside WSLHow it works
Since
Program Files\WSLis already on the system PATH (added by the MSI), and WSL appends Windows PATH entries by default, the extensionlesswslcscript is found automatically when a user typeswslcinside a WSL distribution.