Skip to content

Commit

Permalink
Update cpp_info.cppflags -> cpp_info.cxxflags
Browse files Browse the repository at this point in the history
Deprecated since 1.13.0

conan-io/conan#4611
conan-io/docs#1091
  • Loading branch information
Croydon committed Apr 10, 2019
1 parent eee729c commit 3a89590
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
16 changes: 16 additions & 0 deletions bincrafters_conventions/actions/update_c_deprecated_attributes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
def update_c_deprecated_attributes(main, file):
conanfile = open(file, 'r')
recipe = conanfile.read()
conanfile.close()

deprecations = { # Official Conan attributes
"self.cpp_info.cppflags": "self.cpp_info.cxxflags",
# Custom attributes
}

for deprecated, replacement in deprecations.items():
if deprecated in recipe:
if main.replace_in_file(file, deprecated, replacement):
main.output_result_update(title="Replace deprecated attribute {} with {}".format(deprecated, recipe))
return True
return True
6 changes: 4 additions & 2 deletions bincrafters_conventions/bincrafters_conventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from .actions.update_a_python_version import update_a_python_version
from .actions.update_a_path_manipulation import update_a_path_manipulation
from .actions.update_a_python_environment_variable import update_a_python_environment_variable
from .actions.update_c_deprecated_attributes import update_c_deprecated_attributes
from .actions.update_c_openssl_version_patch import update_c_openssl_version_patch
from .actions.update_c_generic_exception_to_invalid_conf import update_c_generic_exception_to_invalid_conf
from .actions.update_c_install_subfolder import update_c_install_subfolder
Expand All @@ -37,7 +38,7 @@
from .actions.update_other_pyenv_python_version import update_other_pyenv_python_version


__version__ = '0.5.2'
__version__ = '0.5.3'
__author__ = 'Bincrafters <bincrafters@gmail.com>'
__license__ = 'MIT'

Expand Down Expand Up @@ -289,7 +290,8 @@ def _update_conanfile(self, conanfile):
:param conanfile: Conan recipe path
:return:
"""
return (update_c_default_options_to_dict(self, conanfile),
return (update_c_deprecated_attributes(self, conanfile),
update_c_default_options_to_dict(self, conanfile),
update_c_generic_exception_to_invalid_conf(self, conanfile),
update_c_configure_cmake(self, conanfile),
update_c_source_subfolder(self, conanfile),
Expand Down
9 changes: 6 additions & 3 deletions tests/test_update_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ def package(self):
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.cxxflags = ["-pthread"]
"""

CONAN_FILE_OLD = """#!/usr/bin/env python
Expand Down Expand Up @@ -373,6 +374,7 @@ def package(self):
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.cppflags = ["-pthread"]
"""

CONAN_FILE_OLD_MULTILINE = """#!/usr/bin/env python
Expand Down Expand Up @@ -432,6 +434,7 @@ def package(self):
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.cppflags = ["-pthread"]
"""

APPVEYOR_FILE = """build: false
Expand Down Expand Up @@ -514,7 +517,7 @@ def test_update_travis_file():


def test_updated_conanfile():
""" Try to update an up-to-date file
""" Try to update an already up-to-date file, nothing should change
"""
_, conan_path = tempfile.mkstemp(prefix='conanfile', suffix='.py')
with open(conan_path, 'w') as file:
Expand All @@ -532,7 +535,7 @@ def test_updated_conanfile():


def test_conanfile_default_options():
""" Try to update an up-to-date file
""" Try to update an conanfile which has old styled default options
"""
_, conan_path = tempfile.mkstemp(prefix='conanfile', suffix='.py')
with open(conan_path, 'w') as file:
Expand All @@ -550,7 +553,7 @@ def test_conanfile_default_options():


def test_conanfile_default_options_mutiline():
""" Try to update an up-to-date file
""" Try to update an conanfile which has old styled multiline default options
"""
_, conan_path = tempfile.mkstemp(prefix='conanfile', suffix='.py')
with open(conan_path, 'w') as file:
Expand Down

0 comments on commit 3a89590

Please sign in to comment.