Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loop variable does not propagate to (implicit) rule body #103

Open
cspiel opened this issue Apr 16, 2018 · 0 comments
Open

Loop variable does not propagate to (implicit) rule body #103

cspiel opened this issue Apr 16, 2018 · 0 comments

Comments

@cspiel
Copy link
Collaborator

cspiel commented Apr 16, 2018

Consider the following OMakefile:

extensions[] =
        .a
        .b
        .c

foreach(ext => ..., $(extensions))
        x = $(ext)
        %.q: %$(ext)
                echo $"ext = $(ext), x = $x" # Comment out this line and the error disappears.
                cp $< $@
        export .RULE

It defines a set of implicit rules for %.q targets. Call it for example with

touch foo.b;  rm -f foo.q;  omake foo.q

omake raises the error

unbound variable: public.ext

A simple workaround is shown in the example. If we capture the loop
variable ext inside the foreach-loop, but outside of the (implicit) rule
in variable x, we can use x inside the rule body without an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant