Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.
6 changes: 6 additions & 0 deletions hooks/conan-center.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"KB-H030": "CONANDATA.YML FORMAT",
"KB-H031": "CONANDATA.YML REDUCE",
"KB-H032": "SYSTEM REQUIREMENTS",
"KB-H033": "APPLE FRAMEWORK",
"KB-H034": "TEST PACKAGE - NO IMPORTS()",
"KB-H037": "NO AUTHOR",
"KB-H040": "NO TARGET NAME",
Expand Down Expand Up @@ -346,6 +347,11 @@ def test(out):
(match and "{}.install".format(match.group(1)) in conanfile_content):
out.error("The method 'SystemPackageTool.install' is not allowed in the recipe.")

@run_test("KB-H033", output)
def test(out):
if "cpp_info.shared_link_flags" in conanfile_content and "-framework" in conanfile_content:
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
25 changes: 25 additions & 0 deletions tests/test_hooks/conan-center/test_conan-center.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ def test(self):
# validate residual cmake files in test_package/build
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)
Expand Down Expand Up @@ -604,6 +605,30 @@ def system_requirements(self):
self.assertIn("[SYSTEM REQUIREMENTS (KB-H032)] 'libusb' is part of the allowlist.", output)
self.assertNotIn("ERROR: [SYSTEM REQUIREMENTS (KB-H032)]", 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_imports_not_allowed(self):
conanfile_tp = textwrap.dedent("""\
from conans import ConanFile, tools
Expand Down