OK, which is why I am trying to take all of the Arduino library code and use it as a package but whilst still being able to talk to the hardware myself without the fear that I am interfering with something in the Arduino.
It might be easier to start with
PlatformIO framework support for Arduino for that.
Maybe look at how
common examples look like there?
(The platform-atmelsam does support MKR Zero;
here is its mkrzero.json board support file, and
here the SVD XML file for ATSAMD21G18A.)
For example, the Arduino Blink example
ported to PlatformIO, targeted for Atmel SAM, has
this platformio.ini configuration file, and
this Blink.cpp file.
Basically, you work with the C++ sources, without the source-code mangling that the Arduino IDE does.
That means tracking dependencies and modifying the Arduino core files and libraries is easier (because it's then all just C++ code you can see without magickal mangling), and you can remove all the stuff you don't want.
The downside is that tracking Arduino cores and libraries becomes harder, as any customization you do needs to be ported to each new version.