.. _module-pw_build-project_builder: =============== Project Builder =============== .. pigweed-module-subpage:: :name: pw_build The ``pw_build`` Python module contains a light-weight build command execution library used for projects that require running multiple commands to perform a build. For example: running ``cmake`` alongside ``gn``. .. grid:: 3 .. grid-item-card:: :octicon:`rocket` Get started :link: module-pw_build-project_builder-start :link-type: ref :class-item: sales-pitch-cta-primary How to write your own build script. .. grid-item-card:: :octicon:`code-square` Reference :link: module-pw_build-project_builder-reference :link-type: ref :class-item: sales-pitch-cta-secondary Reference details about the ``pw_build`` Python API. .. grid-item-card:: :octicon:`terminal` ``pw build`` CLI :link: module-pw_build-project_builder-cli :link-type: ref :class-item: sales-pitch-cta-secondary Command line interface usage. .. _module-pw_build-project_builder-start: ----------- Get Started ----------- The quickest way to get started with Project Builder is to create a build script based on existing examples. Example Build Scripts ===================== Examples of Project Builder based ``pw build`` commands: - `Upstream Pigweed repo pigweed_upstream_build.py `_ - `Examples repo build_project.py `_ - `Kudzu repo build_project.py `_ .. _module-pw_build-project_builder-reference: --------- Reference --------- At a high level: - A single :py:class:`BuildRecipe ` contains many :py:class:`BuildCommands ` which are run sequentially. - Multiple :py:class:`BuildRecipes ` can be created and passed into the :py:class:`ProjectBuilder ` class which provides logging and terminal output options. - A :py:class:`ProjectBuilder ` instance is then passed to the :py:func:`run_builds ` function which allows specifying the number of parallel workers (the number of recipes which are executed in parallel). .. mermaid:: flowchart TB subgraph BuildRecipeA ["BuildRecipe: ninja"] buildCommandA1["BuildCommand
gn gen out"] buildCommandA2["BuildCommand
ninja -C out default"] buildCommandA1-->buildCommandA2 end subgraph BuildRecipeB ["BuildRecipe: bazel"] buildCommandB1["BuildCommand
bazel build //...:all"] buildCommandB2["BuildCommand
bazel test //...:all"] buildCommandB1-->buildCommandB2 end ProjectBuilder["ProjectBuilder(build_recipes=...)"] BuildRecipeA-->ProjectBuilder BuildRecipeB-->ProjectBuilder run_builds["run_builds(project_builder=..., workers=1)"] ProjectBuilder-->run_builds BuildCommand ============ .. autoclass:: pw_build.build_recipe.BuildCommand BuildCommand Run Filters ------------------------ .. autofunction:: pw_build.build_recipe.should_gn_gen .. autofunction:: pw_build.build_recipe.should_gn_gen_with_args .. autofunction:: pw_build.build_recipe.should_regenerate_cmake BuildRecipe =========== .. autoclass:: pw_build.build_recipe.BuildRecipe ProjectBuilder ============== .. autoclass:: pw_build.project_builder.ProjectBuilder .. autofunction:: pw_build.project_builder.run_builds .. _module-pw_build-project_builder-cli: -------------------------------------------------- Upstream ``pw build`` Command-Line Interface Usage -------------------------------------------------- .. argparse:: :module: pw_build.pigweed_upstream_build :func: _build_argument_parser :prog: pw build This is the command line interface provided by the ``pw build`` command (`pigweed_upstream_build.py `_) in upstream Pigweed.