|
| 1 | +About the build system |
| 2 | +====================== |
| 3 | + |
| 4 | +.. include:: ../../global_substitutions.txt |
| 5 | + |
| 6 | +Under everything is the build system. |
| 7 | +Iterating on ``catkin`` from ROS 1 we have created a set of |packages| under the moniker ``ament``. |
| 8 | +Some of the reasons for changing the name to ``ament`` are that we wanted it to not collide with ``catkin`` (in case we want mix them at some point) and to prevent confusion with existing ``catkin`` documentation. |
| 9 | +``ament``'s primary responsibility is to make it easier to develop and maintain ROS 2 core |packages|. |
| 10 | +However, this responsibility extends to any user who is willing to make use of our build system conventions and tools. |
| 11 | +Additionally it should make |packages| conventional, such that developers should be able to pick up any ``ament`` based |package| and make some assumptions about how it works, how to introspect it, and how to build or use it. |
| 12 | + |
| 13 | +``ament`` consists of a few important repositories which are all in the ``ament`` |GitHub|_ organization: |
| 14 | + |
| 15 | +.. contents:: |
| 16 | + :depth: 1 |
| 17 | + :local: |
| 18 | + |
| 19 | +The ``ament_package`` Package |
| 20 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 21 | + |
| 22 | +Located on |GitHub|_ at `ament/ament_package <https://github.com/ament/ament_package>`_, this repository contains a single :term:`ament Python package` that provides various utilities for |ament packages|, e.g. templates for environment hooks. |
| 23 | + |
| 24 | +All |ament packages| must contain a single :term:`package.xml` file at the root of the package regardless of their underlying build system. |
| 25 | +The :term:`package.xml` "manifest" file contains information that is required in order to process and operate on a |package|. |
| 26 | +This |package| information includes things like the |package|'s name, which is globally unique, and the package's dependencies. |
| 27 | +The :term:`package.xml` file also serves as the marker file which indicates the location of the |package| on the file system. |
| 28 | + |
| 29 | +Parsing of the :term:`package.xml` files is provided by ``catkin_pkg`` (as in ROS 1), while functionality to locate |packages| by searching the file system for these :term:`package.xml` files is provided by build tools such as ``colcon``. |
| 30 | + |
| 31 | +.. glossary:: |
| 32 | + |
| 33 | + package.xml |
| 34 | + Package manifest file which marks the root of a :term:`package` and contains meta information about the :term:`package` including its name, version, description, maintainer, license, dependencies, and more. |
| 35 | + The contents of the manifest are in machine readable XML format and the contents are described in the |REPs| `127 <http://www.ros.org/reps/rep-0127.html>`_ and `140 <http://www.ros.org/reps/rep-0140.html>`_, with the possibility of further modifications in future |REPs|. |
| 36 | + |
| 37 | +So anytime some |package| is referred to as an :term:`ament package`, it means that it is a single unit of software (source code, build files, tests, documentation, and other resources) which is described using a :term:`package.xml` manifest file. |
| 38 | + |
| 39 | +.. glossary:: |
| 40 | + |
| 41 | + ament package |
| 42 | + Any |package| which contains a :term:`package.xml` and follows the packaging guidelines of ``ament``, regardless of the underlying build system. |
| 43 | + |
| 44 | +Since the term :term:`ament package` is build system agnostic, there can be different kinds of |ament packages|, e.g. :term:`ament CMake package`, :term:`ament Python package`, etc. |
| 45 | + |
| 46 | +Here is a list of common package types that you might run into in this software stack: |
| 47 | + |
| 48 | +.. glossary:: |
| 49 | + |
| 50 | + CMake package |
| 51 | + Any |package| containing a plain CMake project and a :term:`package.xml` manifest file. |
| 52 | + |
| 53 | + ament CMake package |
| 54 | + A :term:`CMake package` that also follows the ``ament`` packaging guidelines. |
| 55 | + |
| 56 | + Python package |
| 57 | + Any |package| containing a `setuptools <http://pythonhosted.org/setuptools/>`_ based Python project and a :term:`package.xml` manifest file. |
| 58 | + |
| 59 | + ament Python package |
| 60 | + A :term:`Python package` that also follows the ``ament`` packaging guidelines. |
| 61 | + |
| 62 | +The ``ament_cmake`` Repository |
| 63 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 64 | + |
| 65 | +Located on |GitHub|_ at `ament/ament_cmake <https://github.com/ament/ament_cmake>`_, this repository contains many "ament CMake" and pure CMake packages which provide the infrastructure in CMake that is required to create "ament CMake" packages. |
| 66 | +In this context "ament CMake" packages means: ``ament`` packages that are built using CMake. |
| 67 | +So the |packages| in this repository provide the necessary CMake functions/macros and CMake Modules to facilitate creating more "ament CMake" (or ``ament_cmake``) packages. |
| 68 | +Packages of this type are identified with the ``<build_type>ament_cmake</build_type>`` tag in the ``<export>`` tag of the :term:`package.xml` file. |
| 69 | + |
| 70 | +The |packages| in this repository are extremely modular, but there is a single "bottleneck" |package| called ``ament_cmake``. |
| 71 | +Anyone can depend on the ``ament_cmake`` |package| to get all of the aggregate functionality of the |packages| in this repository. |
| 72 | +Here a list of the |packages| in the repository along with a short description: |
| 73 | + |
| 74 | +- ``ament_cmake`` |
| 75 | + |
| 76 | + - aggregates all other |packages| in this repository, users need only to depend on this. |
| 77 | + |
| 78 | +- ``ament_cmake_auto`` |
| 79 | + |
| 80 | + - provides convenience CMake functions which automatically handle a lot of the tedious parts of writing a |package|'s ``CMakeLists.txt`` file |
| 81 | + |
| 82 | +- ``ament_cmake_core`` |
| 83 | + |
| 84 | + - provides all built-in core concepts for ``ament``, e.g. environment hooks, resource indexing, symbolic linking install and others |
| 85 | + |
| 86 | +- ``ament_cmake_gmock`` |
| 87 | + |
| 88 | + - adds convenience functions for making gmock based unit tests |
| 89 | + |
| 90 | +- ``ament_cmake_gtest`` |
| 91 | + |
| 92 | + - adds convenience functions for making gtest based automated tests |
| 93 | + |
| 94 | +- ``ament_cmake_nose`` |
| 95 | + |
| 96 | + - adds convenience functions for making nosetests based python automated tests |
| 97 | + |
| 98 | +- ``ament_cmake_python`` |
| 99 | + |
| 100 | + - provides CMake functions for |packages| that contain Python code |
| 101 | + |
| 102 | +- ``ament_cmake_test`` |
| 103 | + |
| 104 | + - aggregates different kinds of tests, e.g. gtest and nosetests, under a single target using `CTest <https://cmake.org/Wiki/CMake/Testing_With_CTest>`_ |
| 105 | + |
| 106 | +The ``ament_cmake_core`` |package| contains a lot of the CMake infrastructure that makes it possible to cleanly pass information between |packages| using conventional interfaces. |
| 107 | +This makes the |packages| have more decoupled build interfaces with other |packages|, promoting their reuse and encouraging conventions in the build systems of different |packages|. |
| 108 | +For instance it provides a standard way to pass include directories, libraries, definitions, and dependencies between |packages| so that consumers of this information can access this information in a conventional way. |
| 109 | + |
| 110 | +The ``ament_cmake_core`` |package| also provides features of the ``ament`` build system like symbolic link installation, which allows you to symbolically link files from either the source space or the build space into the install space rather than copying them. |
| 111 | +This allows you to install once and then edit non-generated resources like Python code and configuration files without having to rerun the install step for them to take effect. |
| 112 | +This feature essentially replaces the "devel space" from ``catkin`` because it has most of the advantages with few of the complications or drawbacks. |
| 113 | + |
| 114 | +Another feature provided by ``ament_cmake_core`` is the |package| resource indexing which is a way for |packages| to indicate that they contain a resource of some type. |
| 115 | +The design of this feature makes it much more efficient to answer simple questions like what |packages| are in this prefix (e.g. ``/usr/local``) because it only requires that you list the files in a single possible location under that prefix. |
| 116 | +You can read more about this feature in the `design docs <https://github.com/ament/ament_cmake/blob/master/ament_cmake_core/doc/resource_index.md>`_ for the resource index. |
| 117 | + |
| 118 | +Like ``catkin``, ``ament_cmake_core`` also provides environment setup files and |package| specific environment hooks. |
| 119 | +The environment setup files, often named something like ``setup.bash``, are a place for |package| developers to define changes to the environment that are needed to utilize their |package|. |
| 120 | +The developers are able to do this using an "environment hook" which is basically an arbitrary bit of shell code that can set or modify environment variables, define shell functions, setup auto-completion rules, etc... |
| 121 | +This feature is how, for example, ROS 1 set the ``ROS_DISTRO`` environment variable without ``catkin`` knowing anything about the ROS distribution. |
| 122 | + |
| 123 | +The ``ament_lint`` Repository |
| 124 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 125 | + |
| 126 | +Located on |GitHub|_ at `ament/ament_lint <https://github.com/ament/ament_lint>`_, this repository provides several |packages| which provide linting and testing services in a convenient and consistent manner. |
| 127 | +Currently there are |packages| to support C++ style linting using ``uncrustify``, static C++ code checks using ``cppcheck``, checking for copyright in source code, Python style linting using ``pep8``, and other things. |
| 128 | +The list of helper packages will likely grow in the future. |
| 129 | + |
| 130 | +Build tools |
| 131 | +~~~~~~~~~~~ |
| 132 | + |
| 133 | +A build tool performs the task of building a workspace of packages together at once with a single invocation. |
| 134 | +For ROS 2 releases up to Ardent, the build tool providing this functionality is called ``ament_tools``. |
| 135 | +As of ROS 2 Bouncy, ``ament_tools`` has been superseded by ``colcon``, as described in `the universal build tool article <http://design.ros2.org/articles/build_tool.html>`_. |
0 commit comments