Needy

The Dependency Helper

Needs File

The needs file is the thing that defines what your needs are. It can be defined as either a JSON or YAML file. YAML is generally preferred as it’s less prone to stray comma errors and is much easier to use with Jinja templating, but it does require the pyyaml Python module to be installed. JSON works with no additional Python modules installed, so may be preferable if you have simple needs and don’t want to require users to install anything.

The examples here will use YAML, but both JSON and YAML use all of the same configuration parameters.

The most basic of needs files looks something like this:

libraries:
    catch:
        repository: git@github.com:philsquared/Catch.git
        commit: v1.3.0

This should go into a file named needs.yaml. In this example, we’re starting off by declaring a dependency on Catch, a unit testing framework. If you invoke needy satisfy from the directory with this file, Needy will download and build Catch.

You can find example configurations for more libraries in the functional tests (look in tests/functional).

Using the Output

When needy builds a library, it will put the build products into a needs directory alongside the needs file. This directory should not be committed to version control (Add it to your .gitignore if you’re using Git.). The layout of this directory looks something like this:

- needs
  - catch
    - build
      - osx
        - x86_64
          + include
          + lib
    + source
  needs.yaml

The exact path to the output depends on your target, but the build directory always contains include and lib directories containing the headers you should include and the libraries you might want to link to.

The easiest way to add these include and lib directories to your path is via the needy cflags and needy ldflags commands. Passing the output of those commands as compiler and linker arguments will add all of the header and library output to your search paths, and all you’ll need to do is add -l flags if necessary.

Universal Binaries

If you need a universal binary, you can specify it like so:

universal-binaries:
    iphoneos:
        ios:
            - armv7
            - arm64

Then, you can build it via needy satisfy -u iphoneos. Needy will build each library for each target individually, merge the binaries into fat binaries, and create a set of universal headers for you to use.

The output is used in the same way as for individual architectures.

Available Configuration Parameters

These are the parameters that can be specified in your needs file.

Top Level

Library

Project

The project configuration describes how the library is built.

Projects that are header-only or built from source use the following parameters:

Projects that are built with Make use the following parameters:

Projects that are built using Autotools use the following parameters:

Projects that are built using Boost.Build use the following parameters:

Projects that are built using CMake use the following parameters:

Projects that are built using MSBuild use the following parameters:

Projects that are built using Xcode use the following parameters:

Projects that are built using custom steps defined by the needs file use the following parameters:

String values are formatted with the following parameters:

This means you may need to escape curly braces in your strings (see the Python format string documentation).