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

rapid-bird-79300

02/16/2023, 7:24 PM
Hey Pants Team, curious if there's a way to have the BUILD files changed as input to a
goal_rule
. Using
targets: Targets
doesn't seem to include BUILD files.
āœ… 1
b

bitter-ability-32190

02/16/2023, 7:25 PM
Specs
? And filter the file specs to
BUILD
files?
r

rapid-bird-79300

02/16/2023, 7:25 PM
use case you can run
./pants my-goal app/BUILD
and we can inspect the options on that file
b

bitter-ability-32190

02/16/2023, 7:26 PM
oh, well you can certainly get the
BUILD
contents. Getting the semantic contents may be a different affair (post-macro targets/fields/etc...)
r

rapid-bird-79300

02/16/2023, 7:27 PM
yeah at this point I just want the input to show in the plugin goal right now it's just
Copy code
12:22:21.29 [INFO] stdout: "Targets([])"
b

bitter-ability-32190

02/16/2023, 7:29 PM
Copy code
files = await Get(SpecsPaths, Specs, specs)
and then
Copy code
specified_build_files = FilespecMatcher(
            includes=[os.path.join("**", p) for p in build_file_options.patterns],
            excludes=build_file_options.ignores,
        ).matches(files)
I think that ought to get you the
BUILD
files generically
šŸ‘ 1
Including referencing the build file patterns
r

rapid-bird-79300

02/16/2023, 7:30 PM
that looks like the right path but how do we accept that as input to the plugin?
like right now we don't know which BUILD file to inspect
b

bitter-ability-32190

02/16/2023, 7:31 PM
Combine with
--changed-since
?
r

rapid-bird-79300

02/16/2023, 7:31 PM
so you're saying
/pants my-goal --changed-since=origin/master app/BUILD
?
we provide spec files in CI and still not sure how we can detect that a
app/BUILD
was provided as input to the goal
b

bitter-ability-32190

02/16/2023, 7:33 PM
ā€¢ Make
my-goal
take in
Specs
and filter just to
BUILD
files using the above code ā€¢ Run it using
./pants --changed-since my-goal
šŸ‘€ 1
There's probably a way to make it with with "changed since specs" or something but thats beyond me šŸ™‚
r

rapid-bird-79300

02/16/2023, 7:35 PM
Copy code
targets: Targets,
    spec: Specs,
seeing some rule graph errors
b

bitter-ability-32190

02/16/2023, 7:36 PM
Do you also want
targets
?
r

rapid-bird-79300

02/16/2023, 7:36 PM
ahhhh I see we can't have both it's either or
cool then we can take those specs and get more details
b

bitter-ability-32190

02/16/2023, 7:37 PM
You can use
specs
to get `targets`:
Copy code
Get(
        FilteredTargets,
        Specs,
        specs,
    )
r

rapid-bird-79300

02/16/2023, 7:37 PM
this is perfect thank you @bitter-ability-32190 this was very helpful
b

bitter-ability-32190

02/16/2023, 7:38 PM
šŸ™Œ
3 Views