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

native.existing_rule fails to parse rule names beginning with `:` #1195

Open
trainman419 opened this issue Apr 25, 2016 · 0 comments
Open

native.existing_rule fails to parse rule names beginning with `:` #1195

trainman419 opened this issue Apr 25, 2016 · 0 comments

Comments

@trainman419
Copy link

@trainman419 trainman419 commented Apr 25, 2016

I'm building a macro which can take many types of things as arguments; both existing rules and raw source files.

By convention, as described in the Labels section of the manual, rules should be passed with the leading colon, so when calling my macro and passing a filegroup, I pass srcs = ":my_srcgroup".

When I try to determine if this is an existing rule or a file in my macro, I do:

for src in srcs:
  if native.existing_rule(src)
    # some things for filegroups
  else:
    # other things for file names

Unfortunately, native.existing_rule does not understand the leading-colon syntax for rules, and therefore always returns false for any rule name starting with a :

I have a workaround but it's ugly:

for src in srcs:
  rule_name = src
  if rule_name.startswith(':'):
    rule_name = rule_name[1:]
  rule = native.existing_rule(rule_name)
  print(src, rule)
  if rule:
    # some things for filegroups
  else:
    # other things for file names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.