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

Use cpp_info.frameworks instead of cpp_info.exe_link_flags #113

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
6 changes: 6 additions & 0 deletions hooks/conan-center.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"KB-H029": "TEST PACKAGE - RUN ENVIRONMENT",
"KB-H030": "CONANDATA.YML FORMAT",
"KB-H031": "CONANDATA.YML REDUCE",
"KB-H033": "APPLE FRAMEWORK",
"KB-H037": "NO AUTHOR",
}

Expand Down Expand Up @@ -276,6 +277,11 @@ def test(out):
out.error("The 'RunEnvironment()' build helper is no longer needed. "
"It has been integrated into the self.run(..., run_environment=True)")

@run_test("KB-H033", output)
def test(out):
if "cpp_info.shared_link_flags" in conanfile_content and "-framework" in conanfile_content:
Copy link
Contributor

Choose a reason for hiding this comment

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

that might trigger false positives, need to reduce scope of test

Copy link
Member Author

Choose a reason for hiding this comment

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

can you elaborate some idea?

Copy link
Contributor

Choose a reason for hiding this comment

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

having something like:

self.cpp_info.shared_link_flags = ["-B,Symbolic"]
...
tools.replace_in_file("Makefile", "-framework Foundation", "-framework CoreFoundation")

will result in false positive I believe

out.error("Apple Frameworks should be packaged using 'self.cpp_info.frameworks'")

@run_test("KB-H030", output)
def test(out):
conandata_path = os.path.join(export_folder_path, "conandata.yml")
Expand Down
34 changes: 26 additions & 8 deletions tests/test_hooks/conan-center/test_conan-center.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,7 @@ def test(self):
output = self.conan(['create', '.', 'name/version@user/test'])
self.assertIn("[CMAKE MINIMUM VERSION (KB-H028)] OK", output)
self.assertNotIn("ERROR [CMAKE MINIMUM VERSION (KB-H028)]", output)

cmake = textwrap.dedent("""CMAKE_MINIMUM_REQUIRED (VERSION 2.8.11)
project(test)
""")
tools.save('CMakeLists.txt', content=cmake)
output = self.conan(['create', '.', 'name/version@user/test'])
self.assertIn("[CMAKE MINIMUM VERSION (KB-H028)] OK", output)


cmake = textwrap.dedent("""cmake_minimum_required(VERSION 2.8.11)
project(test)
""")
Expand All @@ -441,6 +434,31 @@ def test(self):
self.assertIn("[CMAKE MINIMUM VERSION (KB-H028)] OK", output)
self.assertNotIn("ERROR [CMAKE MINIMUM VERSION (KB-H028)]", output)

def test_apple_frameworks(self):
conanfile = textwrap.dedent("""\
from conans import ConanFile
class AConan(ConanFile):
url = "https://github.com/conan-io/conan-center-index"
license = "fake_license"
description = "whatever"
exports_sources = "header.h"
def package(self):
self.copy("*", dst="include")
def cpp_info(self):
self.cpp_info.""")

inv_conanfile = conanfile + 'shared_link_flags.append("-framework CoreAudio")'
tools.save('conanfile.py', content=inv_conanfile)
output = self.conan(['create', '.', 'name/version@user/test'])
self.assertIn("ERROR: [APPLE FRAMEWORK (KB-H033)] Apple Frameworks should be packaged " \
"using 'self.cpp_info.frameworks'", output)

val_conanfile = conanfile + 'frameworks.append("CoreAudio")'
tools.save('conanfile.py', content=val_conanfile)
output = self.conan(['create', '.', 'name/version@user/test'])
self.assertIn("[APPLE FRAMEWORK (KB-H033)] OK", output)


def test_no_author(self):
conanfile = textwrap.dedent("""\
from conans import ConanFile
Expand Down