Created a `./docs` directory to house documentation (#466)

* Added links to docs to top level README

* Updated more docs

* Added generated header
This commit is contained in:
UebelAndre 2021-01-24 15:23:19 -08:00 committed by GitHub
parent 1b48e17f96
commit 8b8f31dd1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 296 additions and 185 deletions

View File

@ -66,3 +66,9 @@ tasks:
working_directory: test/detect_root_test
test_targets:
- "//:tests"
docs_linux:
name: Docs
platform: ubuntu2004
working_directory: docs
build_targets:
- //...

View File

@ -1,3 +1,4 @@
docs
examples
toolchains_examples
test/standard_cxx_flags_test

1
.gitignore vendored
View File

@ -74,5 +74,6 @@ fabric.properties
# Ignore all bazel-* symlinks. There is no full list since this can change
# based on the name of the directory bazel is cloned into.
/bazel-*
/docs/bazel-*
/examples/bazel-*
.ijwb/

124
README.md
View File

@ -1,4 +1,5 @@
# rules_foreign_cc
[![Build status](https://badge.buildkite.com/c28afbf846e2077715c753dda1f4b820cdcc46cc6cde16503c.svg)](https://buildkite.com/bazel/rules-foreign-cc)
**Rules for building C/C++ projects using foreign build systems inside Bazel projects.**
@ -6,17 +7,24 @@
This is **not an officially supported Google product**
(meaning, support and/or new releases may be limited.)
## Documentation
Documentation for all rules and providers are available [here](./docs/README.md)
## Bazel versions compatibility
Works with Bazel after 3.0.0 without any flags.
## News
**March 2019:**
- Support for versions earlier then 0.22 was removed.
- Tests on Bazel CI are running in the nested workspace
**January 2019:**
- Bazel 0.22.0 is released, no flags are needed for this version, but it does not work on Windows (Bazel C++ API is broken).
- Support for versions earlier then 0.20 was removed.
@ -47,21 +55,22 @@ Extracted shell fragments are described in commands.bzl.
Further planned steps in this direction: testing with RBE, shell script fragments for running on Windows without msys/mingw,
tests for shell fragments.
## Building CMake projects:
## Building CMake projects
- Build libraries/binaries with CMake from sources using cmake_external rule
- Use cmake_external targets in cc_library, cc_binary targets as dependency
- Bazel cc_toolchain parameters are used inside cmake_external build
- See full list of cmake_external arguments below 'example'
- cmake_external is defined in ./tools/build_defs
- Works on Ubuntu, Mac OS and Windows(* see special notes below in Windows section) operating systems
- Works on Ubuntu, Mac OS and Windows(\* see special notes below in Windows section) operating systems
**Example:**
(Please see full examples in ./examples)
<br/>The example for **Windows** is below, in the section 'Usage on Windows'.
* In `WORKSPACE`, we use a `http_archive` to download tarballs with the libraries we use.
* In `BUILD`, we instantiate a `cmake_external` rule which behaves similarly to a `cc_library`, which can then be used in a C++ rule (`cc_binary` in this case).
The example for **Windows** is below, in the section 'Usage on Windows'.
- In `WORKSPACE`, we use a `http_archive` to download tarballs with the libraries we use.
- In `BUILD`, we instantiate a `cmake_external` rule which behaves similarly to a `cc_library`, which can then be used in a C++ rule (`cc_binary` in this case).
In `WORKSPACE`, put
@ -166,9 +175,11 @@ $ devbazel build //examples/cmake_pcl:eigen
**Usage on Windows**
When using on Windows, you should start Bazel in MSYS2 shell, as the shell script inside cmake_external assumes this.
Also, you should explicitly specify **make commands and option to generate CMake crosstool file**.<br/>
Also, you should explicitly specify **make commands and option to generate CMake crosstool file**.
The default generator for CMake will be detected automatically, or you can specify it explicitly.
<br/>**The tested generators:** Visual Studio 15, Ninja and NMake.
**The tested generators:** Visual Studio 15, Ninja and NMake.
The extension '.lib' is assumed for the static libraries by default.
Example usage (see full example in ./examples/cmake_hello_world_lib):
@ -217,103 +228,6 @@ cmake_external(
)
```
**cmake_external arguments:**
Mandatory arguments:
```name, lib_source```
```python
attrs: {
# CMake only:
#
# Relative install prefix to be passed to CMake in -DCMAKE_INSTALL_PREFIX
"install_prefix": attr.string(mandatory = False),
# CMake cache entries to initialize (they will be passed with -Dkey=value)
# Values, defined by the toolchain, will be joined with the values, passed here.
# (Toolchain values come first)
"cache_entries": attr.string_dict(mandatory = False, default = {}),
# CMake environment variable values to join with toolchain-defined.
# For example, additional CXXFLAGS.
"env_vars": attr.string_dict(mandatory = False, default = {}),
# Other CMake options
"cmake_options": attr.string_list(mandatory = False, default = []),
# When True, CMake crosstool file will be generated from the toolchain values,
# provided cache-entries and env_vars (some values will still be passed as -Dkey=value
# and environment variables).
# If CMAKE_TOOLCHAIN_FILE cache entry is passed, specified crosstool file will be used
# When using this option, it makes sense to specify CMAKE_SYSTEM_NAME in the
# cache_entries - the rule makes only a poor guess about the target system,
# it is better to specify it manually.
"generate_crosstool_file": attr.bool(mandatory = False, default = False),
# Working directory, with the main CMakeLists.txt
# (otherwise, the top directory of the lib_source label files is used.)
"working_directory": attr.string(mandatory = False, default = ""),
#
# From framework.bzl:
#
# Library name. Defines the name of the install directory and the name of the static library,
# if no output files parameters are defined (any of static_libraries, shared_libraries,
# interface_libraries, binaries_names)
# Optional. If not defined, defaults to the target's name.
"lib_name": attr.string(mandatory = False),
# Label with source code to build. Typically a filegroup for the source of remote repository.
# Mandatory.
"lib_source": attr.label(mandatory = True, allow_files = True),
# Optional compilation definitions to be passed to the dependencies of this library.
# They are NOT passed to the compiler, you should duplicate them in the configuration options.
"defines": attr.string_list(mandatory = False, default = []),
#
# Optional additional inputs to be declared as needed for the shell script action.
# Not used by the shell script part in cc_external_rule_impl.
"additional_inputs": attr.label_list(mandatory = False, allow_files = True, default = []),
# Optional additional tools needed for the building.
# Not used by the shell script part in cc_external_rule_impl.
"additional_tools": attr.label_list(mandatory = False, allow_files = True, default = []),
#
# Optional part of the shell script to be added after the make commands
"postfix_script": attr.string(mandatory = False),
# Optinal make commands, defaults to ["make", "make install"]
"make_commands": attr.string_list(mandatory = False, default = ["make", "make install"]),
#
# Optional dependencies to be copied into the directory structure.
# Typically those directly required for the external building of the library/binaries.
# (i.e. those that the external build system will be looking for and paths to which are
# provided by the calling rule)
"deps": attr.label_list(mandatory = False, allow_files = True, default = []),
# Optional tools to be copied into the directory structure.
# Similar to deps, those directly required for the external building of the library/binaries.
"tools_deps": attr.label_list(mandatory = False, allow_files = True, default = []),
#
# Optional name of the output subdirectory with the header files, defaults to 'include'.
"out_include_dir": attr.string(mandatory = False, default = "include"),
# Optional name of the output subdirectory with the library files, defaults to 'lib'.
"out_lib_dir": attr.string(mandatory = False, default = "lib"),
# Optional name of the output subdirectory with the binary files, defaults to 'bin'.
"out_bin_dir": attr.string(mandatory = False, default = "bin"),
#
# Optional. if true, link all the object files from the static library,
# even if they are not used.
"alwayslink": attr.bool(mandatory = False, default = False),
# Optional link options to be passed up to the dependencies of this library
"linkopts": attr.string_list(mandatory = False, default = []),
#
# Output files names parameters. If any of them is defined, only these files are passed to
# Bazel providers.
# if no of them is defined, default lib_name.a/lib_name.lib static library is assumed.
#
# Optional names of the resulting static libraries.
"static_libraries": attr.string_list(mandatory = False),
# Optional names of the resulting shared libraries.
"shared_libraries": attr.string_list(mandatory = False),
# Optional names of the resulting interface libraries.
"interface_libraries": attr.string_list(mandatory = False),
# Optional names of the resulting binaries.
"binaries": attr.string_list(mandatory = False),
# Flag variable to indicate that the library produces only headers
"headers_only": attr.bool(mandatory = False, default = False),
}
```
## Design document:
## Design document
[External C/C++ libraries rules](https://docs.google.com/document/d/1Gv452Vtki8edo_Dj9VTNJt5DA_lKTcSMwrwjJOkLaoU/edit?usp=sharing)

View File

@ -1,9 +1,21 @@
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
genrule(
name = "flatten_header_vm",
srcs = [
"gen_header.sh",
"docs.bzl",
],
outs = ["flatten_header.vm"],
cmd = "$(location gen_header.sh) $(location docs.bzl) $@",
output_to_bindir = True,
)
stardoc(
name = "docs",
out = "docs.md",
header_template = ":flatten_header_vm",
input = "docs.bzl",
deps = ["@rules_foreign_cc//:bzl_srcs"],
)
@ -23,7 +35,7 @@ genrule(
cmd = """cat << EOF > $@
#!/bin/bash
set -e
cat \\$${BUILD_WORKSPACE_DIRECTORY}/$(location //docs:docs) > \\$${BUILD_WORKSPACE_DIRECTORY}/docs/README.md
cat \\$${BUILD_WORKSPACE_DIRECTORY}/$(location //:docs) > \\$${BUILD_WORKSPACE_DIRECTORY}/README.md
""",
)

View File

@ -1,4 +1,20 @@
<!-- Generated with Stardoc: http://skydoc.bazel.build -->
# Rules Foreign CC
- [boost_build](#boost_build)
- [cmake_external](#cmake_external)
- [cmake_tool](#cmake_tool)
- [ConfigureParameters](#ConfigureParameters)
- [configure_make](#configure_make)
- [ForeignCcArtifact](#ForeignCcArtifact)
- [ForeignCcDeps](#ForeignCcDeps)
- [InputFiles](#InputFiles)
- [make](#make)
- [make_tool](#make_tool)
- [native_tool_toolchain](#native_tool_toolchain)
- [ninja_tool](#ninja_tool)
- [rules_foreign_cc_dependencies](#rules_foreign_cc_dependencies)
- [ToolInfo](#ToolInfo)
- [WrappedOutputs](#WrappedOutputs)
<a id="#boost_build"></a>
@ -89,6 +105,25 @@ Rule for building external library with CMake.
| <a id="cmake_external-working_directory"></a>working_directory | Working directory, with the main CMakeLists.txt (otherwise, the top directory of the lib_source label files is used.) | String | optional | "" |
<a id="#cmake_tool"></a>
## cmake_tool
<pre>
cmake_tool(<a href="#cmake_tool-name">name</a>, <a href="#cmake_tool-cmake_srcs">cmake_srcs</a>)
</pre>
Rule for building CMake. Invokes bootstrap script and make install.
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="cmake_tool-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
| <a id="cmake_tool-cmake_srcs"></a>cmake_srcs | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
<a id="#configure_make"></a>
## configure_make
@ -186,6 +221,64 @@ Rule for building external libraries with GNU Make. GNU Make commands (make and
| <a id="make-tools_deps"></a>tools_deps | Optional tools to be copied into the directory structure. Similar to deps, those directly required for the external building of the library/binaries. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
<a id="#make_tool"></a>
## make_tool
<pre>
make_tool(<a href="#make_tool-name">name</a>, <a href="#make_tool-make_srcs">make_srcs</a>)
</pre>
Rule for building Make. Invokes configure script and make install.
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="make_tool-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
| <a id="make_tool-make_srcs"></a>make_srcs | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
<a id="#native_tool_toolchain"></a>
## native_tool_toolchain
<pre>
native_tool_toolchain(<a href="#native_tool_toolchain-name">name</a>, <a href="#native_tool_toolchain-path">path</a>, <a href="#native_tool_toolchain-target">target</a>)
</pre>
Rule for defining the toolchain data of the native tools (cmake, ninja), to be used by rules_foreign_cc with toolchain types `@rules_foreign_cc//tools/build_defs:cmake_toolchain` and `@rules_foreign_cc//tools/build_defs:ninja_toolchain`.
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="native_tool_toolchain-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
| <a id="native_tool_toolchain-path"></a>path | Absolute path to the tool in case the tool is preinstalled on the machine. Relative path to the tool in case the tool is built as part of a build; the path should be relative to the bazel-genfiles, i.e. it should start with the name of the top directory of the built tree artifact. (Please see the example <code>//examples:built_cmake_toolchain</code>) | String | optional | "" |
| <a id="native_tool_toolchain-target"></a>target | If the tool is preinstalled, must be None. If the tool is built as part of the build, the corresponding build target, which should produce the tree artifact with the binary to call. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
<a id="#ninja_tool"></a>
## ninja_tool
<pre>
ninja_tool(<a href="#ninja_tool-name">name</a>, <a href="#ninja_tool-ninja_srcs">ninja_srcs</a>)
</pre>
Rule for building Ninja. Invokes configure script and make install.
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="ninja_tool-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
| <a id="ninja_tool-ninja_srcs"></a>ninja_srcs | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
<a id="#ConfigureParameters"></a>
## ConfigureParameters
@ -280,6 +373,25 @@ and C/C++ compilation and linking info from dependencies
| <a id="InputFiles-declared_inputs"></a>declared_inputs | All files and directories that must be declared as action inputs |
<a id="#ToolInfo"></a>
## ToolInfo
<pre>
ToolInfo(<a href="#ToolInfo-path">path</a>, <a href="#ToolInfo-target">target</a>)
</pre>
Information about the native tool
**FIELDS**
| Name | Description |
| :------------- | :------------- |
| <a id="ToolInfo-path"></a>path | Absolute path to the tool in case the tool is preinstalled on the machine. Relative path to the tool in case the tool is built as part of a build; the path should be relative to the bazel-genfiles, i.e. it should start with the name of the top directory of the built tree artifact. (Please see the example <code>//examples:built_cmake_toolchain</code>) |
| <a id="ToolInfo-target"></a>target | If the tool is preinstalled, must be None. If the tool is built as part of the build, the corresponding build target, which should produce the tree artifact with the binary to call. |
<a id="#WrappedOutputs"></a>
## WrappedOutputs

18
docs/WORKSPACE.bazel Normal file
View File

@ -0,0 +1,18 @@
workspace(name = "rules_foreign_cc_docs")
local_repository(
name = "rules_foreign_cc",
path = "..",
)
load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
rules_foreign_cc_dependencies()
load("//:stardoc_repository.bzl", "stardoc_repository")
stardoc_repository()
load("//:stardoc_deps.bzl", "stardoc_deps")
stardoc_deps()

View File

@ -1,9 +1,17 @@
"""A module exporting symbols for Stardoc generation"""
"""A module exporting symbols for Stardoc generation."""
load("@rules_foreign_cc//:workspace_definitions.bzl", _rules_foreign_cc_dependencies = "rules_foreign_cc_dependencies")
load("@rules_foreign_cc//for_workspace:cmake_build.bzl", _cmake_tool = "cmake_tool")
load("@rules_foreign_cc//for_workspace:make_build.bzl", _make_tool = "make_tool")
load("@rules_foreign_cc//for_workspace:ninja_build.bzl", _ninja_tool = "ninja_tool")
load("@rules_foreign_cc//tools/build_defs:boost_build.bzl", _boost_build = "boost_build")
load(
"@rules_foreign_cc//tools/build_defs/native_tools:native_tools_toolchain.bzl",
_ToolInfo = "ToolInfo",
_native_tool_toolchain = "native_tool_toolchain",
)
load("@rules_foreign_cc//tools/build_defs:cmake.bzl", _cmake_external = "cmake_external")
load("@rules_foreign_cc//tools/build_defs:configure.bzl", _configure_make = "configure_make")
load("@rules_foreign_cc//:workspace_definitions.bzl", _rules_foreign_cc_dependencies = "rules_foreign_cc_dependencies")
load("@rules_foreign_cc//tools/build_defs:make.bzl", _make = "make")
load(
"@rules_foreign_cc//tools/build_defs:framework.bzl",
@ -14,14 +22,17 @@ load(
_WrappedOutputs = "WrappedOutputs",
)
# Rules
# Rules Foreign CC symbols
boost_build = _boost_build
cmake_external = _cmake_external
cmake_tool = _cmake_tool
configure_make = _configure_make
make = _make
make_tool = _make_tool
native_tool_toolchain = _native_tool_toolchain
ninja_tool = _ninja_tool
rules_foreign_cc_dependencies = _rules_foreign_cc_dependencies
# Providers
# buildifier: disable=name-conventions
ConfigureParameters = _ConfigureParameters
@ -36,3 +47,6 @@ InputFiles = _InputFiles
# buildifier: disable=name-conventions
WrappedOutputs = _WrappedOutputs
# buildifier: disable=name-conventions
ToolInfo = _ToolInfo

31
docs/gen_header.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
set -euo pipefail
# The block below functions as follows
#
# - Look for all assignments
# - Remove all load statements
# - Remove multi line load statements
# - Remvoe all whitespace
# - Remove all comments
# - Strip assignments
# - Generate `- [symbol](#sybol)` formatting
# - Sort entries
TABLE_OF_CONTENTS=$(grep "=" "$1" \
| sed '/^load.*/d' \
| sed '/,$/d' \
| sed '/^$/d' \
| sed '/^#/d' \
| sed 's/ = .*//' \
| sed 's/\(.*\)/- [\1](#\1)/' \
| sort -f
)
cat << EOF > "$2"
# Rules Foreign CC
${TABLE_OF_CONTENTS}
EOF

View File

@ -9,7 +9,6 @@ tests = [
"//cmake_cares:test_old_c_ares",
"//cmake_hello_world_lib/static:test_hello",
"//cmake_nghttp2:test_nghttp2",
"//docs:docs_build_test",
# Commented out because the paths in shell test should be different depending on whether it called
# from out workspace or same workspace
# Uncomment after nested workspaces are supported on CI

View File

@ -54,11 +54,3 @@ maven_install(
load(":examples_repositories.bzl", "include_examples_repositories")
include_examples_repositories()
load("//docs:stardoc_repository.bzl", "stardoc_repository")
stardoc_repository()
load("//docs:stardoc_deps.bzl", "stardoc_deps")
stardoc_deps()

View File

@ -33,11 +33,8 @@ def _cmake_tool(ctx):
return [DefaultInfo(files = depset([cmake]))]
""" Rule for building CMake. Invokes bootstrap script and make install.
Attributes:
cmake_srcs - target with the CMake sources
"""
cmake_tool = rule(
doc = "Rule for building CMake. Invokes bootstrap script and make install.",
attrs = {
"cmake_srcs": attr.label(mandatory = True),
},

View File

@ -30,13 +30,13 @@ def _make_tool(ctx):
return [DefaultInfo(files = depset([make]))]
""" Rule for building Make. Invokes configure script and make install.
Attributes:
make_srcs - target with the Make sources
"""
make_tool = rule(
doc = "Rule for building Make. Invokes configure script and make install.",
attrs = {
"make_srcs": attr.label(mandatory = True),
"make_srcs": attr.label(
doc = "target with the Make sources",
mandatory = True,
),
},
fragments = ["cpp"],
output_to_genfiles = True,

View File

@ -27,11 +27,8 @@ def _ninja_tool(ctx):
return [DefaultInfo(files = depset([ninja]))]
""" Rule for building Ninja. Invokes configure script and make install.
Attributes:
ninja_srcs - target with the Ninja sources
"""
ninja_tool = rule(
doc = "Rule for building Ninja. Invokes configure script and make install.",
attrs = {
"ninja_srcs": attr.label(mandatory = True),
},

View File

@ -17,19 +17,27 @@ def create_cmake_script(
include_dirs = [],
is_debug_mode = True):
"""Constructs CMake script to be passed to cc_external_rule_impl.
Args:
workspace_name - current workspace name
target_os - OSInfo with target operating system information, used for CMAKE_SYSTEM_NAME in
workspace_name: current workspace name
target_os: OSInfo with target operating system information, used for CMAKE_SYSTEM_NAME in
CMake toolchain file
tools - cc_toolchain tools (CxxToolsInfo)
flags - cc_toolchain flags (CxxFlagsInfo)
install_prefix - value ot pass to CMAKE_INSTALL_PREFIX
root - sources root relative to the $EXT_BUILD_ROOT
no_toolchain_file - if False, CMake toolchain file will be generated, otherwise not
user_cache - dictionary with user's values of cache initializers
user_env - dictionary with user's values for CMake environment variables
options - other CMake options specified by user
cmake_path: The path to the cmake executable
tools: cc_toolchain tools (CxxToolsInfo)
flags: cc_toolchain flags (CxxFlagsInfo)
install_prefix: value ot pass to CMAKE_INSTALL_PREFIX
root: sources root relative to the $EXT_BUILD_ROOT
no_toolchain_file: if False, CMake toolchain file will be generated, otherwise not
user_cache: dictionary with user's values of cache initializers
user_env: dictionary with user's values for CMake environment variables
options: other CMake options specified by user
include_dirs: Optional additional include directories. Defaults to [].
is_debug_mode: If the compilation mode is `debug`. Defaults to True.
Returns:
string: A formatted string of the generated build command
"""
merged_prefix_path = _merge_prefix_path(user_cache, include_dirs)
toolchain_dict = _fill_crossfile_from_toolchain(workspace_name, target_os, tools, flags)

View File

@ -1,13 +1,17 @@
ToolInfo = provider(
doc = "Information about the native tool",
fields = {
"path": """Absolute path to the tool in case the tool is preinstalled on the machine.
Relative path to the tool in case the tool is built as part of a build; the path should be relative
to the bazel-genfiles, i.e. it should start with the name of the top directory of the built tree
artifact. (Please see the example "//examples:built_cmake_toolchain")""",
"target": """If the tool is preinstalled, must be None.
If the tool is built as part of the build, the corresponding build target, which should produce
the tree artifact with the binary to call.""",
"path": (
"Absolute path to the tool in case the tool is preinstalled on the machine. " +
"Relative path to the tool in case the tool is built as part of a build; the path should be relative " +
"to the bazel-genfiles, i.e. it should start with the name of the top directory of the built tree " +
"artifact. (Please see the example `//examples:built_cmake_toolchain`)"
),
"target": (
"If the tool is preinstalled, must be None. " +
"If the tool is built as part of the build, the corresponding build target, which should produce " +
"the tree artifact with the binary to call."
),
},
)
@ -19,26 +23,31 @@ def _native_tool_toolchain(ctx):
target = ctx.attr.target,
))
""" Rule for defining the toolchain data of the native tools (cmake, ninja),
to be used by rules_foreign_cc with toolchain types
@rules_foreign_cc//tools/build_defs:cmake_toolchain and
@rules_foreign_cc//tools/build_defs:ninja_toolchain.
"""
native_tool_toolchain = rule(
doc = (
"Rule for defining the toolchain data of the native tools (cmake, ninja), " +
"to be used by rules_foreign_cc with toolchain types " +
"`@rules_foreign_cc//tools/build_defs:cmake_toolchain` and " +
"`@rules_foreign_cc//tools/build_defs:ninja_toolchain`."
),
implementation = _native_tool_toolchain,
attrs = {
"path": attr.string(
mandatory = False,
doc = """Absolute path to the tool in case the tool is preinstalled on the machine.
Relative path to the tool in case the tool is built as part of a build; the path should be
relative to the bazel-genfiles, i.e. it should start with the name of the top directory
of the built tree artifact. (Please see the example "//examples:built_cmake_toolchain")""",
doc = (
"Absolute path to the tool in case the tool is preinstalled on the machine. " +
"Relative path to the tool in case the tool is built as part of a build; the path should be " +
"relative to the bazel-genfiles, i.e. it should start with the name of the top directory " +
"of the built tree artifact. (Please see the example `//examples:built_cmake_toolchain`)"
),
),
"target": attr.label(
mandatory = False,
doc = """If the tool is preinstalled, must be None.
If the tool is built as part of the build, the corresponding build target,
which should produce the tree artifact with the binary to call.""",
doc = (
"If the tool is preinstalled, must be None. " +
"If the tool is built as part of the build, the corresponding build target, " +
"which should produce the tree artifact with the binary to call."
),
),
},
)