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

[BazelDeps] glob() compatible with bazel 8.x #17444

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions .ci/docker/conan-tests
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ ENV PY36=3.6.15 \
GXX_11=/usr/bin/g++-11 \
CLANG_14=/usr/bin/clang-14 \
CLANGXX_14=/usr/bin/clang++-14 \
BAZEL_6_3_2=6.3.2 \
BAZEL_7_1_2=7.1.2
BAZEL_6_5_0=6.5.0 \
BAZEL_7_4_1=7.4.1 \
BAZEL_8_0_0=8.0.0
Comment on lines +23 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestion, name this with the major so we just need to change this part for future updates:

Suggested change
BAZEL_6_5_0=6.5.0 \
BAZEL_7_4_1=7.4.1 \
BAZEL_8_0_0=8.0.0
BAZEL_6=6.5.0 \
BAZEL_7=7.4.1 \
BAZEL_8=8.0.0


RUN apt-get update && \
apt-get install -y --no-install-recommends \
Expand Down Expand Up @@ -131,14 +132,19 @@ RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 10 && \
update-alternatives --set clang /usr/bin/clang-14 && \
update-alternatives --set clang++ /usr/bin/clang++-14

RUN mkdir -p /usr/share/bazel-$BAZEL_6_3_2/bin && \
wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_6_3_2}/bazel-${BAZEL_6_3_2}-linux-x86_64 && \
chmod +x bazel-${BAZEL_6_3_2}-linux-x86_64 && \
mv bazel-${BAZEL_6_3_2}-linux-x86_64 /usr/share/bazel-$BAZEL_6_3_2/bin/bazel && \
mkdir -p /usr/share/bazel-$BAZEL_7_1_2/bin && \
wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_7_1_2}/bazel-${BAZEL_7_1_2}-linux-x86_64 && \
chmod +x bazel-${BAZEL_7_1_2}-linux-x86_64 && \
mv bazel-${BAZEL_7_1_2}-linux-x86_64 /usr/share/bazel-$BAZEL_7_1_2/bin/bazel
RUN mkdir -p /usr/share/bazel-$BAZEL_6_5_0/bin && \
wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_6_5_0}/bazel-${BAZEL_6_5_0}-linux-x86_64 && \
chmod +x bazel-${BAZEL_6_5_0}-linux-x86_64 && \
mv bazel-${BAZEL_6_5_0}-linux-x86_64 /usr/share/bazel-$BAZEL_6_5_0/bin/bazel && \
mkdir -p /usr/share/bazel-$BAZEL_7_4_1/bin && \
wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_7_4_1}/bazel-${BAZEL_7_4_1}-linux-x86_64 && \
chmod +x bazel-${BAZEL_7_4_1}-linux-x86_64 && \
mv bazel-${BAZEL_7_4_1}-linux-x86_64 /usr/share/bazel-$BAZEL_7_4_1/bin/bazel && \
mkdir -p /usr/share/bazel-$BAZEL_8_0_0/bin && \
wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_8_0_0}/bazel-${BAZEL_8_0_0}-linux-x86_64 && \
chmod +x bazel-${BAZEL_8_0_0}-linux-x86_64 && \
mv bazel-${BAZEL_8_0_0}-linux-x86_64 /usr/share/bazel-$BAZEL_8_0_0/bin/bazel


USER conan
WORKDIR $HOME
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/osx-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ jobs:
~/Applications/CMake/3.15.7
~/Applications/CMake/3.19.7
~/Applications/CMake/3.23.5
~/Applications/bazel/6.3.2
~/Applications/bazel/7.1.2
~/Applications/bazel/6.5.0
~/Applications/bazel/7.4.1
~/Applications/bazel/8.0.0
key: ${{ runner.os }}-conan-tools-cache

- name: Build CMake old versions not available for ARM
Expand Down Expand Up @@ -111,7 +112,7 @@ jobs:
if: steps.cache-tools.outputs.cache-hit != 'true'
run: |
set -e
for version in 6.3.2 7.1.2; do
for version in 6.5.0 7.4.1 8.0.0; do
mkdir -p ${HOME}/Applications/bazel/${version}
wget -q -O ${HOME}/Applications/bazel/${version}/bazel https://github.com/bazelbuild/bazel/releases/download/${version}/bazel-${version}-darwin-arm64
chmod +x ${HOME}/Applications/bazel/${version}/bazel
Expand Down Expand Up @@ -146,8 +147,9 @@ jobs:
~/Applications/CMake/3.15.7
~/Applications/CMake/3.19.7
~/Applications/CMake/3.23.5
~/Applications/bazel/6.3.2
~/Applications/bazel/7.1.2
~/Applications/bazel/6.5.0
~/Applications/bazel/7.4.1
~/Applications/bazel/8.0.0
key: ${{ runner.os }}-conan-tools-cache

- name: Set up Python ${{ matrix.python-version }}
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/win-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ jobs:
C:\tools\cmake\3.15.7
C:\tools\cmake\3.19.7
C:\tools\cmake\3.23.5
C:\tools\bazel\6.3.2
C:\tools\bazel\7.1.2
C:\tools\bazel\6.5.0
C:\tools\bazel\7.4.1
C:\tools\bazel\8.0.0
key: ${{ runner.os }}-conan-tools-cache

- name: Build CMake old versions of CMake
Expand Down Expand Up @@ -211,7 +212,7 @@ jobs:
- name: Install Bazel versions
if: steps.cache-tools.outputs.cache-hit != 'true'
run: |
$BAZEL_BUILD_VERSIONS = "6.3.2", "7.1.2"
$BAZEL_BUILD_VERSIONS = "6.5.0", "7.4.1", "8.0.0"
foreach ($version in $BAZEL_BUILD_VERSIONS) {
Write-Host "Downloading Bazel version $version for Windows..."
$destination = "C:\tools\bazel\$version"
Expand Down
4 changes: 3 additions & 1 deletion conan/tools/google/bazeldeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ class _BazelBUILDGenerator:
{% for bindir in obj["bindirs"] %}
"{{ bindir }}/**",
{% endfor %}
]),
],
allow_empty = True
),
visibility = ["//visibility:public"],
)
{% endif %}
Expand Down
17 changes: 10 additions & 7 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,16 @@
"system": {"path": {'Windows': "C:/tools/cygwin/bin"}},
},
'bazel': {
"default": "6.3.2",
"6.3.2": {"path": {'Linux': '/usr/share/bazel-6.3.2/bin',
'Windows': 'C:/tools/bazel/6.3.2',
'Darwin': '/Users/runner/Applications/bazel/6.3.2'}},
"7.1.2": {"path": {'Linux': '/usr/share/bazel-7.1.2/bin',
'Windows': 'C:/tools/bazel/7.1.2',
'Darwin': '/Users/runner/Applications/bazel/7.1.2'}},
"default": "7",
"6.5.0": {"path": {'Linux': '/usr/share/bazel-6.5.0/bin',
'Windows': 'C:/tools/bazel/6.5.0',
'Darwin': '/Users/runner/Applications/bazel/6.5.0'}},
"7.4.1": {"path": {'Linux': '/usr/share/bazel-7.4.1/bin',
'Windows': 'C:/tools/bazel/7.4.1',
'Darwin': '/Users/runner/Applications/bazel/7.4.1'}},
"8.0.0": {"path": {'Linux': '/usr/share/bazel-8.0.0/bin',
'Windows': 'C:/tools/bazel/8.0.0',
'Darwin': '/Users/runner/Applications/bazel/8.0.0'}},
Comment on lines +149 to +158
Copy link
Contributor

@czoido czoido Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we put just the major we don't have to update the tests marks in case we change versions

Suggested change
"default": "7",
"6.5.0": {"path": {'Linux': '/usr/share/bazel-6.5.0/bin',
'Windows': 'C:/tools/bazel/6.5.0',
'Darwin': '/Users/runner/Applications/bazel/6.5.0'}},
"7.4.1": {"path": {'Linux': '/usr/share/bazel-7.4.1/bin',
'Windows': 'C:/tools/bazel/7.4.1',
'Darwin': '/Users/runner/Applications/bazel/7.4.1'}},
"8.0.0": {"path": {'Linux': '/usr/share/bazel-8.0.0/bin',
'Windows': 'C:/tools/bazel/8.0.0',
'Darwin': '/Users/runner/Applications/bazel/8.0.0'}},
"default": "7",
"6": {"path": {'Linux': '/usr/share/bazel-6.5.0/bin',
'Windows': 'C:/tools/bazel/6.5.0',
'Darwin': '/Users/runner/Applications/bazel/6.5.0'}},
"7": {"path": {'Linux': '/usr/share/bazel-7.4.1/bin',
'Windows': 'C:/tools/bazel/7.4.1',
'Darwin': '/Users/runner/Applications/bazel/7.4.1'}},
"8": {"path": {'Linux': '/usr/share/bazel-8.0.0/bin',
'Windows': 'C:/tools/bazel/8.0.0',
'Darwin': '/Users/runner/Applications/bazel/8.0.0'}},

},
'premake': {
"disabled": True,
Expand Down
19 changes: 15 additions & 4 deletions test/functional/toolchains/google/test_bazel.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def base_profile():


@pytest.mark.parametrize("build_type", ["Debug", "Release", "RelWithDebInfo", "MinSizeRel"])
@pytest.mark.tool("bazel", "6.3.2")
@pytest.mark.tool("bazel", "6.5.0")
def test_basic_exe_6x(bazelrc, build_type, base_profile, bazel_output_root_dir):
client = TestClient(path_with_spaces=False)
client.run(f"new bazel_exe -d name=myapp -d version=1.0 -d output_root_dir={bazel_output_root_dir}")
Expand All @@ -56,7 +56,7 @@ def test_basic_exe_6x(bazelrc, build_type, base_profile, bazel_output_root_dir):


@pytest.mark.parametrize("build_type", ["Debug", "Release", "RelWithDebInfo", "MinSizeRel"])
@pytest.mark.tool("bazel", "7.1.2")
@pytest.mark.tool("bazel", "7.4.1")
def test_basic_exe(bazelrc, build_type, base_profile, bazel_output_root_dir):
client = TestClient(path_with_spaces=False)
client.run(f"new bazel_7_exe -d name=myapp -d version=1.0 -d output_root_dir={bazel_output_root_dir}")
Expand All @@ -73,8 +73,19 @@ def test_basic_exe(bazelrc, build_type, base_profile, bazel_output_root_dir):
assert "myapp/1.0: Hello World Debug!" in client.out


@pytest.mark.tool("bazel", "8.0.0")
def test_basic_lib(bazelrc, base_profile, bazel_output_root_dir):
"""
Issue related: https://github.com/conan-io/conan/issues/17438
"""
client = TestClient(path_with_spaces=False)
client.run(f"new bazel_7_lib -d name=mylib -d version=1.0 -d output_root_dir={bazel_output_root_dir}")
client.run("create .")
assert "mylib/1.0: Hello World Release!" in client.out


@pytest.mark.parametrize("shared", [False, True])
@pytest.mark.tool("bazel", "6.3.2")
@pytest.mark.tool("bazel", "6.5.0")
def test_transitive_libs_consuming_6x(shared, bazel_output_root_dir):
"""
Testing the next dependencies structure for shared/static libs
Expand Down Expand Up @@ -200,7 +211,7 @@ def test_transitive_libs_consuming_6x(shared, bazel_output_root_dir):


@pytest.mark.parametrize("shared", [False, True])
@pytest.mark.tool("bazel", "7.1.2")
@pytest.mark.tool("bazel", "7.4.1")
@pytest.mark.skipif(platform.system() == "Linux",
reason="Conan CI fails (likely related to parallel "
"tests running??). Skipping it for now!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


@pytest.mark.skipif(platform.system() != "Darwin", reason="Only for Darwin")
@pytest.mark.tool("bazel", "6.3.2") # not working for Bazel 7.x
@pytest.mark.tool("bazel", "6.5.0") # not working for Bazel 7.x
def test_bazel_simple_cross_compilation():
profile = textwrap.dedent("""
[settings]
Expand Down
8 changes: 6 additions & 2 deletions test/integration/toolchains/google/test_bazeldeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ def layout(self):
name = "dep_binaries",
srcs = glob([
"bin/**",
]),
],
allow_empty = True
),
visibility = ["//visibility:public"],
)
""")
Expand Down Expand Up @@ -180,7 +182,9 @@ def package_info(self):
srcs = glob([
"bin1/**",
"bin2/**",
]),
],
allow_empty = True
),
visibility = ["//visibility:public"],
)
""")
Expand Down
Loading