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

cpp_info components #5408

Closed
wants to merge 149 commits into from
Closed
Show file tree
Hide file tree
Changes from 127 commits
Commits
Show all changes
149 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
6d4898a
Added cpp_info interface test + deprecation assert tweak
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
b17f823
Merge branch 'feature/5090' into feature/5090b
danimtb Jun 25, 2019
2273c62
Refactor DepCppInfo and CppInfo
danimtb Jun 27, 2019
6030868
Merge branch 'develop' into feature/5090b
danimtb Jun 27, 2019
a32a354
added dirs
danimtb Jun 27, 2019
91ac38b
added deps_cpp_info rootpaths
danimtb Jun 27, 2019
87aa4b9
added version and description
danimtb Jun 27, 2019
c06bcb5
Protect public_deps
danimtb Jun 27, 2019
ad6ef1c
Added json conversion
danimtb Jun 27, 2019
1fd57c2
revert deprecation warning
danimtb Jun 27, 2019
3043d0d
fixed deprecration warning assert
danimtb Jun 27, 2019
3883c1d
fix issue withabslute paths in linux
danimtb Jun 27, 2019
c671b83
fix another linux path issue
danimtb Jun 27, 2019
d2a169a
fix boost build test
danimtb Jun 27, 2019
3c3a955
fix other b2 test
danimtb Jun 27, 2019
b4328a7
fix cmake multi
danimtb Jun 27, 2019
dcaf7c6
revert protected _version, _description and _public_deps
danimtb Jun 27, 2019
390fdc9
fix protected attributes in installer
danimtb Jun 27, 2019
3f19440
fix compiler args test
danimtb Jun 27, 2019
654f096
remove comments
danimtb Jun 27, 2019
06f60b2
fix pkg_config test
danimtb Jun 27, 2019
6f0ef7e
fix premake test
danimtb Jun 27, 2019
3b35ffb
fix sysroot partially
danimtb Jun 28, 2019
fe4bcaf
fix scons partially
danimtb Jun 28, 2019
7442fb9
Added sysroot unit test
danimtb Jun 28, 2019
04f58c7
revert sysroot flag in tests
danimtb Jun 28, 2019
8835f62
fix interface test for sysroot
danimtb Jun 28, 2019
86a8643
fix cpp_info in cppflags test
danimtb Jun 28, 2019
ac59597
added cflags unit test
danimtb Jun 28, 2019
cb85171
fixes backwards comp
danimtb Jun 30, 2019
4ec7be0
fix test
danimtb Jun 30, 2019
90d23a0
fix flags and defines in reverse order
danimtb Jul 1, 2019
c742157
revert check for version and description in json
danimtb Jul 1, 2019
a7a6dff
fix list copy
danimtb Jul 1, 2019
67c1dcd
revert changes in test for flags order
danimtb Jul 1, 2019
3a3b7cd
bring back description field in json and remove print
danimtb Jul 1, 2019
00d929c
fix py3 test
danimtb Jul 1, 2019
f59ed93
remove prints
danimtb Jul 1, 2019
68c877f
redo test with text generator
danimtb Jul 1, 2019
1497ab8
Added comments
danimtb Jul 1, 2019
9d79323
Added unit test with component and configuration
danimtb Jul 1, 2019
b4755b7
docstrings
danimtb Jul 1, 2019
46eb33a
fix json test
danimtb Jul 1, 2019
4609c2f
fix text generator test
danimtb Jul 1, 2019
c8444e2
fix sysroot loading in txt generator
danimtb Jul 1, 2019
c8382ef
fix sysroot test
danimtb Jul 1, 2019
663fe0a
revert filter_empty
danimtb Jul 1, 2019
68466ec
Assign cpp_info.name inside update()
danimtb Jul 1, 2019
3ff43ea
revert json null values
danimtb Jul 2, 2019
ce00092
filter_empty=False not needed
danimtb Jul 2, 2019
e9311c6
review
danimtb Jul 2, 2019
868ff15
filter_empty not needed
danimtb Jul 2, 2019
6ea072f
typos
danimtb Jul 2, 2019
ab9a3e8
fix boost generator tests
danimtb Jul 2, 2019
ccea5e9
fix python 3
danimtb Jul 2, 2019
293a566
enhanced test
danimtb Jul 2, 2019
98530c7
fix dirs and paths in the + dependent to -
danimtb Jul 2, 2019
a778dad
Make paths in test compatible with linux
danimtb Jul 2, 2019
42b69f9
keep same order
danimtb Jul 2, 2019
4b388d1
Added consumer diamond test
danimtb Jul 3, 2019
f7e76e4
fix order of deps_cpp_info in TXTGenerator.load()
danimtb Jul 3, 2019
f3049e7
simplify with setdefault
danimtb Jul 4, 2019
2c54491
Fix CMakeMulti generator
danimtb Jul 5, 2019
80d30ab
minor changes
danimtb Jul 8, 2019
ee2d0cf
Raise with global values and components and fix test
danimtb Jul 8, 2019
4a64b7c
Merge branch 'develop' into feature/5090b
danimtb Jul 16, 2019
368518f
return components.items()
danimtb Jul 16, 2019
3be683b
fix components items test
danimtb Jul 16, 2019
1afc3d8
test abslute paths too
danimtb Jul 16, 2019
b13d7c9
Added docstrings
danimtb Jul 16, 2019
8a4d827
bring isabs() check back
danimtb Jul 16, 2019
417c9ab
Revert "bring isabs() check back"
danimtb Jul 16, 2019
20138fc
fix abs path test
danimtb Jul 16, 2019
6b9028f
revert absloute path to test and make textgenerator handle abslute paths
danimtb Jul 16, 2019
a0aca26
fix abs paths in linux tests
danimtb Jul 16, 2019
0ccae68
fix generator abs paths
danimtb Jul 16, 2019
997bea3
fix assertion in test
danimtb Jul 17, 2019
588e283
fix unrelated test
danimtb Jul 17, 2019
a1e1754
fix test name
danimtb Jul 17, 2019
38fcb23
renamed dir_name and added docstring
danimtb Jul 17, 2019
b0377ac
improved dosctring for param path_name & renamed _filter_paths and ad…
danimtb Jul 17, 2019
1f2b7fe
added docstring for _sorted_components
danimtb Jul 17, 2019
5cea0ce
Added clarification about None
danimtb Jul 17, 2019
aeedb5b
renamed _get_dirs and _get_paths and added docstring
danimtb Jul 17, 2019
f492491
Added docstring to _get_flags
danimtb Jul 17, 2019
114a41d
include additional assert with fixed libs order from components
danimtb Jul 17, 2019
7540838
move result
danimtb Jul 18, 2019
0c03036
DepCppInfo init vars and cache them
danimtb Jul 18, 2019
29b2b81
removed import
danimtb Jul 18, 2019
89c378a
Use internal component for DepComponent
danimtb Jul 18, 2019
5a0ca0f
fix includedirs
danimtb Jul 18, 2019
ae760f5
remove default values check
danimtb Jul 18, 2019
9068b8d
reduce list in sorting algorithm
danimtb Jul 19, 2019
994b14f
line lenght
danimtb Jul 19, 2019
b959969
small fix
danimtb Jul 19, 2019
53b2102
one location for DEFAULT constants
danimtb Jul 19, 2019
d90721e
imports and identation
danimtb Jul 19, 2019
f34fc6d
revert test
danimtb Jul 19, 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
11 changes: 7 additions & 4 deletions conans/client/generators/cmake_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
cmake_package_info, cmake_user_info_vars,
generate_targets_section)
from conans.model import Generator
from conans.model.build_info import CppInfo
from conans.model.build_info import CppInfo, DepCppInfo, DepsCppInfo


def extend(cpp_info, config):
Expand All @@ -26,7 +26,7 @@ def add_lists(seq1, seq2):
result.cxxflags = cpp_info.cxxflags + config_info.cxxflags
result.sharedlinkflags = cpp_info.sharedlinkflags + config_info.sharedlinkflags
result.exelinkflags = cpp_info.exelinkflags + config_info.exelinkflags
return result
return DepCppInfo(result)
return cpp_info


Expand All @@ -45,23 +45,26 @@ def filename(self):

def _content_type(self, build_type):
sections = []
global_deps_cpp_info = DepsCppInfo()

# Per requirement variables
for dep_name, dep_cpp_info in self.deps_build_info.dependencies:

# Only the specific of the build_type
dep_cpp_info = extend(dep_cpp_info, build_type)
deps = DepsCppCmake(dep_cpp_info)
dep_flags = cmake_dependency_vars(dep_name, deps=deps, build_type=build_type)
sections.append(dep_flags)
# Store the extended DepCppInfos for global variables
global_deps_cpp_info.update_dep_cpp_info(dep_cpp_info, dep_name)

# GENERAL VARIABLES
sections.append("\n### Definition of global aggregated variables ###\n")
all_flags = cmake_dependencies(dependencies=self.deps_build_info.deps,
build_type=build_type)
sections.append(all_flags)

dep_cpp_info = extend(self.deps_build_info, build_type)
deps = DepsCppCmake(dep_cpp_info)
deps = DepsCppCmake(global_deps_cpp_info)
all_flags = cmake_global_vars(deps=deps, build_type=build_type)
sections.append(all_flags)

Expand Down
6 changes: 1 addition & 5 deletions conans/client/generators/json_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ def get_deps_user_info(self):
def get_dependencies_info(self):
res = []
for depname, cpp_info in self.deps_build_info.dependencies:
serialized_info = serialize_cpp_info(cpp_info)
serialized_info["name"] = depname
for cfg, cfg_cpp_info in cpp_info.configs.items():
serialized_info.setdefault("configs", {})[cfg] = serialize_cpp_info(cfg_cpp_info)
res.append(serialized_info)
res.append(cpp_info.as_dict())
return res

def get_settings(self):
Expand Down
37 changes: 32 additions & 5 deletions conans/client/generators/text.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import re
import traceback
from collections import defaultdict
from collections import OrderedDict, defaultdict

from conans.errors import ConanException
from conans.model import Generator
Expand All @@ -11,6 +12,13 @@
from conans.util.log import logger


class OrderedDefaultDict(OrderedDict):

def __missing__(self, key):
self[key] = value = defaultdict(dict)
danimtb marked this conversation as resolved.
Show resolved Hide resolved
return value


class DepsCppTXT(object):
def __init__(self, cpp_info):
self.include_paths = "\n".join(p.replace("\\", "/")
Expand Down Expand Up @@ -87,7 +95,7 @@ def _loads_cpp_info(text):

try:
# Parse the text
data = defaultdict(lambda: defaultdict(dict))
data = OrderedDefaultDict()
for m in pattern.finditer(text):
var_name = m.group(1)
lines = []
Expand Down Expand Up @@ -115,17 +123,36 @@ def _loads_cpp_info(text):
deps_cpp_info = DepsCppInfo()
for dep, configs_cpp_info in data.items():
if dep is None:
cpp_info = deps_cpp_info
continue
Copy link
Member

Choose a reason for hiding this comment

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

I would say this is also changing behavior, and it won't be recovering the data for the aggregated variables.
Why changing it? Seems risky.

Copy link
Member Author

Choose a reason for hiding this comment

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

Aggregated variables are recovered and composed of the values gathered from each dependency. So no need to read them or recover, as they will be composed when requested.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please put a comment there: "None correspond to the aggregated values from all the dependencies, we can skip it because we are assigning the dependencies individually and can get the aggregated value"

else:
cpp_info = deps_cpp_info._dependencies.setdefault(dep, CppInfo(root_folder=""))
root_path = configs_cpp_info[None]["rootpath"][0] # Get general rootpath
cpp_info = CppInfo(root_path)
cpp_info.filter_empty = False

for config, fields in configs_cpp_info.items():
item_to_apply = cpp_info if not config else getattr(cpp_info, config)

for key, value in fields.items():
if key in ['rootpath', 'sysroot']:
if key == 'rootpath':
continue
if key == 'sysroot':
value = value[0]
if key in ["includedirs", "libdirs", "bindirs", "builddirs", "srcdirs",
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure why this is being changed, and why this processing is necessary now. Any idea @lasote?

Copy link
Contributor

@lasote lasote Jul 29, 2019

Choose a reason for hiding this comment

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

I would say previously you were getting the aggregated info and now it is getting the components info to aggregate it later.

"resdirs"]:
# Convert absolute paths to relative if root_path is inside the path
saved_values = value
value = []
for val in saved_values:
try:
rel_path = os.path.relpath(val, root_path)
if ".." in rel_path:
value.append(val)
else:
value.append(rel_path)
except ValueError:
value.append(val)
setattr(item_to_apply, key, value)
deps_cpp_info.update(cpp_info, dep)
return deps_cpp_info

except Exception as e:
Expand Down
1 change: 1 addition & 0 deletions conans/client/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ def _propagate_info(node):

def _call_package_info(self, conanfile, package_folder, ref):
conanfile.cpp_info = CppInfo(package_folder)
conanfile.cpp_info.name = conanfile.name
Copy link
Member Author

Choose a reason for hiding this comment

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

This name has to be assigned here before so the user can later change this name and the value is preserved. Setting this name in deps_cpp_info.update() will overwrite the name value when the info is propagated

conanfile.cpp_info.version = conanfile.version
conanfile.cpp_info.description = conanfile.description
conanfile.env_info = EnvInfo()
Expand Down
19 changes: 1 addition & 18 deletions conans/client/recorder/action_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,6 @@
INSTALL_ERROR_BUILDING = "building"


def _cpp_info_to_dict(cpp_info):
doc = {}
for it, value in vars(cpp_info).items():
if it.startswith("_") or not value:
continue

if it == "configs":
configs_data = {}
for cfg_name, cfg_cpp_info in value.items():
configs_data[cfg_name] = _cpp_info_to_dict(cfg_cpp_info)
doc["configs"] = configs_data
continue

doc[it] = value
return doc


class Action(namedtuple("Action", "type, full_ref, doc, time")):

def __new__(cls, the_type, full_ref, doc=None):
Expand Down Expand Up @@ -112,7 +95,7 @@ def package_install_error(self, pref, error_type, description, remote_name=None)
def package_cpp_info(self, pref, cpp_info):
assert isinstance(pref, PackageReference)
# assert isinstance(cpp_info, CppInfo)
self._inst_packages_info[pref.copy_clear_revs()]['cpp_info'] = _cpp_info_to_dict(cpp_info)
self._inst_packages_info[pref.copy_clear_revs()]['cpp_info'] = cpp_info.as_dict()

@property
def install_errored(self):
Expand Down
Loading