Call an external program from CTFE
monkyyy
crazymonkyyy at gmail.com
Sun Jun 23 16:46:05 UTC 2024
On Sunday, 23 June 2024 at 16:33:54 UTC, realhet wrote:
> Hi,
>
> Is there a way to call an external program from CTFE?
>
>
> Use case:
> Inside a module I want to put some GLSL code.
> I also want to generate that GLSL code using CTFE.
> And when it's done, it would be nice if I was able to save that
> GLSL code into a temp file and call the glsl compiler on it.
> The goal is that the compiled version of the module would
> contain also the compiled version of that GLSL shader.
> And the time of the GLSL compilation could be the exact same
> time of the EXE compilation.
>
> This sounds a bit of hacking, but from viewing from a
> multi-target build perspective, it can make sense. Calling a
> compiler from another compiler... Why not? :D
>
> The nearest thing I've found is the "include file contents"
> 'macro', that can be enabled with a command line parameter.
> (Maybe it's already deprecated, I'm not sure.)
>
>
> My other way to do this would be an automation inside my IDE.
> But if something could be done on the language level it's
> always better than doing it by using external tools.
ctfe is intentionally hobbled "for safety"; while theres bugs and
edge cases I dont think anyone has a sane way to escape to full
execution
realistically you should just write a build script with two stages
fun thought experiment time, if you found a programmable
"FUSE"(file system api) database of some sort, mixed `-J` and
`-mixin`, I think you may be able to call a compiler
More information about the Digitalmars-d-learn
mailing list