Anyone know of an easy way to determine runtime OS? I’d like to be able to tell between macOS, linux/unix, and freeBSD.
Won’t you have to compile for different systems anyway, so you wouldn’t need to do this at runtime?
I don’t think there’s anything intrinsically like Golang’s sys module, just a barebones ::System, which could probably do with a bit of love. Perhaps look for a known paradigm for the OS, eg. /proc
, /Library
? Doesn’t seem as clean as one might want though.
On POSIX systems you can usually take a look at /proc/version
or uname
to determine the operating system.
@absolutejam_gh In theory you’re correct that binaries are compiled for a specific target platform. But many operating systems also offer compatibility layers. You can pretty successfully run most Linux binaries on FreeBSD, for example.
You’re generally right - I’m rewriting crystal-build though, so I’d like to be able to provide some binaries for commonly used machines, to avoid the “ crystal requires crystal” issue.
Compiling from source will be the “right” way to do it though.
Looks suitable enough. Thanks!