Anyone know of a guide or tutorial on adding depen...
# plugins
c
Anyone know of a guide or tutorial on adding dependency inference? I'm thinking about adding a plugin to compile C code
f
You should look at the
cc
backend. We already have dependency inference for C code.
(At least based on includes.)
The
cc
backend is incomplete though and could use some attention. :)
cc @wide-midnight-78598 on whether you have any relevant work which is not in repo.
c
I did see that but didn't understand how it works
I think pants' environment could be really good for my project (CircuitPython) because we have many targets that get compiled in different gcc environments because they are for different microcontrollers
w
Incomplete is correct. A lot of the base stuff is there, but I was splitting it into 3-4 PRs for easier PRing before work became crazy. My original impetus for this was also embedded programming, which is why I had hooks for grabbing gcc-arm as well
https://github.com/sureshjoshi/pants I have a bunch of "cc" branches, which is where the existing work is captured. If someone wants to take it over the line, I'd be really happy, as I still really need it, but won't be able to get back to Pants for at least 2 weeks (and first, I have completions testing to land, and then some updates to the VSCode Plugin)
Though, in fairness, I was thinking about this last night - and based on some of the other plugins I've written, and some enhancements, I'm less sure of my approach
c
Nice! Good to know it was also for embedded
what are you less sure of?
w
I think trying to be too clever about generating objects, using the Pants cache and all that. That's nice and all, and maybe it's useful in some bootstrapping situations, but I feel like if I were to do it again (and maybe I will re-do it this way), I'd probably want Pants as a front-end to a ninja backend. Like, let the battle-tested, super fast tool do what it's supposed to, and have the Pants plugin act more like cmake to generate the appropriate ninja build files
Then, my follow-up idea of being able to run pants on cmake files becomes even better. That's something I'll have to do anyways, some migration from cmake to pants via Tailor. I don't think we could legitimately have a C backend without nice cmake interop
That's not to say that they're mutually exclusive, though.
c
cmake interop would be nice. right now we have complicated make system that ignores our deps' cmake files. my main goal is to unify our builds across boards
right now make takes in a BOARD= variable and builds it independently of others
and we have 400+ boards
🤯 1
are there any other cases where pants is a frontend to another system?
from my understanding it does a lot of what ninja does already
w
So, as an example, in the JS backend, Pants does some dep management, but npm or one of those package managers handles the nitty-gritty about the language. I have a Swift plugin somewhere, and that forks everything off to the swift compiler. There were talks about starting from the LLVM layer with Pants in CC, but I dunno, I see the practical side being higher-level configuration, management, toolchains. The actual act of compiling is honestly an "irrelevant" implementation detail
c
I've wanted to switch to clang but it doesn't have as small code size as gcc. So, I'd vote to keep them separate
w
Well, the toolchain part is just something you specify at the system level (or download if it's downloadable). Use gcc, gcc-arm, clang, zig, 🤷 who cares. I view it more as "here's the libraries I want out, here's the binaries I want out, Pants - go figure out via dep inference where everything is - and make that happen" Whether we use raw gcc commands and cache object files galore, vs just calling out to ninja to perform the compilation step - I think that's super irrelevant
So long as we can do it in such a way that we don't re-do unnecessary work
c
what does ninja get you that pants doesn't?
w
Probably performance. In my limited tests, needing to create all those processes and caching results was slower than ninja. Not crazy amounts, but like... Why even. So, the idea would be that Pants is more equivalent to Cmake
c
either one will be faster than our current make system...
w
😆
Yeah, fair point 🙂
c
it'll become a priority for us to work on when github starts charging open source projects for build time
w
Uhhh that's a thing?
c
not yet
🤞
w
🙏
c
you can always do the ninja backend for pants later
that could be generally applied I'd think
w
I agree. Its an experimental backend anyways - so, any of the low level changes wouldn't actually touch the API. And in a cruel twist of irony, the very project I'm backlogged working on right now, was the exact project I was building that plugin for. And now, I'm trying to cram a toolchain together to build this thing again 🤦‍♂️
c
🙂