Is it possible to do some "if Windows", "if Linux" checks, etc. in the shards.yaml file?

Is it possible to do some “if Windows”, “if Linux” checks, etc. in the shards.yaml file ?

(to avoid unnecessary downloads, depending upon the platforms, i.e. : to allow platform-specific installations) ?

Short answer, not really.

Related: How to change shard.yml (for Windows)

1 Like

Thank you !

Maybe you can compile this C code and call it from Crystal, if not possible in Crystal itself?:

#include <stdio.h>

#if defined(_WIN32) || defined(_WIN64)
        const char* os = "Windoze";
#else
#ifdef __linux
        const char* os = "Linux";
#else
        const char* os = "Unknown";
#endif
#endif

int main(void)
{
   printf("os = %s\n", os);
   return 0;
}
1 Like

Thank you, but the shards.yml itself is not Crystal code!

On the other hand, with the new browser, there’s no need anymore for a different .yml file per platform. The dependencies are again the same on all platforms (so, problem solved). :slight_smile: