b0, occasionally

The quick hints if you need to use the b0 tool occasionally.

In b0 the build is organized into named units. Lists of units can be gathered into named packs. A unit can be in more than one pack. In general the repeatable options -u and -p allow to select units and packs and -x and -X to substract from this selection.

Basic

How do I build ?

b0

What gets build ?

b0 --what

What can I build ?

b0 list

How do I run tests ?

b0 list --tests  # List tests
b0 test          # Run all tests
b0 test -l       # Run all tests, including the long ones
b0 test --what   # Show what will run
b0 test -u this -u that  # Only run the 'this' and 'that' tests
b0 test --seed 123 # Run random tests with seed 123
b0 test --correct  # Correct failed snapshot tests

Since tests are executable you can also run them directly. See How do I run build artefacts ?. In particular certain tests may offer specific options, consult them by invoking the test directly.

b0 -- this_test --help

How do I run build artefacts ?

b0 list         # Spot the name of the unit you are interested in
b0 -- mytool …  # Build mytool and run with arguments.
b0 -- mylib     # If mylib is a library gets you in a REPL
b0 -- mymedia   # May be configured to render the media
b0 -b -- mytool …   # Back to build only

How do I benchmark an executable ?

The following forms can be used in order to have up-to-date artefacts but avoiding timing the build.

time $(b0 --path -- mytool) …
hyperfine "$(b0 --path -- mytool) …"

How do I open build artefacts in a browser ?

b0 -- .show-url mywebsite
b0 -- .show-url --help     # See the different modes of operation
b0 -- mywebsite            # May be configured to open in your browser

How do I get information about a unit or pack ?

b0 info mytool
b0 info mypack

How can I use the build anywhere ?

eval $(b0 lock)
cd /any/where/
b0 -- mytool …

How can I add a new source to the project ?

b0 init src > module.ml       # Default has OCaml syntax
b0 init src unit.h unit.c     # Uses extensions for syntax
b0 init src -x > example.ml   # Uses CC0-1.0 license
b0 init src --help

More on builds

How do I build specific parts ?

b0 list            # Spot units names or packs you are interested in
b0 -u mylib -p mypack  # Build unit mylib and units in mypack
b0 -p mypack -x mytool # Build units in mypack without mytool (if applicable)

How do I clear the build ?

b0 delete
b0 delete -a   # Clean

How do I see build steps ?

b0 log
b0 log -l

Which build steps take time ?

b0 log -d

Which build steps failed ?

b0 log -e

Which build steps did really execute ?

b0 log -u