Add optional tool_path_origin to Tools in C++ crosstool

This change adds an optional field to the C++ crosstool proto that
allows configuring the origin tool_path is relative to.

For now, the origin can be one of the following:
  - CROSSTOOL_PACKAGE: If tool_path is a relative path, it's assumed to
    be relative to the package of the crosstool top.
  - FILESYSTEM_ROOT: tool_path is an absolute path. This is checked by
    Bazel.
  - WORKSPACE_ROOT: tool_path must be a relative path and is assumed to
    be relative to the exec-root of the workspace (similar to other
    executables).

Updates bazelbuild/bazel#8438

Closes #10967.

PiperOrigin-RevId: 310142352
Change-Id: If6316ffa5d7d2713b197840b4aafb2f0cdbb0b96
This commit is contained in:
Yannic Bonenberger 2020-05-06 06:52:09 -07:00 committed by Copybara-Service
parent 9ddf8aac74
commit dbe8807224
1 changed files with 22 additions and 3 deletions

View File

@ -16,11 +16,11 @@
syntax = "proto2"; syntax = "proto2";
// option java_api_version = 2; // copybara-comment-this-out-please
option java_package = "com.google.devtools.build.lib.view.config.crosstool";
package com.google.devtools.build.lib.view.config.crosstool; package com.google.devtools.build.lib.view.config.crosstool;
// option java_api_version = 2; // copybara-comment-this-out-please
option java_package = "com.google.devtools.build.lib.view.config.crosstool";
// A description of a toolchain, which includes all the tools generally expected // A description of a toolchain, which includes all the tools generally expected
// to be available for building C/C++ targets, based on the GNU C compiler. // to be available for building C/C++ targets, based on the GNU C compiler.
// //
@ -235,9 +235,28 @@ message CToolchain {
// Describes a tool associated with a crosstool action config. // Describes a tool associated with a crosstool action config.
message Tool { message Tool {
// Describes the origin of a path.
enum PathOrigin {
// Indicates that `tool_path` is relative to the location of the
// crosstool. For legacy reasons, absolute paths are als0 allowed here.
CROSSTOOL_PACKAGE = 0;
// Indicates that `tool_path` is an absolute path.
// This is enforced by Bazel.
FILESYSTEM_ROOT = 1;
// Indicates that `tool_path` is relative to the current workspace's
// exec root.
WORKSPACE_ROOT = 2;
}
// Path to the tool, relative to the location of the crosstool. // Path to the tool, relative to the location of the crosstool.
required string tool_path = 1; required string tool_path = 1;
// Origin of `tool_path`.
// Optional only for legacy reasons. New crosstools should set this value!
optional PathOrigin tool_path_origin = 4 [default = CROSSTOOL_PACKAGE];
// A list of feature sets defining when this tool is applicable. The tool // A list of feature sets defining when this tool is applicable. The tool
// will used when any one of the feature sets evaluate to true. (That is, // will used when any one of the feature sets evaluate to true. (That is,
// when when every 'feature' is enabled, and every 'not_feature' is not // when when every 'feature' is enabled, and every 'not_feature' is not