zetzit / zz

πŸΊπŸ™ ZetZ a zymbolic verifier and tranzpiler to bare metal C
MIT License
1.6k stars 52 forks source link

introducing compiler flags as language item #97

Closed aep closed 4 years ago

aep commented 4 years ago

use like this:

flags {
    linker("-lbla")
}

works with conditionals:

flags if #(os::_WIN32){
    linker("-lW32_bla")
}

eventually macro support will allow generating these from configure tests, something like:

flags {
  @pkgconfig("gtk")
}

in order to integrate into C conditionals they are emitted as pragma. but there's really only msvc that supports linker pragmas, so make also parses them back out of the c file and appends them to the compiler commandline.

this means export to other build systems becomes slightly inconsistent, but it would have been that way anyway, because every build system works differently.

jwerle commented 4 years ago

This looks great! Is it possible to add a test? re: variants/features - I never had a chance to look at it, what was the point of it?

aep commented 4 years ago

not sure how to add a test, because that would have to link something. async will use this, so i think its fine.

features where a direct copy of rust features. each module can define something like "with_gtk" and use that as conditional like if (with_gtk) { init_gtk.} but since those are resolved at parsetime, you would end up emitting non portable c code. what we do now is much better, since it delays the conditional choice to the c compiler. the exported C code now works for all variants.

jwerle commented 4 years ago

Good point and amazing!