Comments (7)
I just pushed a new (undocumented) rule named sh_binary() to the repo:
It behaves a little differently from genrule()
, so I'm curious to get your thoughts.
Basically, within the script that you specify as the main
argument to sh_binary()
, you can assume the existence of the environment variable $BUCK_PROJECT_ROOT
. That is the root of the directory that should contain all of the resources you passed to sh_binary()
. (It's a read-only symlink to the actual file.) This directory should be a unified view of buck-out/gen/
and your main tree, filtered by the resources you declared in sh_binary()
.
(Though as I type this, as things are currently implemented for generated files, I think you would have $BUCK_PROJECT_ROOT/buck-out/gen/foo/bar.txt
instead of $BUCK_PROJECT_ROOT/foo/bar.txt
, which is a bug.)
Given this approach for sh_binary()
, do you think we should do something similar for genrule()
? We currently have $SRCDIR
, but that [roughly] refers to the directory that contains the build file rather than the root of the repo.
from buck.
I expected genrule() to have $SRCDIR setup as a tree of symlinks to the named srcs, with the path prefix of the BUCK file containing the genrule() stripped off. i.e. the current behavior of genrule(). Which doesn't always work thanks to some bugs in the way canonical vs. absolute paths vs. "." as the project root are handled, but that is issue #39.
For a genfile() used as src for a genrule() I expect the same thing. If this BUCK file says genfile("foo/bar.txt") then my genrule should see $SRCDIR/foo/bar.txt. I shouldn't need to write a sh_binary() to be invoked from a genrule() to get there.
But this is fairly hideous either way. What I am really trying to do is generate an XML file in a genrule() and then package that into a JAR that I can pass through to another java_library() as a dep. I do that right now by just feeding the genfile(...) path as part of the resources list of a java_library() and carry on. Looks like 2aa814b broke this, so I need to rewrite the rule. If I have to fall down to a sh_binary() I might as well just replace the java_library() rule with an additional step in my genrule() to produce a JAR output instead of an XML file as output.
So then my example becomes:
genrule(
name = 'gen',
cmd = 'mkdir -p $TMP/com/example/;' +
'echo foo>$TMP/com/example/foo.properties;' +
'cd $TMP; zip -qr $OUT .',
deps = [],
out = 'foo.jar',
)
prebuilt_jar(
name = 'lib',
binary_jar = genfile('foo.jar'),
deps = [':gen'],
)
we already have a few such rules in our tree. I guess I should convert this java_library() rule to this form instead?
from buck.
Short answer: no decision has been made, so don't go rewriting all of your
gen rules just yet! Use .buckversion to stay at a point that doesn't have
the regression for now (though I realize that may not allow you to get the
recent python speed wins).
On Jul 24, 2013 9:29 PM, "Shawn O. Pearce" [email protected] wrote:
I expected genrule() to have $SRCDIR setup as a tree of symlinks to the
named srcs, with the path prefix of the BUCK file containing the genrule()
stripped off. i.e. the current behavior of genrule(). Which doesn't always
work thanks to some bugs in the way canonical vs. absolute paths vs. "." as
the project root are handled, but that is issue #39#39
.For a genfile() used as src for a genrule() I expect the same thing. If
this BUCK file says genfile("foo/bar.txt") then my genrule should see
$SRCDIR/foo/bar.txt. I shouldn't need to write a sh_binary() to be invoked
from a genrule() to get there.But this is fairly hideous either way. What I am really trying to do is
generate an XML file in a genrule() and then package that into a JAR that I
can pass through to another java_library() as a dep. I do that right now by
just feeding the genfile(...) path as part of the resources list of a
java_library() and carry on. Looks like 2aa814bhttps://github.com/facebook/buck/commit/2aa814be5a646e5cd8c0480bb68e20007b5df4e7broke this, so I need to rewrite the rule. If I have to fall down to a
sh_binary() I might as well just replace the java_library() rule with an
additional step in my genrule() to produce a JAR output instead of an XML
file as output.So then my example becomes:
genrule(
name = 'gen',
cmd = 'mkdir -p $TMP/com/example/;' +
'echo foo>$TMP/com/example/foo.properties;' +
'cd $TMP; zip -qr $OUT .',
deps = [],
out = 'foo.jar',
)
prebuilt_jar(
name = 'lib',
binary_jar = genfile('foo.jar'),
deps = [':gen'],
)we already have a few such rules in our tree. I guess I should convert
this java_library() rule to this form instead?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/41#issuecomment-21529831
.
from buck.
Gerrit already requires a patched version of buck that is 4 commits ahead of your tree. I just keep rebasing and fixing the same damn merge conflicts. Now we have 5 commits ahead, the latest one replaces "." as the top of the source tree with the absolute path because "." as the project root late becomes "/./" in some path strings and buck isn't fully prepared for this. sigh
The java_library() not accepting a genfile() in a package name is now patched around by having the genrule() spit out a JAR by running jar itself. sigh
Despite things like this, buck is still better than Maven.
from buck.
"still better than Maven" is our motto
On Jul 26, 2013 12:27 AM, "Shawn O. Pearce" [email protected]
wrote:
Gerrit already requires a patched version of buck that is 4 commits ahead
of your tree. I just keep rebasing and fixing the same damn merge
conflicts. Now we have 5 commits ahead, the latest one replaces "." as the
top of the source tree with the absolute path because "." as the project
root late becomes "/./" in some path strings and buck isn't fully prepared
for this. sighThe java_library() not accepting a genfile() in a package name is now
patched around by having the genrule() spit out a JAR by running jar
itself. sighDespite things like this, buck is still better than Maven.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/41#issuecomment-21602181
.
from buck.
Is this still an issue for you @spearce?
from buck.
genfile
doesn't even exist anymore.
from buck.
Related Issues (20)
- Python 3.10: third-party python modules need update (setuptools: No module named 'symbol', pex: cannot import name 'iterable' from 'collections') HOT 10
- How to Change Xcode xxx.pbxproj resource-id prefix ?
- got OSError: [Errno 45] Operation not supported when run "buck build demo_app_ios" command
- Trying to generate multiple targets with buck project --combined-project, expecting one project, got many
- GCC Toolchain Path Incorrect Post R22 NDK HOT 4
- Invite to slack channel
- How to avoid or allow apple security in M1?
- How do I join slack?
- Jitpack failure
- zip64 self executing jar issue
- Accessing files across directories
- Cannot run a build, failed to initialize buck (sqlite-jdbc) HOT 2
- Unable to build buck. Java class file version error. HOT 3
- Windows,When building rule //src/com/facebook/buck/jvm/java/abi/kotlin:kotlin.
- [Question] Isolation level between test targets within the same project. HOT 1
- Unable to create abi jar
- buck fetch fails with symbolic links in an archive HOT 1
- State of the Project? HOT 2
- Buck fails to link, linkage order seems to be wrong in linker.argsfile HOT 1
- How can we build instant app using buck
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from buck.