Questions about sub workspaces and query command

26 views
Skip to first unread message

Anna Ström

unread,
May 2, 2021, 10:38:30 PM5/2/21
to bazel-discuss

Hi,

I have some questions about subworkspaces. First is a description of the environment and then the questions in the end.

Our environment

===============

Repo where we run the bazel commands from 

/bazel/...


Test repos added to bazel repo WORKSPACE file as follows:

local_repository(

    name = "world",

    path = "../../bbi/testarea/tutorialFromBazel/54322/Norden/World",

)

 

local_repository(

    name = "norden",

    path = "../../bbi/testarea/tutorialFromBazel/54322/Norden",

)

 

Our test repos

==============

Norden

├── BUILD

├── HelloNorden.cc

├── HelloNorden.hh

├── WORKSPACE

└── World

    ├── BUILD

    ├── HelloWorld.cc

    ├── HelloWorld.hh

    └── WORKSPACE

 

WORKSPACE File for Norden:

 

local_repository(

    name = "europe",

    path = "../Europe",

)

 

local_repository(

    name = "world",

    path = "World",

)

 

BUILD for Norden:

cc_binary(

    name = "HelloNorden",

    srcs = ["HelloNorden.cc", "HelloNorden.hh"],

    deps = ["@europe//:HelloEurope", "@world//:HelloWorld"],

    visibility = ["//visibility:public"],

)


WORKSPACE for World:

Empty

 

BUILD for World:

cc_library(

    name = "HelloWorld",

    srcs = ["HelloWorld.cc"],

    hdrs = ["HelloWorld.hh"],

    visibility = ["//visibility:public"],

   

)

======================================

 

Questions:

 

1. Is the structure of the test repos above with a subworkspaces like "World" valid?

2.

We run the following command standing in the bazel workspace

> bazel query 'attr(visibility, "//visibility:public", @norden//...)'

 

What is the correct result:

@norden//World:HelloWorld

@norden//:HelloNorden

 

or

 

@norden//:HelloNorden

 

3. Where does bazel search for valid packages when  using a label like @norden//...?

When I added traces it seems like  it searches in any directory in both bazel directory and in the test repos including following the cache and the available direcories there including external.

 

BR Anna

Reply all
Reply to author
Forward
0 new messages