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

Extended cpp_info model object to new components concept #5242

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
e743bd2
Added tests and first POC component class with recursive libs retrieval
danimtb May 20, 2019
7073291
Removed ordered dict class and moved to component class
danimtb May 21, 2019
66289a7
Propagate lib and exe to cpp_info and maintain current behavior or libs
danimtb May 21, 2019
07f90a7
Removed multilevel components and recursivity
danimtb May 21, 2019
25a2776
implemented inheritance of includedir directory
danimtb May 21, 2019
a100bc2
comment
danimtb May 22, 2019
9643fea
Merge branch 'develop' into feature/5090
danimtb May 28, 2019
e43b442
Directory propagation and integration test
danimtb May 28, 2019
14dc504
Introduced DirList and completed tests
danimtb May 28, 2019
b00a93c
small changes for paths
danimtb May 29, 2019
06e2117
Merge branch 'develop' into feature/5090
danimtb Jun 13, 2019
9b53334
Removed DirList and added system_deps
danimtb Jun 13, 2019
61981a2
fix exes
danimtb Jun 14, 2019
5509638
fixed deprecation warning in tests
danimtb Jun 17, 2019
f6df365
Fixed cpp_info libs value in json output
danimtb Jun 17, 2019
e88b6f1
fix test
danimtb Jun 17, 2019
6c8bd40
Add description to _get_paths()
danimtb Jun 19, 2019
831172c
removed prints
danimtb Jun 19, 2019
058ed4e
Add exes test
danimtb Jun 19, 2019
0d9ba39
Test wrong cpp_info raises on create
danimtb Jun 19, 2019
db8b873
Added system_deps test
danimtb Jun 19, 2019
b098c12
Adds complete test
danimtb Jun 19, 2019
6ab1bdb
Add system_deps global behavior
danimtb Jun 19, 2019
2f82336
Merge branch 'develop' into feature/5090
danimtb Jun 19, 2019
d1d2ffc
Indent text
danimtb Jun 20, 2019
be74c0d
Review and move libs properties. Use function to get components sorted
danimtb Jun 20, 2019
1e6e1fd
Renamed .deps to .components
danimtb Jun 20, 2019
6a2e2f7
simplified get paths
danimtb Jun 20, 2019
b32e3b9
Fix link order and added test
danimtb Jun 20, 2019
4bb2db2
Update conans/test/unittests/model/build_info_test.py
danimtb Jun 20, 2019
4b49026
Update conans/test/unittests/model/build_info_test.py
danimtb Jun 20, 2019
62a9782
Update conans/test/integration/package_info_test.py
danimtb Jun 20, 2019
b756503
Update conans/test/integration/package_info_test.py
danimtb Jun 20, 2019
aef1a51
asserts
danimtb Jun 20, 2019
b085211
fix path repetition
danimtb Jun 20, 2019
ebd80e3
remove endline
danimtb Jun 20, 2019
63f8235
move default values dict
danimtb Jun 20, 2019
2c3e3d7
Use is none
danimtb Jun 20, 2019
c01ba50
Completed test
danimtb Jun 21, 2019
d150060
Added deps_cpp_info.system_deps global
danimtb Jun 21, 2019
f61e2d9
simplified link order property, added test and fixed other ones
danimtb Jun 21, 2019
0dbb943
get paths in order too
danimtb Jun 21, 2019
c3da770
docstring
danimtb Jun 21, 2019
195665c
improve system_deps test
danimtb Jun 21, 2019
ff6fca3
merge methods
danimtb Jun 21, 2019
1c95d9b
Added components to the cpp_info json output
danimtb Jun 21, 2019
6cdda0f
loop check with test
danimtb Jun 24, 2019
93f6c8d
5090 fixes
lasote Jun 25, 2019
5f5f172
Merge pull request #4 from lasote/feature/5090_fixes
danimtb Jun 25, 2019
1036bd8
improved message
danimtb Jun 25, 2019
9696a4a
remove cppflags from component class
danimtb Jun 25, 2019
6fae2f8
Merge branch 'develop' into feature/5090
danimtb Jun 27, 2019
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
30 changes: 16 additions & 14 deletions conans/model/build_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,24 @@ def _sorted_components(self):
Sorted components from less dependent to the most one
:return: ordered list of components
"""
# Sort first elements with less items in .deps attribute
comps = sorted(self._components.values(), key=lambda component: len(component.deps))
# Save name of unsorted elements
unsorted_names = [comp.name for comp in comps]

unsorted_names = list(self._components.keys())
sorted_comps = []
element = unsorted_names[0]
while unsorted_names:
danimtb marked this conversation as resolved.
Show resolved Hide resolved
for comp in comps:
# If element is already sorted, continue
if comp.name not in unsorted_names:
continue
# If element does not have deps or all of its deps are already sorted, sort this
# element and remove it from the unsorted list
elif not comp.deps or not [dep for dep in comp.deps if dep in unsorted_names]:
sorted_comps.append(comp)
unsorted_names.remove(comp.name)
try:
deps = self._components[element].deps
except KeyError as e:
raise ConanException("Component %s not found in cpp_info object" % e)
if all(dep in [c.name for c in sorted_comps] for dep in deps):
sorted_comps.append(self._components[element])
unsorted_names.remove(element)
element = unsorted_names[0] if unsorted_names else None
else:
for dep in deps:
if dep not in [c.name for c in sorted_comps]:
element = dep
break
return sorted_comps

@property
Expand Down Expand Up @@ -156,7 +158,7 @@ def _get_paths(self, path_name):
result = []

if self._components:
for dep_value in self._components.values():
for dep_value in self._sorted_components:
abs_paths = self._filter_paths(getattr(dep_value, "%s_paths" % path_name))
for path in abs_paths:
if path not in result:
Expand Down
3 changes: 2 additions & 1 deletion conans/test/integration/package_info_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,9 @@ def build(self):
expected_comp_iss_library_paths
expected_global_binary_paths = expected_comp_starlight_binary_paths
expected_global_libs = expected_comp_starlight_system_deps + [expected_comp_starlight_lib]
expected_global_libs.extend(expected_comp_launcher_system_deps)
expected_global_libs.extend(expected_comp_planet_system_deps)
expected_global_libs.append(expected_comp_planet_lib)
expected_global_libs.extend(expected_comp_launcher_system_deps)
expected_global_libs.extend(expected_comp_iss_system_deps)
expected_global_libs.append(expected_comp_iss_lib)
expected_global_exes = [expected_comp_launcher_exe]
Expand Down
17 changes: 13 additions & 4 deletions conans/test/unittests/model/build_info_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def cpp_info_system_deps_test(self):
info["LIB2"].system_deps = ["sys2"]
info["LIB1"].deps = ["LIB3"]
danimtb marked this conversation as resolved.
Show resolved Hide resolved
info["LIB3"].system_deps = ["sys3", "sys2"]
self.assertEqual(['sys2', 'sys3', 'sys1', 'sys11'], info.libs)
self.assertEqual(['sys3', 'sys2', 'sys1', 'sys11'], info.libs)
info["LIB3"].system_deps = [None, "sys2"]
self.assertEqual(['sys2', 'sys1', 'sys11'], info.libs)

Expand All @@ -241,15 +241,16 @@ def cpp_info_libs_system_deps_order_test(self):
info["LIB1"].deps = ["LIB2"]
info["LIB2"].lib = "lib2"
info["LIB2"].system_deps = ["sys2"]
info["LIB1"].deps = ["LIB3"]
info["LIB2"].deps = ["LIB3"]
info["LIB3"].lib = "lib3"
info["LIB3"].system_deps = ["sys3", "sys2"]
self.assertEqual(['sys2', 'lib2', 'sys3', 'lib3', 'sys1', 'sys11', 'lib1'], info.libs)
self.assertEqual(['sys2', 'sys3', 'sys1', 'sys11'], info.system_deps)
self.assertEqual(['sys3', 'sys2', 'lib3', 'lib2', 'sys1', 'sys11', 'lib1'], info.libs)
self.assertEqual(['sys3', 'sys2', 'sys1', 'sys11'], info.system_deps)

def cpp_info_link_order_test(self):

def _assert_link_order(sorted_libs):
assert sorted_libs, "'sorted_libs' is empty"
for num, lib in enumerate(sorted_libs):
component_name = lib[-1]
for dep in info[component_name].deps:
Expand Down Expand Up @@ -297,6 +298,14 @@ def _assert_link_order(sorted_libs):
info["B"].deps = []
_assert_link_order(info.libs)

def cppinfo_inexistent_component_dep_test(self):
info = CppInfo(None)
info["LIB1"].lib = "lib1"
info["LIB1"].deps = ["LIB2"]
with six.assertRaisesRegex(self, ConanException, "Component 'LIB2' not found in cpp_info "
"object"):
info.libs

def cppinfo_dirs_test(self):
folder = temp_folder()
info = CppInfo(folder)
Expand Down