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

average-sugar-68948

12/16/2022, 9:35 PM
Hi folks. Sorry for the (probably) repeat question, but couldn't find searching: what's the latest on C/C++ support? I see some cc_sources in master, but it doesn't appear to be enabled. Any examples out there? I'm looking to have a Python+C++ through ctypes setup.
f

fast-nail-55400

12/16/2022, 9:42 PM
I believe @wide-midnight-78598 is in the process of splitting https://github.com/pantsbuild/pants/pull/16424 apart and submitting it in smaller pieces. So the support on
main
is definitely not ready yet until that process is done.
w

wide-midnight-78598

12/16/2022, 9:42 PM
That's correct. And man splitting up that PR is tedious 😢
The end of that should be 1st party lib and binary compilation
a

average-sugar-68948

12/16/2022, 9:59 PM
Awesome! Just glad to see progress, I'll be eagerly awaiting completion. Hopefully I can get away with making .so's manually with make until it lands.
w

wide-midnight-78598

12/16/2022, 10:09 PM
So, if you're able to, it would be great to get some incremental testing on this along the way - to catch all the places where I've missed stuff. For example, right now if you
tailor
and then run
./pants roots
or something, is everything even picked up correctly
If my pesky migraine goes away, then I was going to push a PR tonight checking for local gcc/clang, and also downloading standalone toolchains
a

average-sugar-68948

12/16/2022, 10:46 PM
sorry newb question, I did a default pants install so am on 2.14.0. should I do something different?
f

fast-nail-55400

12/16/2022, 10:49 PM
if you are using a current copy of the
./pants
script, you can set the environment variable
PANT_SHA
to a git commit ID from the Pants
main
branch and the `./pants`script will download and run from that point on Pants
main
that would allow you to easily consume a development version to try out stuff as it lands
w

wide-midnight-78598

12/16/2022, 10:51 PM
e.g.
PANTS_SHA=d209d1558202349896fa268b2c0a1b3c5fd8b546 ./pants --version
a

average-sugar-68948

12/17/2022, 1:58 PM
that's awesome, I love pants so much already. I updated to that commit (2.16.0.dev2+gitd209d155), but
./pants tailor <dir>
doesn't modify <dir>/BUILD, when <dir> contains a single <file>.cc. Is that the intended usage?
w

wide-midnight-78598

12/17/2022, 2:35 PM
Hmm, I'm not a
tailor
user, so I can't recall if it updates BUILD files - if you delete that file, does it create one including
cc_sources
f

fast-nail-55400

12/17/2022, 2:46 PM
tailor
only adds targets, it doesn't update existing targets
a

average-sugar-68948

12/18/2022, 2:44 PM
The BUILD file I had was originally empty (and remained empty after tailor). I also tried removing the BUILD file, but tailor didn't recreate it.
I'll make a small test repo tomorrow and share it
w

wide-midnight-78598

12/18/2022, 2:59 PM
Silly question: Did you add the experimental
cc
package? Just a sanity check
a

average-sugar-68948

12/19/2022, 3:28 PM
Not a silly question - I hadn't found where it was but I tracked it down. Now I see cc_sources() added to my BUILD on a
tailor
. Sorry, just getting familiar. So I guess next step is working toward a run/test goal. Did that toolchain-checking PR land?
w

wide-midnight-78598

12/19/2022, 3:33 PM
It'll be getting pushed for a PR in a few minutes - and will need some bikeshedding on the options/flags naming. Supports system clang/gcc, and then a downloadable toolchain (which I've only ever tested on ARM gcc) Once that passes, I'll throw in the compilation/linking stuff hopefully this week if I get time
I'd love some input on the bikeshedding to avoid an echo chamber. https://github.com/pantsbuild/pants/discussions/16777 https://github.com/pantsbuild/pants/pull/17844
a

average-sugar-68948

12/19/2022, 6:28 PM
Awesome. I don't have any meaningful input into the names discussion (e.g. I don't think C preprocessor when I see cpp)
How's it going? I pulled the change from Dec 27, and I'm using
cc_sources
with clang-format for linting along with my Python, which is nice. I'm currently fudging the build by subprocessing a bash script at import time to build a shared library that is loaded into python with ctypes (oh the humanity!). But I noticed that when including a
cc_source
as a dependency in a
python_source
, the cc files don't actually make it into the sandbox. I have to use a
files
target. Should this work?