Tinygo: Inject build-time variables

Created on 10 Apr 2020  路  2Comments  路  Source: tinygo-org/tinygo

With go you can inject variables using ldflags like this:

go build -o ./main.wasm -ldflags "-X main.Version=$(VERSION)" ./main.go

Attempting this with tinygo:

tinygo build -o ./main.wasm -target wasm -ldflags "-X main.Version=$(VERSION)" ./main.go

Gives:

tinygo:wasm-ld: error: unknown argument: -X
tinygo:wasm-ld: error: cannot open main.Version=1.0.0: No such file or directory
error: failed to link /var/folders/jc/3lr9ltt96k90h_mg_xq6pvbw0000gn/T/tinygo833831446/main: failed to link using built-in wasm-ld

Is there an equivalent way to achieve this in tinygo?

enhancement

Most helpful comment

Right now, unfortunately not. However I think functionality like this would be useful in the long term (for example, to set a WiFi password at compile time when you're building firmware for a personal IoT-like device).

All 2 comments

Right now, unfortunately not. However I think functionality like this would be useful in the long term (for example, to set a WiFi password at compile time when you're building firmware for a personal IoT-like device).

@aykevl I really need this feature for something. Any thoughts on implementation that we could work on?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nerzal picture Nerzal  路  5Comments

alankrantas picture alankrantas  路  4Comments

Zambiorix picture Zambiorix  路  3Comments

bradleypeabody picture bradleypeabody  路  7Comments

cleahcim picture cleahcim  路  5Comments