refaktor / rye

homoiconic dynamic programming language with some new ideas
https://ryelang.org
Apache License 2.0
406 stars 21 forks source link

Simplify Go build tags #277

Closed stefanb closed 1 month ago

stefanb commented 1 month ago

Currently there is a bunch of go build tags that have to be explicitly listed during build to get various functionalities that are not really depending on some 3rd party C library being installed on the system as they have all the needed implementation in referenced Go modules in pure Go.

Eg https://github.com/refaktor/rye/blob/832b291606652ac7db1da17d03888054d127ccab/.github/workflows/build.yml#L63 lists a bunch of tags to build as much code as possible, but is easy to miss one or even check if all are included.

The list is hard to keep track of and can easily get out of sync and vastly different in other places: https://github.com/refaktor/rye/blob/832b291606652ac7db1da17d03888054d127ccab/.github/workflows/build.yml#L78 https://github.com/refaktor/rye/blob/832b291606652ac7db1da17d03888054d127ccab/.docker/Dockerfile#L10 https://github.com/refaktor/rye/blob/832b291606652ac7db1da17d03888054d127ccab/.goreleaser.yaml#L37 https://github.com/Homebrew/homebrew-core/blob/45c5ae17a86523d65c9b1f1afb02c2de981157ea/Formula/r/ryelang.rb#L22-L23

IMO a better approach would be to include all functionality that only depends on Go code by default, and require tags to specifically enable features relying on external C libraries (ebitengine, webkit, raylib, gtk...).

making it easier to run & install also by

go run github.com/refaktor/rye@latest hello.rye
go install github.com/refaktor/rye@latest

without listing ANY tags.

Such unnecessary build tags could be removed or inverted (eg b_postgres -> b_no_postgres) to allow disabling them if this is needed (eg. if binary size is important).

Some tags could even be combined with default tags (cgo, wasm, linux, windows....), so that eg building wasm wouldn't require b_tiny build flag (not sure if this is still needed).

refaktor commented 1 month ago

I am not in favor of bundling all builtins in, but it would make things simpler, and available for new users, it would simplify build processes, automated and manual. Binary would then have "bateries included" which now they don't so they are less useful

And we just figured out that build flags don't get passed down to imports (I tested it once and falsely concluded that they do get passed). So if we build rye-ebitengine for example we can't pass -tags "b_sqlite" (again example) and rye would include it. So Rye including more bindings by default also solves problems around that, for now at least.

I will do this, I also made multiline repl with microliner work better (but now perfectly yet) so I would make another release with that commit.

Thank you for the proposal!

refaktor commented 1 month ago

I made "allin" branch ... I enabled most modules and also some that weren't in ./build b_* tags now. Now it seems golint-ci is checking all these files and it reported a tons of issues. Which is great, for example "Error return value is not checked" as the builtins will be much more robust in an instant we solve this. But it will take some more time.

refaktor commented 1 month ago

Ok. This was done now. Thanks!