In Starlark, how do I generate a file that has associated runfiles?Recommended strategy to accumulate data in bazel aspects output filesBazel test rule for the Python BDD tool “behave”How to deal with implicit dependency (e.g C++ include) for incremental build in custom Skylark ruleHow to run test on the source tree in bazel?How to use Bazel with Node.jsHow do I make a bazel `sh_binary` target depend on other binary targets?bazel c++ create and link with shared libraryhow to build cc_test for android using bazelHow to get the bazel dependencies of Tensorflow by bazel query?
Is this homebrew "Faerie Fire Grenade" unbalanced?
Should a TA point out a professor's mistake while attending their lecture?
Break down the phrase "shitsurei shinakereba naranaindesu"
Ask one verbal question to figure out who is blind and who is mute among three persons
My colleague treats me like he's my boss, yet we're on the same level
How to animate a function plot
Is it good practice to speed up and slow down where not written in a song?
Why do presidential pardons exist in a country having a clear separation of powers?
Why are JWST optics not enclosed like HST?
math mode in ticks ( tikzpicture )
Create a list of snaking numbers under 50,000
Which language is the closest lexically to Spanish?
Eliminate key lookup in execution plan
Group riding etiquette
Sum and average calculator
What are ways to record who took the pictures if a camera is used by multiple people?
What was Captain Marvel supposed to do once she reached her destination?
Why does Sauron not permit his followers to use his name?
Can inductive kick be discharged without freewheeling diode, in this example?
Is the word 'mistake' a concrete or abstract noun?
What should be done with the carbon when using magic to get oxygen from carbon dioxide?
How do I get my neighbour to stop disturbing with loud music?
Resources to learn about firearms?
I was reported to HR as being a satan worshiper
In Starlark, how do I generate a file that has associated runfiles?
Recommended strategy to accumulate data in bazel aspects output filesBazel test rule for the Python BDD tool “behave”How to deal with implicit dependency (e.g C++ include) for incremental build in custom Skylark ruleHow to run test on the source tree in bazel?How to use Bazel with Node.jsHow do I make a bazel `sh_binary` target depend on other binary targets?bazel c++ create and link with shared libraryhow to build cc_test for android using bazelHow to get the bazel dependencies of Tensorflow by bazel query?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
In a Starlark file that's being used in Bazel, if I create a file with ctx.actions.declare_file()
, is there some way to associate dependencies/datafiles/runfiles with it? For example:
I can create and write to a file:
script_file = ctx.actions.declare_file("myscript.sh")
ctx.actions.write(
script_file,
"echo hello from myscript.shn",
is_executable = True
)
... and then I can use script_file
any way I want. E.g. in ctx.actions.run
or ctx.actions.run_shell
.
Now suppose myscript.sh
depends on data.txt
:
data_file = ctx.actions.declare_file("data.txt")
ctx.actions.write(data_file, "hello from data.txtn")
script_file = ctx.actions.declare_file("myscript.sh")
ctx.actions.write(
script_file,
"cat n".format(data_file.path),
is_executable = True
)
And then I can run it (in this example, the rule that called this has an output named "main"):
ctx.actions.run_shell(
tools = [script_file, data_file],
outputs = [ctx.outputs.main],
command = " > ".format(script_file.path, ctx.outputs.main.path)
)
Okay. But really it's messy to have to specify both script_file
and data_file
in the tools
array. I would like to specify just script_file
, and have the data_file
be automatically picked up as a runfile of script_file
.
Is there a way to that? If so, how? If not, is there some other, better way for me to be approaching this?
bazel starlark
add a comment |
In a Starlark file that's being used in Bazel, if I create a file with ctx.actions.declare_file()
, is there some way to associate dependencies/datafiles/runfiles with it? For example:
I can create and write to a file:
script_file = ctx.actions.declare_file("myscript.sh")
ctx.actions.write(
script_file,
"echo hello from myscript.shn",
is_executable = True
)
... and then I can use script_file
any way I want. E.g. in ctx.actions.run
or ctx.actions.run_shell
.
Now suppose myscript.sh
depends on data.txt
:
data_file = ctx.actions.declare_file("data.txt")
ctx.actions.write(data_file, "hello from data.txtn")
script_file = ctx.actions.declare_file("myscript.sh")
ctx.actions.write(
script_file,
"cat n".format(data_file.path),
is_executable = True
)
And then I can run it (in this example, the rule that called this has an output named "main"):
ctx.actions.run_shell(
tools = [script_file, data_file],
outputs = [ctx.outputs.main],
command = " > ".format(script_file.path, ctx.outputs.main.path)
)
Okay. But really it's messy to have to specify both script_file
and data_file
in the tools
array. I would like to specify just script_file
, and have the data_file
be automatically picked up as a runfile of script_file
.
Is there a way to that? If so, how? If not, is there some other, better way for me to be approaching this?
bazel starlark
I found this, which looks related to what I'm trying to do, and if I'm reading this correctly, it implies that what I'm trying to do cannot yet be done: github.com/bazelbuild/bazel/issues/7187
– Mike Morearty
Mar 28 at 0:37
add a comment |
In a Starlark file that's being used in Bazel, if I create a file with ctx.actions.declare_file()
, is there some way to associate dependencies/datafiles/runfiles with it? For example:
I can create and write to a file:
script_file = ctx.actions.declare_file("myscript.sh")
ctx.actions.write(
script_file,
"echo hello from myscript.shn",
is_executable = True
)
... and then I can use script_file
any way I want. E.g. in ctx.actions.run
or ctx.actions.run_shell
.
Now suppose myscript.sh
depends on data.txt
:
data_file = ctx.actions.declare_file("data.txt")
ctx.actions.write(data_file, "hello from data.txtn")
script_file = ctx.actions.declare_file("myscript.sh")
ctx.actions.write(
script_file,
"cat n".format(data_file.path),
is_executable = True
)
And then I can run it (in this example, the rule that called this has an output named "main"):
ctx.actions.run_shell(
tools = [script_file, data_file],
outputs = [ctx.outputs.main],
command = " > ".format(script_file.path, ctx.outputs.main.path)
)
Okay. But really it's messy to have to specify both script_file
and data_file
in the tools
array. I would like to specify just script_file
, and have the data_file
be automatically picked up as a runfile of script_file
.
Is there a way to that? If so, how? If not, is there some other, better way for me to be approaching this?
bazel starlark
In a Starlark file that's being used in Bazel, if I create a file with ctx.actions.declare_file()
, is there some way to associate dependencies/datafiles/runfiles with it? For example:
I can create and write to a file:
script_file = ctx.actions.declare_file("myscript.sh")
ctx.actions.write(
script_file,
"echo hello from myscript.shn",
is_executable = True
)
... and then I can use script_file
any way I want. E.g. in ctx.actions.run
or ctx.actions.run_shell
.
Now suppose myscript.sh
depends on data.txt
:
data_file = ctx.actions.declare_file("data.txt")
ctx.actions.write(data_file, "hello from data.txtn")
script_file = ctx.actions.declare_file("myscript.sh")
ctx.actions.write(
script_file,
"cat n".format(data_file.path),
is_executable = True
)
And then I can run it (in this example, the rule that called this has an output named "main"):
ctx.actions.run_shell(
tools = [script_file, data_file],
outputs = [ctx.outputs.main],
command = " > ".format(script_file.path, ctx.outputs.main.path)
)
Okay. But really it's messy to have to specify both script_file
and data_file
in the tools
array. I would like to specify just script_file
, and have the data_file
be automatically picked up as a runfile of script_file
.
Is there a way to that? If so, how? If not, is there some other, better way for me to be approaching this?
bazel starlark
bazel starlark
edited Mar 27 at 23:17
Mike Morearty
asked Mar 27 at 23:12
Mike MoreartyMike Morearty
7,5924 gold badges27 silver badges33 bronze badges
7,5924 gold badges27 silver badges33 bronze badges
I found this, which looks related to what I'm trying to do, and if I'm reading this correctly, it implies that what I'm trying to do cannot yet be done: github.com/bazelbuild/bazel/issues/7187
– Mike Morearty
Mar 28 at 0:37
add a comment |
I found this, which looks related to what I'm trying to do, and if I'm reading this correctly, it implies that what I'm trying to do cannot yet be done: github.com/bazelbuild/bazel/issues/7187
– Mike Morearty
Mar 28 at 0:37
I found this, which looks related to what I'm trying to do, and if I'm reading this correctly, it implies that what I'm trying to do cannot yet be done: github.com/bazelbuild/bazel/issues/7187
– Mike Morearty
Mar 28 at 0:37
I found this, which looks related to what I'm trying to do, and if I'm reading this correctly, it implies that what I'm trying to do cannot yet be done: github.com/bazelbuild/bazel/issues/7187
– Mike Morearty
Mar 28 at 0:37
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55387878%2fin-starlark-how-do-i-generate-a-file-that-has-associated-runfiles%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55387878%2fin-starlark-how-do-i-generate-a-file-that-has-associated-runfiles%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I found this, which looks related to what I'm trying to do, and if I'm reading this correctly, it implies that what I'm trying to do cannot yet be done: github.com/bazelbuild/bazel/issues/7187
– Mike Morearty
Mar 28 at 0:37