prusa3d / PrusaSlicer

G-code generator for 3D printers (RepRap, Makerbot, Ultimaker etc.)
https://www.prusa3d.com/prusaslicer/
GNU Affero General Public License v3.0
7.66k stars 1.92k forks source link

Added support for building with MSBuild Tools #8519

Open StephS opened 2 years ago

StephS commented 2 years ago

I have worked to modify the build_win.bat to not only support Visual Studio 2019, but also MSBuild Tools 2019. MSBuild Tools has all of the same compiler tools as Visual Studio, but without requiring a Visual Studio install. This can help allow a leaner dev environment for those who do not wish to install Visual Studio. The changes include modifying the lines where vswhere.exe is used, and some switches for testing the functionality (I would have added command line flags but I don't understand the parsing section).

You can view the changes on my fork here: https://github.com/StephS/PrusaSlicer/tree/MSBuild To Test, install MSBuild Tools 2019 (I think I also needed to install powershell). Then edit the line "SET PS_USE_MSBUILD=" to "SET PS_USE_MSBUILD=1". I have been able to test on my own system with both Visual Studio and MSBuild installed.

With approval I can create a pull request.

lukasmatena commented 2 years ago

Thanks. The build script is @jschuh 's baby. He would be the most competent to review the changes. @jschuh Would you mind looking into this, if / when you have the time and the right mood?

jschuh commented 2 years ago

Seems reasonable to support MSBuild. My original goal was just to make it as easy to spin up a custom build on Windows as it is on Linux, but I don't think anyone would object to supporting a broader range of tooling.

You can take a look at commit cfdf7d2a00c3979ae52946e2ae0a920b8e8d514e for the simplest possible example of adding a command line parameter. That should work as a template for that part of your proposed change.

I do have a few more suggestions on the implementation:

lukasmatena commented 2 years ago

Thanks. If there is a PR that @jschuh reviews and approves, it will be merged. Given that the script is a convenient helper and not a part of the build process, we cannot invest much time into its maintenance and testing, not to mention that nobody of us is an expert on different MSVC versions and gotchas. Our review will no go much further than checking that there is no format C: or expletives in echos.

StephS commented 2 years ago

Thanks, I created a pull request https://github.com/prusa3d/PrusaSlicer/pull/8554 Regarding the version handling, v17 is excluded (it is set to search for <17). This is the same behavior that was seen here: https://github.com/prusa3d/PrusaSlicer/pull/8554/files#diff-bf6b22b4e8a901118a4bd8786d11c2e06a0553e374dfd2c4dcdbbce795003a8bL80

StephS commented 2 years ago

Pinging @jschuh I think it's ready, it's difficult to test with msbuild only and MSVS only installs, but the command line switch works successfully to switch between the two.