Skip to content

Latest commit

 

History

History
 
 

libraries

nRF library JSON definition

JSON files in the current directory define libraries, which are then used to autogenerate CMake files inside ./cmake folder. This is done by invoking ./ci/scripts/generate_cmake.sh shell script.

Schema

Library defnition follows the schema, which is is properly defined inside the ./ci/scripts/python/nrf5_cmake/library_description.py file. The basic structure is as follows:

"library_name": {
    "documentation": "Short documentation of a library",
    "variant": "object",
    "sdk_version": {
        "from": "X.X.X",
        "to": "X.X.X"
    },
    "sources": [
      "relative/to/sdk/source1.c",
      "relative/to/sdk/source2.c"
    ],
    "includes": {
      "public": [
        "public_include_directory1",
        "public_include_directory2"
      ],
      "private": [
        "private_include_directory1"
      ],
      "private": [
        "interface_include_directory1"
      ]
    },
    "dependencies": {
      "public": [
        "dep1",
        "dep2"
      ]
    },
    "cflags": {
       "public": [
        "-DCFLAG=1"
      ]
    },
    "asmflags": {
       "public": [
        "-DASMFLAG=1"
      ]
    },
    "ldflags": {
       "public": [
        "-DLDFLAG=1"
      ]
    },
    "patches": [
      {
        "operation": "add",
        "sdk_version": ...,
        "sources": ...,
        "includes": ...,
        "dependencies": ...,
        "cflags": ...,
        "asmflags": ...,
        "ldflags": ...,
      },
      {
        "operation": "remove",
        "sdk_version": ...,
        "sources": ...,
        "includes": ...,
        "dependencies": ...,
        "cflags": ...,
        "asmflags": ...,
        "ldflags": ...,
      }
    ]
  },

Documentation

Documentation is currently used to insert a comment before the library definition. This string should be helpful for users, which would like to search through all libraries to find one that they are looking for.

Variant

Currently we support "object", "interface" and "builtin" variants. The first two are used when the add_library code is generated inside the CMake file. The last one indicates that the library is defined by hand and shouldn't be autogenerated by a script. However, the definition of such a library is still useful, because other scripts may use this information when generating other things.

Sources

Each object library should define at least one source file. There shouldn't exist two libraries, which are using the same source file. Consider splitting them and using a common dependency.

Properties

The following properties are supported:

  • includes - list of include directories of a library.
  • dependencies - list of library dependencies.
  • flags - list of flags for C and C++ compiler.
  • asmflags - list of flags for ASM compiler.
  • ldflags - list of flags for the linker.

Each property may contain public, private and interface sections. All of them are optional.

Version

The library may state a range of SDK versions that are applicable to it. Both from and to properties are optional and range is specified as inclusive.

Patches

The library may change between SDK versions. Changes should be defined in the form of a list of patches that can be additive ("add") or subtractive ("remove"). SDK version is required and both "sources" and all properties are supported.