meson-plus-plus
meson-plus-plus copied to clipboard
Handle `subdir(if_found : ...)`
I'd like to handle all subdir() invocations in the frontend, and have a complete tree for the MIR level, I think the best thing to do is have a pass that converts
subdir('foo', if_found : foo_dep)
into
if foo_dep.found()
subdir('foo')
endif
This means we can have the full tree available, and use dead code elimination to get rid of it if we don't need it.
for arrays this is more complicated, as meson doesn't have an all(), I could, however have an all() implementation in my AST level code, and have HIR deal with that, or I could reduce it to something like:
use = true
foreach d : foo_deps
if not d.found()
use = false
break
endif
endforeach
if use
subdir('foo')
endif
Which is advantageous because the subdir() can be lowered away in the AST leve, but the if use would be resolved in the MIR level.