Have a "local" library repository?

Hello,

I am currently struggling to understand how PlatformIO libraries work. I am familiar with package managers (e.g. Maven, Gradle, npm, yarn, docker (registry)), but in those cases I can have local “Artifactory” or “SonaType Nexus” instances in my network to provide me with the packages.

For PlatformIO, I do not understand how to achieve this.

Let’s say I have a library “LibA”, a library “LibB” and an application “AppA”.

“LibB” should depend on “LibA”, but I have no clue on what to add into the dependencies attribute in the library.json in “LibB” since I have no owner name in the PlatformIO registry.

“AppA” should depend on “LibB”, but what would I insert into the lib_deps attribute in the platformio.ini?

“LibB” library.json:

{
  "name": "HardwareSensors",
  "keywords": "sensors, hardware",
  "description": "A simple library containing hardware implementations for sensor adapters",
  "version": "1.00.0",
  "authors": {
    "name": "Igor Voronin",
    "url": "https://github.com/divStar"
  },
  "frameworks": "arduino",
  "platforms": "atmelsam",
  "dependencies": {
    "AbstractSensors": "1.00.0"
  },
  "build": {
    "libArchive": false
  }
}

“LibA” library.json:

{
  "name": "AbstractSensors",
  "keywords": "sensors, abstract, interfaces",
  "description": "A simple library containing abstract interfaces for sensor adapters",
  "version": "1.00.0",
  "authors": {
    "name": "Igor Voronin",
    "url": "https://github.com/divStar"
  },
  "frameworks": "*",
  "platforms": "*",
  "build": {
    "libArchive": false
  }
}

“AppA” platformio.ini:

[platformio]
description = Firmware
default_envs = zeroUSB, native

[env:zeroUSB]
platform = atmelsam
board = zeroUSB
framework = arduino
upload_speed = 115200
upload_port = /dev/cu.usbmodem101
lib_deps =
    fastled/FastLED@^3.6.0
    arkhipenko/TaskScheduler@^3.7.0
    bblanchon/ArduinoJson@^6.21.2
    thijse/ArduinoLog@^1.1.1
    arduino-libraries/RTCZero@^1.6.0
    ivanseidel/LinkedList@0.0.0-alpha+sha.dac3874d28
    paulstoffregen/CapacitiveSensor@^0.5.1
    denyssene/SimpleKalmanFilter@^0.1.0
build_flags = -std=gnu++17
build_unflags = -std=gnu++11
build_src_flags = -Wall -Wextra -Wpedantic
build_src_filter = +<*> -<test/>

[env:native]
platform = native
lib_deps = unity
build_src_filter = +<test/>

Any ideas on e.g. where to place the installable libraries (probably some remote git repository on e.g. a local GitLab instance)?

And how would I add the dependencies to “LibB” and “AppA”?

Also: while “LibA” is trivial - it’s just abstract classes acting as interfaces for decoupling, “LibB” is not as trivial. Is it allowed to also have a platformio.ini in my “LibB” and have e.g. tests or something in the repository in order for e.g. someone to be able to download the library and enhance it and be able to perform some tests to check whether stuff still works?

I am planning on open-sourcing the libraries afterwards, in fact I have published an early version of the firmware for the device here, but I want to make it more testable and I want to have a “virtual device” in order to make the development of a userspace driver easier.