diff --git a/hooks/conan-center.py b/hooks/conan-center.py index b0b7b52f..15dae498 100644 --- a/hooks/conan-center.py +++ b/hooks/conan-center.py @@ -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", @@ -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: + 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") diff --git a/tests/test_hooks/conan-center/test_conan-center.py b/tests/test_hooks/conan-center/test_conan-center.py index 8f8e7cc2..16418bb0 100644 --- a/tests/test_hooks/conan-center/test_conan-center.py +++ b/tests/test_hooks/conan-center/test_conan-center.py @@ -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) @@ -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