How to use po-util's library manager


#1

One of po-util's new features is its library manager.

The library manager makes it easy to use Particle libraries when developing with po-util locally. The library manager does this by using git to download Particle libraries hosted on GitHub and save them to a ~/.po-util/lib directory so that they make be linked inside of projects later.

Here are all of the commands for the library manager:

"po library": The Particle Library manager for po-util.
                Libraries are kept in ~/.po-util/lib

Commands:
  get          Download a Particle Library from GitHub and optionally name it.
  install      Example:
                      po lib get https://github.com/user/libraryName libraryName

  add          Add a downloaded library to a po-util project.
  import       Libraries are added in the firmware directory as soft links.
               Example:
                      po lib add libraryName

  remove       Remove a library from a po-util project.
  rm           Just the soft links are deleted.
               Example:
                      po lib rm libraryName

  create       Create a library from C++ files in the project directory.
               Example:
                      po lib create someLibrary

  purge        Uninstall (delete) a library from ~/.po-util/lib
               Example:
                      po lib purge someLibrary

  list         Show all libraries in ~/.po-util/lib

  help         Show this help documentation.

Can I transfer my Web IDE Project?

The library manager makes it easy to download libraries used in the Web IDE. Here is an example showing how to download the official PowerShield library.

Step 1: Finding the GitHub URL

To find the GitHub URL for a library on the Web IDE, simply click on the GitHub Icon.

You will be taken to the library’s GitHub repository. Click on the “Clone or Download” button and copy the URL inside of the box.

Step 2: Downloading the library

Assuming you already have po-util installed, you would simply download a library by doing:

po lib get GITHUB_URL

pasting in the URL you copied from GitHub.

So to get the PowerShield library you would do:

po lib get https://github.com/spark/PowerShield.git

Step 3: Adding the library to a po-util project

To add a library to a project you would run:

po lib add LIBRARY_NAME

So to add the PowerShield library you would run:

po lib add PowerShield

####Step 4: Using the library

To include the library, you would simply add:

#include "LIBRARY_NAME.h"

to your main.cpp file.

Does this make local development easier?

It does. The library manager adds a useful feature to po-util, making po-util an even more handy tool for developing locally. The library manager is included in po-util, which is available for Linux and MacOS for everyone to use for free.

Po-util can be downloaded by doing:

curl -fsSLO https://raw.githubusercontent.com/nrobinson2000/po-util/master/po-util.sh
./po-util.sh install

or by following the alternative instructions on po-util.com. Po-util is open source and can be found on GitHub. https://github.com/nrobinson2000/po-util


Po-util: a Toolchain Installer / Helper for Linux and OSX
Truly offline IDE?
#2

I have made a major update to po-util and its library manager.

First of all, po-util now uses version 6.x of Node.js, which will remain stable for a while.

Second, I have made it so that po-util keeps track of the libraries you are using in a project by storing the URL where you cloned the library from and the name of the library in a libs.txt file in the root of each project folder.

The beauty of this is that po-util maintains a list of dependent libraries for your project, so that when you decide to share your project, other users can simply run po lib setup to automatically download and link all of the dependent libraries listed in your libs.txt.

Another handy command is po lib clean, which essentially removes all of the symlinks in your project, and leaves your libs.txt untouched. This is ideal for when sharing your project, as there will be no dead symlinks.

Here is an example libs.txt:

https://github.com/Adesh/SparkCore-LiquidCrystal-master.git LiquidCrystal
https://github.com/spark/PowerShield.git PowerShield
https://github.com/spark/OneWireLibrary.git OneWire
https://github.com/tomdeboer/SparkCoreDallasTemperature.git spark-dallas-temperature
https://github.com/spark/AssetTracker.git AssetTracker
https://github.com/spark/InternetButton.git InternetButton
https://github.com/spark/RelayShield.git RelayShield

It contains several libraries, each with the GitURL LibName notation.

Here is what po-util outputs when I run po lib setup to download and link all of the requested libraries:

Dowloading library LiquidCrystal...

Cloning into 'LiquidCrystal'...
remote: Counting objects: 20, done.
remote: Total 20 (delta 0), reused 0 (delta 0), pack-reused 20
Unpacking objects: 100% (20/20), done.
Checking connectivity... done.

Adding library LiquidCrystal to this project...

Dowloading library PowerShield...

Cloning into 'PowerShield'...
remote: Counting objects: 39, done.
remote: Total 39 (delta 0), reused 0 (delta 0), pack-reused 39
Unpacking objects: 100% (39/39), done.
Checking connectivity... done.

Adding library PowerShield to this project...

Dowloading library OneWire...

Cloning into 'OneWire'...
remote: Counting objects: 113, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 113 (delta 0), reused 0 (delta 0), pack-reused 111
Receiving objects: 100% (113/113), 37.19 KiB | 0 bytes/s, done.
Resolving deltas: 100% (53/53), done.
Checking connectivity... done.

Adding library OneWire to this project...

Dowloading library spark-dallas-temperature...

Cloning into 'spark-dallas-temperature'...
remote: Counting objects: 44, done.
remote: Total 44 (delta 0), reused 0 (delta 0), pack-reused 44
Unpacking objects: 100% (44/44), done.
Checking connectivity... done.

Adding library spark-dallas-temperature to this project...

Dowloading library AssetTracker...

Cloning into 'AssetTracker'...
remote: Counting objects: 39, done.
remote: Total 39 (delta 0), reused 0 (delta 0), pack-reused 39
Unpacking objects: 100% (39/39), done.
Checking connectivity... done.

Adding library AssetTracker to this project...

Dowloading library InternetButton...

Cloning into 'InternetButton'...
remote: Counting objects: 189, done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 189 (delta 7), reused 0 (delta 0), pack-reused 171
Receiving objects: 100% (189/189), 60.04 KiB | 0 bytes/s, done.
Resolving deltas: 100% (107/107), done.
Checking connectivity... done.

Adding library InternetButton to this project...

Dowloading library RelayShield...

Cloning into 'RelayShield'...
remote: Counting objects: 37, done.
remote: Total 37 (delta 0), reused 0 (delta 0), pack-reused 37
Unpacking objects: 100% (37/37), done.
Checking connectivity... done.

Adding library RelayShield to this project...

Po-util’s library manager makes it dead simple to download and manage libraries when developing locally on MacOS and Linux Distributions.

Get po-util today by downloading the script and running the install command:

curl -fsSLO https://raw.githubusercontent.com/nrobinson2000/po-util/master/po-util.sh
./po-util.sh install

#3

Hey Robin
The po-util is really awesome! just perfect!
I was wondering how I could use the library manager for this PN532 Library:
po lib get https://github.com/elechouse/PN532
The Problems are the following:

  1. It creates subdirs like this:
    ~/.po-util/lib/PN532/PN532/PN532.h
    I “remedied” this by just copying them to lib by hand

ls ~/.po-util/lib
NDEF PN532 PN532_HSU PN532_I2C PN532_SPI

But now I am getting compile errors all over the place and really don’t want to copy all library headers into all folders, unless this is the only way?
i.e. I am getting this:

~/someProject/firmware/PN532_SPI/PN532_SPI.cpp:3:25: fatal error: PN532_debug.h: No such file or directory
#include “PN532_debug.h”

PN532_debug.h simply resides in firmware/PN532/ but is not found somehow…

Thanks a lot in advance!


#4

Thank you for choosing po-util!

Po-util expects a library repository to contain only one library and to be at the top level.

Does the project require all the libraries to work? If so you could do:

po lib add NDEF
po lib add PN532

...etc

Update:
The library also looks like it still needs some work being ported from Arduino.

Update 2:

I just reread your post. You should change #include "PN532_debug.h" to #include "PN532/PN532_debug.h" I think.


#5

Thanks Rob

got it to work the “dirty” way by just copying them all in one Folder… Just need the main and the _SPI part, have not tested functionality yet though, only compiling :wink:

What do you mean by it needs work to be ported from arduino?


#6

I just saw a few #include "Arduino.h" laying around but maybe it’s fine.


#7

#include "Arduino.h" should be fine from 0.6.1 on, but better 0.6.2+