Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use something else than Make to build on Windows #2396

Closed
guillaumerose opened this issue Jun 3, 2021 · 9 comments
Closed

Use something else than Make to build on Windows #2396

guillaumerose opened this issue Jun 3, 2021 · 9 comments

Comments

@guillaumerose
Copy link
Contributor

Make is not really made to run on Windows.
Many reasons:

  • It is not clear where the developer should build: in WSL? Powershell? Cygwin?
  • There are path errors
  • Slash and backslash errors all the time
  • Env. variables cannot be used before a command, etc.

I understand it is not easy to maintain 2 scripts but the current solution doesn't work well and is inefficient.
I would prefer to run a single .ps1 script that does everything (install dependencies and build everything).

PS C:\Users\guillaume\gomod\crc> make
go install -ldflags="-X github.com/code-ready/crc/pkg/crc/version.crcVersion=1.27.0 -X github.com/code-ready/crc/pkg/crc/version.bundleVersion=4.7.11 -X github.com/code-ready/crc/pkg/crc/version.commitSha=ac609dfe -extldflags='-static' "  ./cmd/crc
PS C:\Users\guillaume\gomod\crc> make cross
GOARCH=amd64 GOOS=darwin go build -ldflags="-X github.com/code-ready/crc/pkg/crc/version.crcVersion=1.27.0 -X github.com/code-ready/crc/pkg/crc/version.bundleVersion=4.7.11 -X github.com/code-ready/crc/pkg/crc/version.commitSha=ac609dfe -extldflags='-static' " -o out/macos-amd64/crc  ./cmd/crc
'GOARCH' is not recognized as an internal or external command,
@gbraad
Copy link
Contributor

gbraad commented Jun 3, 2021

We never supported building on Windows directly due to these issues with make, ssh inconsistencies etc. Recommended is to use WSL or Linux with make cross.

However, Appveyor's image is the baseline for this as it includes Visual Studio and the needed make that is used.

@guillaumerose
Copy link
Contributor Author

For the MSI, we need to build on Windows so this needs to change.

@gbraad
Copy link
Contributor

gbraad commented Jun 3, 2021

For the MSI, we need to build on Windows so this needs to change.

As I understood it was investigated to use generally available tools to build the MSI.

https://github.com/code-ready/crc/wiki/Building-the-msi-package

This includes wix-toolset, which also runs on appveyor: https://github.com/code-ready/crc/blob/66e85bb1a1be7bfbbf4ef4ac46eee9eb5c0dd1a0/appveyor.yml#L11

The only requirement is that make and git is available for the buildscript to run

Note: There is work on getting this (wix-toolset) to run from Linux, more can be found here: wixtoolset/issues#4381 Docker images have been attempted before, but I'd prefer to stick with make and just add a simple setup file.

@gbraad
Copy link
Contributor

gbraad commented Jun 3, 2021

@anjannath
Copy link
Member

anjannath commented Jun 3, 2021

make cross works fine in powershell here:

PS C:\Users\anath\redhat\crc> make cross
GOARCH=amd64 GOOS=darwin go build -ldflags="-X github.com/code-ready/crc/pkg/crc/version.crcVersion=1.27.0 -X github.com/code-ready/crc/pkg/crc/version.bundleVersion=4.7.11 -X github.com/code-ready/crc/pkg/crc/version.commitSha=40f235bb -extldflags='-static' " -o out/macos-amd64/crc  ./cmd/crc
GOOS=linux GOARCH=amd64 go build -ldflags="-X github.com/code-ready/crc/pkg/crc/version.crcVersion=1.27.0 -X github.com/code-ready/crc/pkg/crc/version.bundleVersion=4.7.11 -X github.com/code-ready/crc/pkg/crc/version.commitSha=40f235bb -extldflags='-static' " -o out/linux-amd64/crc  ./cmd/crc
GOARCH=amd64 GOOS=windows go build -ldflags="-X github.com/code-ready/crc/pkg/crc/version.crcVersion=1.27.0 -X github.com/code-ready/crc/pkg/crc/version.bundleVersion=4.7.11 -X github.com/code-ready/crc/pkg/crc/version.commitSha=40f235bb -extldflags='-static' " -o out/windows-amd64/crc.exe  ./cmd/crc

I recently setup my new windows machine, so i have cygwin installed and make and git from cygwin, also there are issues with the backslashes like for make clean but it doesn't error out or stop make

PS C:\Users\anath\redhat\crc> make clean
rm -rf /cygdrive/c/Users/anath/redhat/crc/docs/build
rm -f packaging/darwin/Distribution
rm -f packaging/darwin/Resources/welcome.html
rm -f packaging/darwin/scripts/postinstall
rm -rf packaging/root/
rm -rf packaging/windows/msi
rm -f out/windows-amd64/split
rm -f packaging/rpm/crc.spec images/rpmbuild/Containerfile
rm -rf out
rm -f C:\Users\anath\go/bin/crc <-- like this one
rm -rf release

@gbraad
Copy link
Contributor

gbraad commented Jun 3, 2021

same here, and also on AppVeyor, so this sounds like configuration issues. Especially not understanding where this comes from:

There are path errors
Slash and backslash errors all the time

@gbraad
Copy link
Contributor

gbraad commented Jun 3, 2021

also there are issues with the backslashes like for make clean

Instead of changing the tool, these can be fixed. The additional overhead and maintenance that a new build script introduces does not sounds appealing. But that would be cygwin, right @anjannath. This has never been a recommendation as that also resulted in people running the tool from the bash prompt and then issues arose with the hyper-v driver, the ssh implementation. I believe the recommendation has always been to use PowerShell with make + git to compile on WIndows. An additional script to setup the environment, shared with what is done on AppVeyor is possible and very trivial.

@guillaumerose
Copy link
Contributor Author

Let's close this for the moment. I found a way to get everything working. I would prefer to only use PowerShell and not have to mess with Cygwin, etc.

@ewheelerinc
Copy link

Maybe CMake is the way to go instead of Make. VS2019 has support for cmake according to this article, and it would facilitate building in Linux as well (wixtoolset/issues#4381):

https://docs.microsoft.com/en-us/cpp/linux/create-a-new-linux-project?view=msvc-160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants