nim-lang / RFCs

A repository for your Nim proposals.
136 stars 23 forks source link

[feature request] add pragmas to specify/override nim flags directly in source code #136

Closed slomp closed 5 years ago

slomp commented 5 years ago

Since nim uses an unified build strategy (through imports and such), a feature that could be very handy to make the main source module more self-contained would be the ability to specify nim compiler flags directly in code, through some sort of pragma, e.g.:

{.nim: "cpp --noMain nimcache=...".}

It would be very handy to also be able to introspect these compiler flags in code, as compiler consts accessible by when directives.

Araq commented 5 years ago

That's way harder than it looks. ;-) We need to know about these switches when compiling system.nim, for example. Why not put a NimScript config file next to your project file instead. That works with today's Nim.

slomp commented 5 years ago

Ah, indeed, I did not think about system.nim...

Cool, I did not know I could just add --noMain to nim.cfg!

Looks like most nim compiler flags can be specified in the nim.cfg file. Things compileToC et al. can't; is there any piece of documentation stating which compiler toggles can and cannot be specified in a nim.cfg file?

slomp commented 5 years ago

@Araq Should I close this issue, or is this something worth keeping around for future discussion?

Araq commented 5 years ago

Well switches with -- can, the others are "commands" (c/cc/js/doc) and can't.

Araq commented 5 years ago

Should I close this issue, or is this something worth keeping around for future discussion?

We need to focus. Sorry.