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

Add alwayslink attribute to bazel static library import #11560

Merged
merged 4 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion conan/tools/google/bazeldeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _get_dependency_buildfile_content(self, dependency):
{% for libname, filepath in libs.items() %}
cc_import(
name = "{{ libname }}_precompiled",
{{ library_type }} = "{{ filepath }}"
{{ library_type }} = "{{ filepath }}",
)
{% endfor %}

Expand Down Expand Up @@ -91,6 +91,7 @@ def _get_dependency_buildfile_content(self, dependency):
visibility = ["//visibility:public"],
{% if libs or shared_with_interface_libs %}
deps = [
# do not sort
{% for lib in libs %}
":{{ lib }}_precompiled",
{% endfor %}
Expand Down
7 changes: 4 additions & 3 deletions conans/test/unittests/tools/google/test_bazeldeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_bazeldeps_dependency_buildfiles():
assert 'linkopts = ["/DEFAULTLIB:system_lib1"]' in dependency_content
else:
assert 'linkopts = ["-lsystem_lib1"],' in dependency_content
assert 'deps = [\n \n ":lib1_precompiled",' in dependency_content
assert """deps = [\n # do not sort\n \n ":lib1_precompiled",""" in dependency_content


def test_bazeldeps_get_lib_file_path_by_basename():
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_bazeldeps_get_lib_file_path_by_basename():
assert 'linkopts = ["/DEFAULTLIB:system_lib1"]' in dependency_content
else:
assert 'linkopts = ["-lsystem_lib1"],' in dependency_content
assert 'deps = [\n \n ":liblib1.a_precompiled",' in dependency_content
assert 'deps = [\n # do not sort\n \n ":liblib1.a_precompiled",' in dependency_content


def test_bazeldeps_dependency_transitive():
Expand Down Expand Up @@ -148,7 +148,7 @@ def test_bazeldeps_dependency_transitive():

# Ensure that transitive dependency is referenced by the 'deps' attribute of the direct
# dependency
assert re.search(r'deps =\s*\[\s*":lib1_precompiled",\s*"@TransitiveDepName"',
assert re.search(r'deps =\s*\[\s*# do not sort\s*":lib1_precompiled",\s*"@TransitiveDepName"',
dependency_content)


Expand Down Expand Up @@ -220,6 +220,7 @@ def test_bazeldeps_shared_library_interface_buildfiles():
includes=["include"],
visibility=["//visibility:public"],
deps = [
#donotsort
czoido marked this conversation as resolved.
Show resolved Hide resolved
czoido marked this conversation as resolved.
Show resolved Hide resolved
":lib1_precompiled",
],
)
Expand Down