Any way to specify default -D options?

I have some libraries that work differently depending on what -D flags you pass. In some programs that use them, only some combinations of -D flags work.

I am currently doing this via makefiles and similar things.

Would it make sense to add something like that to shard.yml somehow so “shards build” does the right thing?

There is CRYSTAL_OPTS, but I don’t know if -D is part of that. It should be.

However there is a bit of a danger there in as there is risk stuff break if the particular flag you are giving doesn’t work for the crystal compiler command you do.

Using build system recipes seems like the best way to handle different configurations.

Yes, you can pass compiler flags via CRYSTAL_OPTS.

There isn’t and I think there should because some flags are project wide. Build recipes are nice but each project has its own custom solution to learn & remember :slightly_frowning_face:

I don’t think it fits the crystal compiler. Similar to Rust’s cargo, we might want a build tool on top of shards and crystal that would be called with additional configuration, for example read from shard.yml.

I do have a generic crystal build tool I could maybe improve so it’s smarter for this kind of thing and supports the usual crystal project structure.

Reminds me of community projects like GitHub - devnote-dev/geode: An alternative Crystal package manager that do add the ability for flags to be defined on a target and passes them to the underlying crystal build from doing a shards build. IIRC that idea was brought up before and would be pretty low hanging fruit imo.