|
| 1 | +.. |
| 2 | + # ******************************************************************************* |
| 3 | + # Copyright (c) 2026 Contributors to the Eclipse Foundation |
| 4 | + # |
| 5 | + # See the NOTICE file(s) distributed with this work for additional |
| 6 | + # information regarding copyright ownership. |
| 7 | + # |
| 8 | + # This program and the accompanying materials are made available under the |
| 9 | + # terms of the Apache License Version 2.0 which is available at |
| 10 | + # https://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + # |
| 12 | + # SPDX-License-Identifier: Apache-2.0 |
| 13 | + # ******************************************************************************* |
| 14 | +
|
| 15 | +Extension API |
| 16 | +============= |
| 17 | + |
| 18 | +Consumer Entry Point |
| 19 | +-------------------- |
| 20 | + |
| 21 | +Consumers interact with this repository through the ``gcc`` module extension in |
| 22 | +``@score_bazel_cpp_toolchains//extensions:gcc.bzl``. |
| 23 | + |
| 24 | +Typical usage looks like this: |
| 25 | + |
| 26 | +.. code-block:: starlark |
| 27 | +
|
| 28 | + bazel_dep(name = "score_bazel_cpp_toolchains", version = "0.4.0") |
| 29 | +
|
| 30 | + gcc = use_extension("@score_bazel_cpp_toolchains//extensions:gcc.bzl", "gcc") |
| 31 | +
|
| 32 | + gcc.toolchain( |
| 33 | + name = "score_gcc_toolchain", |
| 34 | + target_cpu = "x86_64", |
| 35 | + target_os = "linux", |
| 36 | + version = "12.2.0", |
| 37 | + use_default_package = True, |
| 38 | + ) |
| 39 | +
|
| 40 | + use_repo(gcc, "score_gcc_toolchain") |
| 41 | +
|
| 42 | +Public Tags |
| 43 | +----------- |
| 44 | + |
| 45 | +``gcc.toolchain(...)`` |
| 46 | + Declares a toolchain repository to generate. |
| 47 | + |
| 48 | +``gcc.sdp(...)`` |
| 49 | + Declares a package repository explicitly. This is used when the package is |
| 50 | + not taken from the default version matrix or when local QNX SDP generation is |
| 51 | + required. |
| 52 | + |
| 53 | +``gcc.toolchain(...)`` Attributes |
| 54 | +--------------------------------- |
| 55 | + |
| 56 | +Required attributes: |
| 57 | + |
| 58 | +- ``name``: name of the generated repository |
| 59 | +- ``target_cpu``: target CPU, currently ``x86_64`` or ``aarch64`` |
| 60 | +- ``target_os``: target OS, currently ``linux`` or ``qnx`` |
| 61 | + |
| 62 | +Common package selection attributes: |
| 63 | + |
| 64 | +- ``use_default_package``: resolve package metadata from ``packages/version_matrix.bzl`` |
| 65 | +- ``version``: GCC version string for Linux toolchains |
| 66 | +- ``sdp_version``: QNX SDP version string |
| 67 | +- ``sdk_version``: alternative SDK identifier used in matrix resolution |
| 68 | +- ``sdp_to_link``: override the package repository name that the toolchain uses |
| 69 | + |
| 70 | +Flag and runtime attributes: |
| 71 | + |
| 72 | +- ``extra_compile_flags`` |
| 73 | +- ``extra_c_compile_flags`` |
| 74 | +- ``extra_cxx_compile_flags`` |
| 75 | +- ``extra_link_flags`` |
| 76 | +- ``ld_library_paths`` |
| 77 | +- ``runtime_ecosystem`` |
| 78 | +- ``use_base_constraints_only`` |
| 79 | + |
| 80 | +QNX-specific attributes: |
| 81 | + |
| 82 | +- ``license_path`` |
| 83 | +- ``license_info_variable`` |
| 84 | +- ``license_info_url`` |
| 85 | + |
| 86 | +``gcc.sdp(...)`` Attributes |
| 87 | +--------------------------- |
| 88 | + |
| 89 | +The ``gcc.sdp`` tag defines the package side of the toolchain setup. Important |
| 90 | +attributes are: |
| 91 | + |
| 92 | +- ``name``: repository name for the package |
| 93 | +- ``build_file``: BUILD file that exposes the package contents as Bazel targets |
| 94 | +- ``url`` and ``sha256``: archive or installer source |
| 95 | +- ``strip_prefix``: extraction prefix for packaged archives |
| 96 | +- ``mode``: ``archive`` or ``build`` |
| 97 | +- ``patchset``: QNX SDP patchset definition used in build mode |
| 98 | +- ``target_cpu``: target CPU used when building an SDP locally |
| 99 | + |
| 100 | +Activation In A Workspace |
| 101 | +------------------------- |
| 102 | + |
| 103 | +Declaring a toolchain repository is not enough on its own. Consumers still need |
| 104 | +to activate the generated toolchain during Bazel analysis, typically with a |
| 105 | +configuration such as: |
| 106 | + |
| 107 | +.. code-block:: text |
| 108 | +
|
| 109 | + --extra_toolchains=@score_gcc_toolchain//:x86_64-linux-gcc_12.2.0 |
| 110 | +
|
| 111 | +The example workspace under ``examples/`` provides complete ``.bazelrc`` |
| 112 | +configurations for this activation step. |
| 113 | + |
| 114 | +Behavior Notes |
| 115 | +-------------- |
| 116 | + |
| 117 | +- The extension is intended for the root module. |
| 118 | +- When ``use_default_package`` is enabled, the version matrix can inject extra |
| 119 | + include and link flags required by non-standard sysroot layouts. |
| 120 | +- QNX toolchains use additional licensing and include-path parameters that do |
| 121 | + not apply to Linux toolchains. |
0 commit comments