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

not possible to declare_file to genfiles_dir #4858

Closed
ahippler opened this issue Mar 15, 2018 · 9 comments
Closed

not possible to declare_file to genfiles_dir #4858

ahippler opened this issue Mar 15, 2018 · 9 comments
Assignees
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) type: feature request

Comments

@ahippler
Copy link
Contributor

Description of the problem / feature request:

since ctx.new_file() is deprecated ctx.actions.declare_file() should be a replacement.
with ctx.new_file() it was possible to generate files to genfiles_dir which I tried with ctx.actions.declare_file()

out = ctx.actions.declare_file(ctx.attr.out, sibling=ctx.genfiles_dir)

produces

Cannot convert parameter 'sibling' to type File or NoneType, in method declare_file(string, root sibling) of 'actions'

Feature requests: what underlying problem are you trying to solve with this feature?

it must be possible to use a root dir (ctx.bin_dir and ctx.genfiles_dir) as sibling
or as different parameter e.g. root.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

rule.bzl:

def _impl(ctx):
    o = ctx.actions.declare_file('x.sh', sibling=ctx.bin_dir)
    ctx.actions.write(o, 'echo Stuff', is_executable = True)
    return [DefaultInfo(executable = o)]

my_rule = rule(_impl, executable = True)

BUILD:

load(':rule.bzl', 'my_rule')
my_rule(name = 'xxx')

bazel build xxx

What operating system are you running Bazel on?

macOS 10.12.6

What's the output of bazel info release?

release 0.11.1-homebrew

@ahippler
Copy link
Contributor Author

I would suggest declare_directory has the same issue

@buchgr
Copy link
Contributor

buchgr commented Mar 16, 2018

cc @laurentlb

@laurentlb
Copy link
Contributor

Long-term plan is to get rid of the root and the distinction between bin_dir and genfiles_dir (cc @lberki).

We might add the feature for now, but it should be clear it will go away.

@lberki
Copy link
Contributor

lberki commented Mar 21, 2018

We can add that knob, but instead, can you get by by putting that file under bazel-bin instead?

@laurentlb
Copy link
Contributor

Maybe try to build your code with --noexperimental_separate_genfiles_directory? This way, this will merge the bin and the genfiles directories. It hasn't been much tested yet, but I hope it can make things simpler.

@ahippler
Copy link
Contributor Author

I didn't know the plan to remove the genfiles directory. Wich version will remove the separation and did you report this anywhere?

@laurentlb
Copy link
Contributor

It's unclear at the moment how we'll proceed. The separation is not useful and it adds complexity. I would be very happy if we could remove it. It's still here for legacy reasons, so we need to investigate and see how much work there is to do before we can switch the default.

@laurentlb laurentlb added type: feature request P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Starlark and removed category: extensibility > skylark labels Nov 21, 2018
schroederc added a commit to schroederc/kythe that referenced this issue Mar 6, 2019
This moves the generated files to the bin directory due to
bazelbuild/bazel#4858.
schroederc added a commit to kythe/kythe that referenced this issue Mar 6, 2019
This moves the generated files to the bin directory due to
bazelbuild/bazel#4858.
@limdor
Copy link
Contributor

limdor commented Apr 2, 2019

@laurentlb a ticket to be able to follow regarding this long term plan would be very beneficial. For me it was also a little bit hard to find in this ticket that this is the long term plan

@laurentlb
Copy link
Contributor

The genfiles directory will be removed in Bazel 0.25. See #6761

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) type: feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants