compiler.nvim icon indicating copy to clipboard operation
compiler.nvim copied to clipboard

Add Windows support

Open Gaweringo opened this issue 1 year ago • 2 comments

This PR would make all commands which use rm -f and mkdir -p windows compatible by adding the get_commands() function to utils which swaps the unix commands with the cmd commands erase /s /q and mkdir. The way to ignore errors is also different and is changed from || true to > nul 2> nul & cd. for cmd. Ignoring errors is also needed for mkdir in cmd, since there is no -p equivalent.

I could not test the asm changes fully yet, since it uses linux/unix syscalls from what I understand. Building and linking works, but the "Run program" does not succeed and exits with a large negative exit code.

Languages which had changes:

  • asm
  • c
  • cpp
  • cs
  • dart
  • go
  • java
  • kotlin
  • python
  • rust
  • swift
  • fortran

Bau which had changes:

  • cmake
  • meson

From my testing, everything should still work on Linux with these changes.

Let me know if I need to change something, or if this PR might go in the wrong direction / uses an undesired approach.

Gaweringo avatar Sep 23 '24 23:09 Gaweringo

Thank you for taking the time to send this PR @Gaweringo. I imagine some Windows users might prefer this approach over WSL, specially when trying the plugin for the first time.

Please give me this week to review it.

In the mean time if you want, you can check if the tests pass on windows running this command inside of Neovim:

-- Change the path to wathever the nvim <data> dir is on windows.
:luafile ~/.local/share/nvim/lazy/compiler.nvim/tests/tests.lua

Zeioth avatar Sep 24 '24 11:09 Zeioth

I ran the test files for the languages I changed.

  • The Flutter Linux build fails (expected)
  • asm had some errors but now works, except for when the compiled program is run, as it does not exit with a 0 error code on Windows. So the status stays at RUNNING
  • The C# csc compilations error (remains in RUNNING state) at an assertion: * Assertion: should not be reached at ..\mono\metadata\marshal-ilgen.c:6239.
    • Removing the /debug argument results in a successful compilation

Gaweringo avatar Sep 24 '24 12:09 Gaweringo