Replies: 2 comments
-
|
I think looking at Actually, here's a pretty basic example: ...and here's a basically-equivalent Brioche recipe today: std.runBash`
echo foo > foo.txt
`
.currentDir(std.outputPath)
.outputScaffold(std.directory())
.toDirectory()
.pipe((recipe) => {
std.runBash`
echo bar > bar.txt
`
.currentDir(std.outputPath)
.outputScaffold(recipe)
.toDirectory()
})This isn't so much to say we should emulate Docker's model, but it shows that they're basically on the opposite end of the spectrum from how we do things. Along the same lines, Earthly Earthfiles are a sort of evolved form of Dockerfiles. I've really only skimmed the basics of Earhtly, so there might be some interesting ideas to learn from there! |
Beta Was this translation helpful? Give feedback.
-
100% agree with that, we should better support chaining recipes and processes. I kind of like what we did here and here. It would be good if we could expand this pattern.
Based on the idea of adding a mkdir method ( The main issue with adding these commands and chaining things is to enforce proper ordering during the execution of the commands. Basically to take an example, when calling cd(source)
.mkdir(std.tpl'${outputPath}/bin')
.runBash({ script: `
gcc hello.c -o "$BRIOCHE_OUTPUT/bin/hello"
`, dependencies: std.toolchain })If I follow my idea that the order is important, since each method will setup the environment step by step, I moved cd(source)
.mkdir(std.tpl'${outputPath}/bin')
.scope(dependencies: [std.toolchain], (recipe) => {
std.runBash`
gcc hello.c -o "$BRIOCHE_OUTPUT/bin/hello"
`
}) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This concept came up during a PR review recently
We basically have 2 different ways to run a single command as a build step today:
(1) Using
std.runBashto run a shell script from a string (orrunNushell, etc.)(2) Using
std.processto make a process recipe "manually"I think both utilities are okay, but I think we can do better. A few thoughts:
std.processis a more direct building block. We just run whatever process we're given without a shell in the way. No need to worry about escaping inputs, since we don't do shell expansionstd.runBashI think (hope!) is more intuitive for a beginner. It looks pretty close to how you'd compile a C project "by hand" (hoepfully, it'd be pretty easy to copy/paste existing shell commands and convert them to a Brioche build without much effort)std.processdoesn't requirebashduring the build, which could help eliminate un-needed dependencies... in theory, at least!std.processcan only run a single process! If you need multiple processes within the same recipe / sandbox, you'll need another tool: a shell (or something else to run multiple commands in sequence)outputScaffoldlooks kinda ugly / complicated.pipe(...)on it to use it as theoutputScaffoldfor the next step.One idea I had thrown out (in the PR review mentioned before) would be a utility to that abstracts over
.outputScaffold(), and @jaudiger suggested that we could even generalize it further and let it take an arbitrary path. Something like.mkdir(std.tpl'${outputPath}/bin')to create an output path, or.mkdir(std.tpl'${workDir}/build')to create a path in the work dir.Taking this idea to the extreme, I think it'd be cool if we had a more composable way to run commands. Ideally, we could:
mkdir/cdcommands to.outputScaffold()/.workDir()/.currentDir()is a bit annoying today.Beta Was this translation helpful? Give feedback.
All reactions