make-files / makefiles

A library of opinionated Makefiles for popular programming languages.
https://makefiles.dev
MIT License
4 stars 5 forks source link

GOOS, GOARCH and GOARM moving forward #56

Closed na4ma4 closed 3 years ago

na4ma4 commented 3 years ago

This would be a BC break on the makefiles, but my suggestion is segmenting the artifacts/build path to include the OS-ARCH_ARM.

So artifacts/build/debug/linux/amd64/rsc would become artifacts/build/debug/linux-amd64/rsc. This is a small change (but BC breaking) for most common build configurations, but now that ARM is becoming more popular it means more compatibility for things like

This also covers if there is a future version of ARM (ARMv9) which would become linux-arm64_9.

This is mainly for ARM since I really doubt there will be a new amd64 revision requiring something like linux-amd64_2.

The main caveat is that when running on a machine the GOARM is optional, so where the following pattern is common:

.PHONY: run
run: artifacts/build/debug/$(GOHOSTOS)/$(GOHOSTARCH)/rsc
    "$<" $(RUN_ARGS)

changing to artifacts/build/debug/$(GOHOSTOS)-$(GOHOSTARCH)/rsc will work, but the cross-compilation won't match.

It's not a huge issue, but it's just something to think about (linux-arm would work if I ran make run on an RPi zero, but the actual cross-compiled build would need to be linux-arm_5).

na4ma4 commented 3 years ago

Not sure if it's a good idea or not, but maybe putting in targets to catch artifacts/build/(debug|release)/(linux|darwin|windows)/% with a $(error) message that it needs to be changed would be helpful.

jmalloc commented 3 years ago

Is there any particular reason to switch from a slash (and hence separate directories) to a hyphen between OS and ARCH ?

na4ma4 commented 3 years ago

Nope, and if I remove that from it, it's only a BC break for existing ARM projects since arm5 becomes arm_5.

jmalloc commented 3 years ago

If you are happy for that BC break (as ARM's only user currently) I will try to solve this now

na4ma4 commented 3 years ago

So basically

and potentially future artifacts/build/debug/darwin/arm64_9/rsc

na4ma4 commented 3 years ago

I'm down for that, you're already in the code, did you want to do it, or did you want a PR ?

jmalloc commented 3 years ago

In regards to the run convention, it's simply no longer correct to use GOHOSTARCH there. I'd like to just add another variable that is the full build path for the current platform, but I don't think it's currently possible (or at least easy) to detect the correct ARM version if building on arm5/6/7, since go env doesn't show GOARM.

jmalloc commented 3 years ago

I'm down for that, you're already in the code, did you want to do it, or did you want a PR ?

All good, I'm in there messing about now