Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom skylark build flags in external dependencies #10039

Closed
moroten opened this issue Oct 15, 2019 · 2 comments
Closed

Support custom skylark build flags in external dependencies #10039

moroten opened this issue Oct 15, 2019 · 2 comments
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Configurability platforms, toolchains, cquery, select(), config transitions

Comments

@moroten
Copy link
Contributor

moroten commented Oct 15, 2019

Description of the problem / feature request:

The implementation of Skylark support for custom build flags
(#5577) does not work for custom build flags in external repositories.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Given the following setup:

mkdir my-external
touch my-external/WORKSPACE nothing.txt myext.txt top.txt

cat >my-external/BUILD.bazel <<EOF
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
bool_flag(
    name = "flag_in_myext",
    build_setting_default = False, visibility = ["//visibility:public"],
)
EOF

cat >BUILD.bazel <<EOF
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
bool_flag(
    name = "flag_at_top",
    build_setting_default = False,
)
alias(
    name = "alias_for_flag_in_myext",
    actual = "@myext//:flag_in_myext",
)
config_setting(
    name = "is_flag_at_top_enabled",
    flag_values = {":flag_at_top": "True"},
)
config_setting(
    name = "is_flag_in_myext_enabled",
    flag_values = {":alias_for_flag_in_myext": "True"},
)
filegroup(
    name = "everything",
    srcs = select({
        ":is_flag_at_top_enabled": ["top.txt"],
        ":is_flag_in_myext_enabled": ["myext.txt"],
        "//conditions:default": ["nothing.text"],
    }),
)
EOF

cat >WORKSPACE <<EOF
local_repository(name = "myext", path = "my-external")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "bazel_skylib",
    url = "https://github.com/bazelbuild/bazel-skylib/archive/b113ed5d05ccddee3093bb157b9b02ab963c1c32.zip",
    sha256 = "cea47b31962206b7ebf2088f749243868d5d9305273205bdd8651567d3e027fc",
    strip_prefix = "bazel-skylib-b113ed5d05ccddee3093bb157b9b02ab963c1c32",
)
EOF

the output looks like

$ bazel cquery 'kind("source file", deps(:everything))'
//:nothing.text (null)
$ bazel cquery 'kind("source file", deps(:everything))' --//:flag_at_top
//:top.txt (null)
$ bazel cquery 'kind("source file", deps(:everything))' --@myext//:flag_in_myext
ERROR: Unrecognized option: --@myext//:flag_in_myext
$ bazel cquery 'kind("source file", deps(:everything))' --//:alias_for_flag_in_myext
ERROR: Unrecognized option: //:alias_for_flag_in_myext

I would expect the bottom two cases to work and output //:myext.txt (null). The alias would be very convenient for the user to shorten the command line.

What operating system are you running Bazel on?

Linux

What's the output of bazel info release?

release 1.0.0

Have you found anything relevant by searching the web?

@gregestren suggested reporting this bug/feature request as the core functionality was implemented in #5577.

@gregestren gregestren added P2 We'll consider working on this in future. (Assignee optional) team-Configurability platforms, toolchains, cquery, select(), config transitions labels Oct 15, 2019
@gregestren
Copy link
Contributor

This is worth at least clarifying which part of the code base is failing to make the connection. From there we can prioritize the right fix.

@jmillikin-stripe
Copy link
Contributor

PR to support Starlark-defined flags starting with --@: #10052

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Configurability platforms, toolchains, cquery, select(), config transitions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants