--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/1c829ba8-5655-4090-bd09-60e59e86b3b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
The reason that directory inputs are unsound in bazel is that bazel won't notice changes in those directories (that's what the purpose of glob() is). Specifically, verifying that a zip file was output from the genrule is easy: the genrule will either create it or not. Bazel can't verify the directory because it doesn't know what should be in there. The underlying idea at work here is that bazel wants to know the exact inputs and outputs of each action, and if the action (i.e. the genrule) outputs a directory, bazel can't know if the action generated what it should have, and furthermore can't know if downstream actions will get what they need if they take in a directory.
Verifying that a directory was output from the genrule is easy: the genrule will either create it or not. Bazel can't verify a zip file because it doesn't know what should be in there. The underlying idea at work here is that bazel wants to know the exact inputs and outputs of each action, and if the action (i.e. the genrule) outputs a zip file, bazel can't know if the action generated what it should have, and furthermore can't know if downstream actions will get what they need if they take in a zip file.
For the record, I'm building Node.js modules.node scripts look in the current working directory for a "node_modules" folder, which contains a tree of javascript files (and other data files).It's not uncommon for node_modules folders to get pretty big; tens of thousands or even hundreds of thousands of loose files.For a reasonably quick example, you could "brew install node", make a temp directory and "npm install babel-core". You'll then have a node_modules folder containing roughly 4,000 files. Our runtime directory has tens of thousands of files.It is absolutely possible to tar those files up (without compressing/decompressing them). But then, each time I want to run my script, I'd have to untar 40,000 files. It's inherently slow to write that many files at launch. It would be much faster to just symlink to the directory where the files were already generated.
On Tuesday, March 8, 2016 at 2:33:15 PM UTC-8, Alex Humesky wrote:The reason that directory inputs are unsound in bazel is that bazel won't notice changes in those directories (that's what the purpose of glob() is). Specifically, verifying that a zip file was output from the genrule is easy: the genrule will either create it or not. Bazel can't verify the directory because it doesn't know what should be in there. The underlying idea at work here is that bazel wants to know the exact inputs and outputs of each action, and if the action (i.e. the genrule) outputs a directory, bazel can't know if the action generated what it should have, and furthermore can't know if downstream actions will get what they need if they take in a directory.With all due respect, I disagree with this paragraph strongly, and so should you.
$ tree . ├── BUILD ├── in │ ├── a │ └── b └── WORKSPACE$ cat BUILD genrule( name = "gen", srcs = ["in"], outs = ["out.txt"], cmd = "cat in/a >> $@; cat in/b >> $@")$ cat in/a input a $ cat in/b input b
$ bazel build :out.txt INFO: Found 1 target... WARNING: /tmp/test/BUILD:1:1: input 'in' to //:gen is a directory; dependency checking of directories is unsound. Target //:out.txt up-to-date: bazel-genfiles/out.txt INFO: Elapsed time: 1.879s, Critical Path: 0.08s
$ cat bazel-genfiles/out.txt input a input b
Zip files are just compressed directories. Everything you say you "can't know" about a directory, you can't know about a zip file either, and everything you can know about a zip file, you can know about a directory, too: you can know that they exist, but you can't verify correctness, because you don't know what the contents should be. You can checksum a zip, and you can checksum a directory.
Your can literally rewrite your paragraph in the reverse and it's equally true:Verifying that a directory was output from the genrule is easy: the genrule will either create it or not. Bazel can't verify a zip file because it doesn't know what should be in there. The underlying idea at work here is that bazel wants to know the exact inputs and outputs of each action, and if the action (i.e. the genrule) outputs a zip file, bazel can't know if the action generated what it should have, and furthermore can't know if downstream actions will get what they need if they take in a zip file.
genrule( name = "gen", outs = ["out"], cmd = "mkdir out; echo 'hello a' > out/a; echo 'hello b' > out/b")
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/41d1eb68-e122-4b02-a850-5427627d1ee3%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/bfc9b8b3-42d9-41fc-baa7-d59a0e13481d%40googlegroups.com.