Hello,
Is there a way to pass data during the crystal build
? What I mean is similar to how it’s done in Go:
go build -ldflags "-X main.VariableName=VariableValue"
see article - https://blog.alexellis.io/inject-build-time-vars-golang/
Hello,
Is there a way to pass data during the crystal build
? What I mean is similar to how it’s done in Go:
go build -ldflags "-X main.VariableName=VariableValue"
see article - https://blog.alexellis.io/inject-build-time-vars-golang/
Prob could use env vars and https://crystal-lang.org/api/Crystal/Macros.html#env(name):StringLiteral|NilLiteral-instance-method to do this.
Something like:
puts "Hello World, version: #{{{env("VERSION")}}}"
VERSION=$(git rev-list -1 HEAD) crystal build test.cr
./test # => Hello World, version: 719d314879719eb98099459199d3493f09694841
Wow, that’s actually way more convenient than in Go. Thank you, I’ll try it out!