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

Makefile for Windows #843

Closed
BElluu opened this issue Jul 11, 2023 · 3 comments
Closed

Makefile for Windows #843

BElluu opened this issue Jul 11, 2023 · 3 comments

Comments

@BElluu
Copy link

BElluu commented Jul 11, 2023

Hello,
In documentation I see

build:
	GOARCH=wasm GOOS=js go build -o web/app.wasm
	go build

run: build
	./hello

but when I run this makefile I got error
image

I think this problem is because I develop on windows. Someone can tell me, how should I build app?

@oderwat
Copy link
Sponsor Contributor

oderwat commented Jul 11, 2023

This is using Unix shell syntax (bash / zsh), I wonder what 'make' is running it. You could try using "set" on an extra line

set GOARCH=wasm
set GOOS=js
go build -o web/app.wasm

Disclaimer: I am not a Windows guy (anymore). We usually don't compile for Windows on Windows. Instead, we cross compile using an Earthly builder on Linux from a Mac, which is our standard developer system. I think it would work with a Makefile, if you use something like CygWin (what I used in the past, maybe read up on How To Use Makefiles on Windows). When on Windows, I usually have WSL2 (and Docker) running for development. But, I am certain, that the "Windows" people here can tell you their best practices.

@suntong
Copy link

suntong commented Jul 31, 2023

Easiest way is to run make under Git Bash, as you need Git Bash to use git under Window anyway.
(How to use make under Git Bash will be out of the scope of this project, if you don't know, please ask in more appropriate places instead)

@oderwat
Copy link
Sponsor Contributor

oderwat commented Jul 31, 2023

I think that using Mage is actually a nicer option than using make in general. This will work on Windows too and even without a local mage installation (which is trivial when running Go). That way, it is fully independent of the shell. I used this for the go-nats-app example (magefile.go). The example shows the two stage compilation and can easily be extended and reused for other projects. We have some large ones which can create docker images, handle deployment and auto-recompile on code changes and such stuff. Besides that, I would again recommend using Earthly when projects get larger. This is our solution for "everything" (CI/CD) with occasional extra scripts (as the build environment is containerized, They have a nice tutorial and the "final" Earthfile version for Go is easy to understand. It will allow all the nifty Linux tools) or magefiles. This should also work on Windows (we are on Mac/Linux/WSL2).

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

No branches or pull requests

4 participants