How to use a (custom, local) package?

I have created a (local) package that that overrides the toolchain (this works), and one that contains my HAL code. Both get installed in the packages directory.

platform_packages = 
   toolchain-atmelavr@file://c:/ti-software/platformio/avr-gcc-10.2
   hwlib@file://c:/ti-software/hwlib

Now I want to use that hwlib from a project. I tried to add it as a dependency, but it isn’t found.

lib_deps = hwlib

How do I use an installed package?

Libraries should not be modeled as packages. Libraries are libraries, PlatformIO handles them natively as such with the library dependency finder and lib_deps system. If you have HAL code, use a normal library structure as outlined in the standard library readme. Libraries can optionally have a library.json manifest file, the content of which is vastly different to a package.json.

Once you have a valid library folder, do not inject it via platform_packages, but a regular lib_deps expression (also see these docs for possible ways to reference a library – via http://, file://, name in the registry, etc.)

lib_deps = 
   file://c:/ti-software/hwlib

Note that if the that library folder is put into the lib/ folder of the project, it is automatically recognized.

Furhter reading: The library dependency finder (LDF).