https://pantsbuild.org/ logo
#general
Title
# general
s

some-farmer-97614

01/11/2019, 10:02 PM
Is there something like bazels genrule in pantsbuild?
a

aloof-angle-91616

01/11/2019, 10:08 PM
the caching process execution framework in the v2 engine can consume input files and produce output files in a structured way, which seems similar to the docs on
genrule
-- see an example for
cloc
, a script which counts lines of code using heuristics and regex: https://github.com/pantsbuild/pants/blob/f30c612f7b9c70e0b1f4cf234d8c9155a8b27508/src/python/pants/backend/graph_info/tasks/cloc.py#L77. we are currently rewriting the python support in v2 (along with many other things) so this functionality works, but the interface from v2 rules to the CLI is still being hashed out -- see the very very very very in-progress diff at https://github.com/pantsbuild/pants/pull/6880. what use case are you thinking of?
s

some-farmer-97614

01/11/2019, 10:18 PM
Thanks for the detailed answer. I’m just getting to know this brand of build system and gauging the differences and how much I’ll be constrained to what’s provided, are there easy extension points, etc.
I’m finding it a bit hard to answer the question: What do I do when my code generation tool / language, etc. isn’t supported? Or could I e.g. process a bunch of images as part of the build etc.
a

aloof-angle-91616

01/11/2019, 10:23 PM
pants has the best extension model of any build tool by far (imo). one of the reasons this has come to be the case is that one of the larger corporate contributors (twitter) doesn't consume any internal version, and always relies on making open source releases, as well as using the extension model to satisfy internal use cases (imo). in the v1 model (which is fully supported), the task development guide is here: https://www.pantsbuild.org/dev_tasks.html (also see https://www.pantsbuild.org/dev.html). the v2 engine API is described here: https://github.com/pantsbuild/pants/blob/master/src/python/pants/engine/README.md, but as mentioned, that is exciting and new and still being hashed out unless you like getting used to really new code.
the general idea is that you can make a directory (by convention,
pants-plugins/
) in your repo which defines pants tasks, subsystems, targets, etc, and register it in your repo's
pants.ini
file. you can then invoke your tasks as first-class citizens just like built-in pants tasks such as jvm and scala compilation tasks.
to answer the original question, there's not an idea specifically akin to
genrule
in the v1 model, but tasks can invoke subprocesses and rely on some automatic caching of output directories, described in the task development docs above.
s

some-farmer-97614

01/11/2019, 10:28 PM
Sounds cool, I’ll give this a try. One reason I’ve been drawn to check out pants first is that I had a very good experience of using twitter finagle. Another that the new engine has been written in Rust 😉
a

aloof-angle-91616

01/11/2019, 10:31 PM
we're going to have first-class rust support sooner than everyone else thinks if i get my act together and i'm planning to make it easier to use pants with twitter open source jvm projects (which is why i joined this company) in a great way soon enough if i get my act together. pants has a lot of features and architectures that no other build tool has and i am attempting to win the title of being its biggest fan.
please feel free to make an issue if you find a bug or missing feature or ping this channel!
3 Views