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

polite-vase-75369

03/19/2019, 5:47 PM
i guess my question is what's the right way to have a GEN task happen before your build or compiles?
all v1 tasks have "product dependencies" that enforce an ordering
but tasks are additionally installed in goals
you can look at
./pants --explain $somegoal
to see what order things will be run in
p

polite-vase-75369

03/19/2019, 6:39 PM
hmmm cool thanks
if my gen task generates some code
that goes into .pants.d/gen/blah, how do i copy that somewhere in my compile task?
in this example from two separate plugins
w

witty-crayon-22786

03/19/2019, 6:44 PM
the node tasks would consume a product
and your task would provide that product, in the format it was expecting
p

polite-vase-75369

03/19/2019, 6:45 PM
are there any examples of this i could look at?
w

witty-crayon-22786

03/19/2019, 6:45 PM
the page i linked to has one
(it's inlined directly from real tasks in the pants codebase)
but... actually, codegen is a different situation.
@polite-vase-75369: codegen tasks "create targets"
p

polite-vase-75369

03/19/2019, 6:49 PM
hmmm
w

witty-crayon-22786

03/19/2019, 6:49 PM
are you extending SimpleCodegenTask?
p

polite-vase-75369

03/19/2019, 6:49 PM
thats more what im thinking about
no im not 😞
w

witty-crayon-22786

03/19/2019, 6:50 PM
there are a bunch of examples of SimpleCodegenTask implementations upstream, so worth looking at some of those.
p

polite-vase-75369

03/19/2019, 6:51 PM
so with SimpleCodegenTask i can first generate code, it goes somewhere (.pants.d/...) and then i can reference it?
w

witty-crayon-22786

03/19/2019, 6:52 PM
SimpleCodegenTask also creates the target for the code
in this case, that would be a
node_module
probably
p

polite-vase-75369

03/19/2019, 6:52 PM
the node plugin is also kinda atypical, not sure if uve looked at it a bunch, it creates symlinks
w

witty-crayon-22786

03/19/2019, 6:52 PM
it then injects that target "next to" the original thrift target
p

polite-vase-75369

03/19/2019, 6:53 PM
oh
actually we are using simplecodegen
what do you mean by "next to"
w

witty-crayon-22786

03/19/2019, 7:00 PM
If a target was directly depending on the thrift target, after simplecodegentask runs it will also be directly depending on the generated ("synthetic") target
p

polite-vase-75369

03/19/2019, 7:04 PM
so i should just be able to add that as a dependency in my build?
i wonder if node just does weird stuff and it isn't working as it should
w

witty-crayon-22786

03/19/2019, 7:05 PM
are you creating the right target type in your SimpleCodegenTask?
and is it running?
ordering matters more for codegen... you need to make sure your task is installed "before" the consuming task
p

polite-vase-75369

03/19/2019, 7:07 PM
code gen def runs, just feels like it's out of order
OH the target type seems wrong
a

aloof-angle-91616

03/20/2019, 4:52 AM
@polite-vase-75369 yes,
NodeModule
would be the correct thing to return from
synthetic_target_type()