Libraries
Like most modern languages, Spade makes it easy to depend on other libraries in your project. Libraries are specified in the [libraries] section of the project swim.toml file. For example, there is an implementation of UART, I2C and SPI at https://codeberg.org/spade-lang/protocols which you can use in your project by adding
[libraries]
protocols.git = "https://codeberg.org/spade-lang/protocols"
To your swim.toml Everything in that project will then get placed in a protocols namespace in your project. For example, you can import the UART transmitter implementation in uart.spade from that project with
use protocols::uart::uart_tx;
Updating Libraries
Libraries are pinned to the git revision they were at when you added them to your project, this is tracked in the swim.lock file and ensures that a project continues to build successfully even if a dependency is updated in the future. If you wish to update your dependencies to the latest version, run
swim updateWhile Spade is evolving, it is often required to update the Spade version when updating dependencies, which can be done with
swim update-spadeFinding Libraries
You can find a list of community libraries and their documentation at the Spade package index, reef: https://reef.spade-lang.org/.
For now, reef does not host any packages, remote dependencies are always specified as git repositories and hosted at the respective git forge.The Standard Library
Spade also comes with a standard library which contains several commonly used utilities including things like the Option type we have already seen, methods for generic programming on arrays, clock domain crossing primitives and more. The standard library is always included in your project under the std:: namespace
You can find documentation for everything included in the standard library at
Customizing Dependencies
You can also depend on libraries you have locally as path dependencies, for example
[libraries]
dependency.path = "../dependency"And if you want to depend on a specific git commit when depending on a git repository you can add
[libraries]
dependency.rev = <git hash>
# or
dependency.branch = <git branch>