fyne-io / fyne-cross

Cross compiler tool for Fyne apps
BSD 3-Clause "New" or "Revised" License
231 stars 47 forks source link

Customize `-ldflags` #239

Open george012 opened 3 months ago

george012 commented 3 months ago

Customize -ldflags For example, fyne-cross darwin -arch=arm64,amd64 -app-id com.test.test -ldflags="-X main.GoVersion=1.21.1", this usage, I need this in my App development.

The native compilation method of golang is go build -o build_path/build_name -trimpath -ldflags "-X main.GoVersion=1.21.1" main.go

There are many custom parameters for custom -X ...

Bluebugs commented 3 months ago

You should be able to use GOFLAGS for this purpose I think.

nobe4 commented 2 months ago

Confirmed, it took me a little while to figure it out, but I got the following working:

GOFLAGS="--ldflags=-X=main.version=v0.0.0" fyne-cross darwin -app-id=test.test

The main catch was whitespaces in the GOFLAG variable. See this very informative thread.

I think adding an example in the README would be worth it :)