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

Make $(location) work for top-level executables #966

Closed
jmmv opened this issue Feb 23, 2016 · 2 comments
Closed

Make $(location) work for top-level executables #966

jmmv opened this issue Feb 23, 2016 · 2 comments

Comments

@jmmv
Copy link
Contributor

jmmv commented Feb 23, 2016

Consider the following workspace:

cat >WORKSPACE <<EOF
workspace(name = 'test')
EOF

cat >BUILD <<EOF
genrule(
    name = 'the_test',
    cmd = "$(location :hello.sh) >$@",
    outs = ['test_output'],
    tools = [":hello.sh"],
)
EOF

cat >hello.sh <<EOF
#! /bin/sh
echo Hello
EOF
chmod +x hello.sh

Given the above, the_test is unbuildable because the execution of hello.sh fails. The problem is that $(location :hello.sh) expands to simply hello.sh which cannot be resolved given a sane PATH (where a "sane path" means a set of directories that does not include the current directory for security reasons; see #958).

A possible fix would be to prefix all relative paths emitted by $(location) with ./. A worse fix (because it wouldn't be consistent in all cases) would be to do so only for outputs composed of a single path component. I don't know what the implications of doing any of these two would be.

@bsilver8192
Copy link
Contributor

Sounds like a duplicate of #347.

@jmmv
Copy link
Contributor Author

jmmv commented Feb 23, 2016

Indeed. Closing as such. I forgot to search for duplicates before filing this particular report.

@jmmv jmmv added the duplicate label Feb 23, 2016
@jmmv jmmv closed this as completed Feb 23, 2016
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

2 participants