Ejemplo n.º 1
0
 def help_test(self):
     deps_env_info = DepsEnvInfo()
     deps_cpp_info = DepsCppInfo()
     deps_cpp_info.includedirs.append("C:/whatever")
     deps_cpp_info.includedirs.append("C:/whenever")
     deps_cpp_info.libdirs.append("C:/other")
     deps_cpp_info.libs.extend(["math", "winsock", "boost"])
     child = DepsCppInfo()
     child.includedirs.append("F:/ChildrenPath")
     child.cppflags.append("cxxmyflag")
     deps_cpp_info._dependencies["Boost"] = child
     fakeconan = namedtuple("Conanfile", "deps_cpp_info cpp_info deps_env_info env_info")
     output = TXTGenerator(fakeconan(deps_cpp_info, None, deps_env_info, None)).content
     deps_cpp_info2 = DepsCppInfo.loads(output)
     self.assertEqual(deps_cpp_info.configs, deps_cpp_info2.configs)
     self.assertEqual(deps_cpp_info.includedirs, deps_cpp_info2.includedirs)
     self.assertEqual(deps_cpp_info.libdirs, deps_cpp_info2.libdirs)
     self.assertEqual(deps_cpp_info.bindirs, deps_cpp_info2.bindirs)
     self.assertEqual(deps_cpp_info.libs, deps_cpp_info2.libs)
     self.assertEqual(len(deps_cpp_info._dependencies),
                      len(deps_cpp_info2._dependencies))
     self.assertEqual(deps_cpp_info["Boost"].includedirs,
                      deps_cpp_info2["Boost"].includedirs)
     self.assertEqual(deps_cpp_info["Boost"].cppflags,
                      deps_cpp_info2["Boost"].cppflags)
     self.assertEqual(deps_cpp_info["Boost"].cppflags, ["cxxmyflag"])
Ejemplo n.º 2
0
 def test_cpp_info_build_modules(self):
     folder = temp_folder()
     info = CppInfo("myname", folder)
     info.build_modules.append(
         "old.cmake")  # Test old behavior with .cmake build modules
     info.build_modules.extend(["other_old.cmake",
                                "file.pc"])  # .pc not considered
     info.build_modules["generator"].append("my_module.cmake")
     info.debug.build_modules["other_gen"] = ["mod-release.cmake"]
     deps_cpp_info = DepsCppInfo()
     deps_cpp_info.add("myname", DepCppInfo(info))
     for gen in [
             "cmake", "cmake_multi", "cmake_find_package",
             "cmake_find_package_multi"
     ]:
         self.assertListEqual([
             os.path.join(folder, "old.cmake"),
             os.path.join(folder, "other_old.cmake")
         ], list(deps_cpp_info["myname"].build_modules_paths[gen]))
     self.assertListEqual(
         [os.path.join(folder, "my_module.cmake")],
         list(deps_cpp_info["myname"].build_modules_paths["generator"]))
     self.assertListEqual([
         os.path.join(folder, "mod-release.cmake")
     ], list(
         deps_cpp_info["myname"].debug.build_modules_paths["other_gen"]))
Ejemplo n.º 3
0
    def help_test(self):
        deps_env_info = DepsEnvInfo()
        deps_cpp_info = DepsCppInfo()

        child = CppInfo("Boost", "F:")
        child.filter_empty = False
        child.includedirs.append("ChildrenPath")
        child.cxxflags.append("cxxmyflag")
        deps_cpp_info.add("Boost", DepCppInfo(child))

        fakeconan = namedtuple(
            "Conanfile",
            "deps_cpp_info cpp_info deps_env_info env_info user_info deps_user_info"
        )
        output = TXTGenerator(
            fakeconan(deps_cpp_info, None, deps_env_info, None, {},
                      defaultdict(dict))).content
        deps_cpp_info2, _, _, _ = TXTGenerator.loads(output)
        self.assertEqual(deps_cpp_info.configs, deps_cpp_info2.configs)
        self.assertEqual(deps_cpp_info.includedirs, deps_cpp_info2.includedirs)
        self.assertEqual(deps_cpp_info.libdirs, deps_cpp_info2.libdirs)
        self.assertEqual(deps_cpp_info.bindirs, deps_cpp_info2.bindirs)
        self.assertEqual(deps_cpp_info.libs, deps_cpp_info2.libs)
        self.assertEqual(len(deps_cpp_info._dependencies),
                         len(deps_cpp_info2._dependencies))
        self.assertEqual(deps_cpp_info["Boost"].includedirs,
                         deps_cpp_info2["Boost"].includedirs)
        self.assertEqual(deps_cpp_info["Boost"].cxxflags,
                         deps_cpp_info2["Boost"].cxxflags)
        self.assertEqual(deps_cpp_info["Boost"].cxxflags, ["cxxmyflag"])
Ejemplo n.º 4
0
 def help_test(self):
     deps_env_info = DepsEnvInfo()
     deps_cpp_info = DepsCppInfo()
     deps_cpp_info.includedirs.append("C:/whatever")
     deps_cpp_info.includedirs.append("C:/whenever")
     deps_cpp_info.libdirs.append("C:/other")
     deps_cpp_info.libs.extend(["math", "winsock", "boost"])
     child = DepsCppInfo()
     child.includedirs.append("F:/ChildrenPath")
     child.cppflags.append("cxxmyflag")
     deps_cpp_info._dependencies["Boost"] = child
     fakeconan = namedtuple(
         "Conanfile",
         "deps_cpp_info cpp_info deps_env_info env_info user_info deps_user_info"
     )
     output = TXTGenerator(
         fakeconan(deps_cpp_info, None, deps_env_info, None, {},
                   defaultdict(dict))).content
     deps_cpp_info2, _ = TXTGenerator.loads(output)
     self.assertEqual(deps_cpp_info.configs, deps_cpp_info2.configs)
     self.assertEqual(deps_cpp_info.includedirs, deps_cpp_info2.includedirs)
     self.assertEqual(deps_cpp_info.libdirs, deps_cpp_info2.libdirs)
     self.assertEqual(deps_cpp_info.bindirs, deps_cpp_info2.bindirs)
     self.assertEqual(deps_cpp_info.libs, deps_cpp_info2.libs)
     self.assertEqual(len(deps_cpp_info._dependencies),
                      len(deps_cpp_info2._dependencies))
     self.assertEqual(deps_cpp_info["Boost"].includedirs,
                      deps_cpp_info2["Boost"].includedirs)
     self.assertEqual(deps_cpp_info["Boost"].cppflags,
                      deps_cpp_info2["Boost"].cppflags)
     self.assertEqual(deps_cpp_info["Boost"].cppflags, ["cxxmyflag"])
Ejemplo n.º 5
0
 def cpp_info_name_test(self):
     folder = temp_folder()
     info = CppInfo(folder)
     info.name = "MyName"
     deps_cpp_info = DepsCppInfo()
     deps_cpp_info.update(info, "myname")
     self.assertIn("MyName", deps_cpp_info["myname"].name)
Ejemplo n.º 6
0
    def configs_test(self):
        deps_cpp_info = DepsCppInfo()
        deps_cpp_info.includedirs.append("C:/whatever")
        deps_cpp_info.debug.includedirs.append("C:/whenever")
        deps_cpp_info.libs.extend(["math"])
        deps_cpp_info.debug.libs.extend(["debug_Lib"])

        child = DepsCppInfo()
        child.includedirs.append("F:/ChildrenPath")
        child.debug.includedirs.append("F:/ChildrenDebugPath")
        child.cppflags.append("cxxmyflag")
        child.debug.cppflags.append("cxxmydebugflag")
        deps_cpp_info._dependencies["Boost"] = child

        deps_env_info = DepsEnvInfo()
        env_info_lib1 = EnvInfo()
        env_info_lib1.var = "32"
        env_info_lib1.othervar.append("somevalue")
        deps_env_info.update(env_info_lib1, "LIB1")

        deps_user_info = DepsUserInfo()
        deps_user_info["LIB2"].myuservar = "23"

        fakeconan = namedtuple("Conanfile", "deps_cpp_info cpp_info deps_env_info env_info user_info deps_user_info")
        output = TXTGenerator(fakeconan(deps_cpp_info, None, deps_env_info, deps_user_info, {}, defaultdict(dict))).content

        deps_cpp_info2, _, deps_env_info2 = TXTGenerator.loads(output)
        self.assertEqual(deps_cpp_info.includedirs, deps_cpp_info2.includedirs)
        self.assertEqual(deps_cpp_info.libdirs, deps_cpp_info2.libdirs)
        self.assertEqual(deps_cpp_info.bindirs, deps_cpp_info2.bindirs)
        self.assertEqual(deps_cpp_info.libs, deps_cpp_info2.libs)
        self.assertEqual(len(deps_cpp_info._dependencies),
                         len(deps_cpp_info2._dependencies))
        self.assertEqual(deps_cpp_info["Boost"].includedirs,
                         deps_cpp_info2["Boost"].includedirs)
        self.assertEqual(deps_cpp_info["Boost"].cppflags,
                         deps_cpp_info2["Boost"].cppflags)
        self.assertEqual(deps_cpp_info["Boost"].cppflags, ["cxxmyflag"])

        self.assertEqual(deps_cpp_info.debug.includedirs, deps_cpp_info2.debug.includedirs)
        self.assertEqual(deps_cpp_info.debug.includedirs, ["C:/whenever"])

        self.assertEqual(deps_cpp_info.debug.libs, deps_cpp_info2.debug.libs)
        self.assertEqual(deps_cpp_info.debug.libs, ["debug_Lib"])

        self.assertEqual(deps_cpp_info["Boost"].debug.includedirs,
                         deps_cpp_info2["Boost"].debug.includedirs)
        self.assertEqual(deps_cpp_info["Boost"].debug.includedirs,
                         ["F:/ChildrenDebugPath"])
        self.assertEqual(deps_cpp_info["Boost"].debug.cppflags,
                         deps_cpp_info2["Boost"].debug.cppflags)
        self.assertEqual(deps_cpp_info["Boost"].debug.cppflags, ["cxxmydebugflag"])

        self.assertEqual(deps_env_info["LIB1"].var, "32")
        self.assertEqual(deps_env_info["LIB1"].othervar, ["somevalue"])

        self.assertEqual(deps_user_info["LIB2"].myuservar, "23")
Ejemplo n.º 7
0
    def configs_test(self):
        deps_cpp_info = DepsCppInfo()
        deps_cpp_info.includedirs.append("C:/whatever")
        deps_cpp_info.debug.includedirs.append("C:/whenever")
        deps_cpp_info.libs.extend(["math"])
        deps_cpp_info.debug.libs.extend(["debug_Lib"])

        child = DepsCppInfo()
        child.includedirs.append("F:/ChildrenPath")
        child.debug.includedirs.append("F:/ChildrenDebugPath")
        child.cppflags.append("cxxmyflag")
        child.debug.cppflags.append("cxxmydebugflag")
        deps_cpp_info._dependencies["Boost"] = child

        deps_env_info = DepsEnvInfo()
        env_info_lib1 = EnvInfo()
        env_info_lib1.var = "32"
        env_info_lib1.othervar.append("somevalue")
        deps_env_info.update(env_info_lib1, "LIB1")

        deps_user_info = DepsUserInfo()
        deps_user_info["LIB2"].myuservar = "23"

        fakeconan = namedtuple("Conanfile", "deps_cpp_info cpp_info deps_env_info env_info user_info deps_user_info")
        output = TXTGenerator(fakeconan(deps_cpp_info, None, deps_env_info, deps_user_info, {}, defaultdict(dict))).content

        deps_cpp_info2, _, deps_env_info2 = TXTGenerator.loads(output)
        self.assertEqual(deps_cpp_info.includedirs, deps_cpp_info2.includedirs)
        self.assertEqual(deps_cpp_info.libdirs, deps_cpp_info2.libdirs)
        self.assertEqual(deps_cpp_info.bindirs, deps_cpp_info2.bindirs)
        self.assertEqual(deps_cpp_info.libs, deps_cpp_info2.libs)
        self.assertEqual(len(deps_cpp_info._dependencies),
                         len(deps_cpp_info2._dependencies))
        self.assertEqual(deps_cpp_info["Boost"].includedirs,
                         deps_cpp_info2["Boost"].includedirs)
        self.assertEqual(deps_cpp_info["Boost"].cppflags,
                         deps_cpp_info2["Boost"].cppflags)
        self.assertEqual(deps_cpp_info["Boost"].cppflags, ["cxxmyflag"])

        self.assertEqual(deps_cpp_info.debug.includedirs, deps_cpp_info2.debug.includedirs)
        self.assertEqual(deps_cpp_info.debug.includedirs, ["C:/whenever"])

        self.assertEqual(deps_cpp_info.debug.libs, deps_cpp_info2.debug.libs)
        self.assertEqual(deps_cpp_info.debug.libs, ["debug_Lib"])

        self.assertEqual(deps_cpp_info["Boost"].debug.includedirs,
                         deps_cpp_info2["Boost"].debug.includedirs)
        self.assertEqual(deps_cpp_info["Boost"].debug.includedirs,
                         ["F:/ChildrenDebugPath"])
        self.assertEqual(deps_cpp_info["Boost"].debug.cppflags,
                         deps_cpp_info2["Boost"].debug.cppflags)
        self.assertEqual(deps_cpp_info["Boost"].debug.cppflags, ["cxxmydebugflag"])

        self.assertEqual(deps_env_info["LIB1"].var, "32")
        self.assertEqual(deps_env_info["LIB1"].othervar, ["somevalue"])

        self.assertEqual(deps_user_info["LIB2"].myuservar, "23")
Ejemplo n.º 8
0
 def cpp_info_name_test(self):
     folder = temp_folder()
     info = CppInfo("myname", folder)
     info.name = "MyName"
     info.names["my_generator"] = "MyNameForMyGenerator"
     deps_cpp_info = DepsCppInfo()
     deps_cpp_info.add("myname", DepCppInfo(info))
     self.assertIn("MyName", deps_cpp_info["myname"].get_name("my_undefined_generator"))
     self.assertIn("MyNameForMyGenerator", deps_cpp_info["myname"].get_name("my_generator"))
Ejemplo n.º 9
0
    def configs_test(self):
        deps_cpp_info = DepsCppInfo()
        deps_cpp_info.filter_empty = False
        child = CppInfo("Boost", "F:/")
        child.filter_empty = False
        child.version = "<version>"
        child.includedirs.append("ChildrenPath")
        child.debug.includedirs.append("ChildrenDebugPath")
        child.cxxflags.append("cxxmyflag")
        child.debug.cxxflags.append("cxxmydebugflag")
        child.libs.extend(["math"])
        child.debug.libs.extend(["debug_Lib"])
        deps_cpp_info.add("Boost", DepCppInfo(child))

        deps_env_info = DepsEnvInfo()
        env_info_lib1 = EnvInfo()
        env_info_lib1.var = "32"
        env_info_lib1.othervar.append("somevalue")
        deps_env_info.update(env_info_lib1, "LIB1")

        deps_user_info = DepsUserInfo()
        deps_user_info["LIB2"].myuservar = "23"

        fakeconan = namedtuple("Conanfile", "deps_cpp_info cpp_info deps_env_info env_info user_info deps_user_info")
        output = TXTGenerator(fakeconan(deps_cpp_info, None, deps_env_info, deps_user_info, {}, defaultdict(dict))).content

        deps_cpp_info2, _, deps_env_info2, _ = TXTGenerator.loads(output, filter_empty=False)
        self.assertEqual(deps_cpp_info.includedirs, deps_cpp_info2.includedirs)
        self.assertEqual(deps_cpp_info.libdirs, deps_cpp_info2.libdirs)
        self.assertEqual(deps_cpp_info.bindirs, deps_cpp_info2.bindirs)
        self.assertEqual(deps_cpp_info.libs, deps_cpp_info2.libs)
        self.assertEqual(len(deps_cpp_info._dependencies),
                         len(deps_cpp_info2._dependencies))
        self.assertEqual(deps_cpp_info["Boost"].includedirs,
                         deps_cpp_info2["Boost"].includedirs)
        self.assertEqual(deps_cpp_info["Boost"].cxxflags,
                         deps_cpp_info2["Boost"].cxxflags)
        self.assertEqual(deps_cpp_info["Boost"].cxxflags, ["cxxmyflag"])

        self.assertEqual(deps_cpp_info.debug.includedirs, deps_cpp_info2.debug.includedirs)
        self.assertEqual(deps_cpp_info.debug.includedirs, ['F:/include', 'F:/ChildrenDebugPath'])

        self.assertEqual(deps_cpp_info.debug.libs, deps_cpp_info2.debug.libs)
        self.assertEqual(deps_cpp_info.debug.libs, ["debug_Lib"])

        self.assertEqual(deps_cpp_info["Boost"].debug.includedirs,
                         deps_cpp_info2["Boost"].debug.includedirs)
        self.assertEqual(deps_cpp_info["Boost"].debug.includedirs, ['include', 'ChildrenDebugPath'])
        self.assertEqual(deps_cpp_info["Boost"].debug.cxxflags,
                         deps_cpp_info2["Boost"].debug.cxxflags)
        self.assertEqual(deps_cpp_info["Boost"].debug.cxxflags, ["cxxmydebugflag"])

        self.assertEqual(deps_env_info["LIB1"].var, "32")
        self.assertEqual(deps_env_info["LIB1"].othervar, ["somevalue"])

        self.assertEqual(deps_user_info["LIB2"].myuservar, "23")
Ejemplo n.º 10
0
 def cpp_info_system_libs_test(self):
     info1 = CppInfo("dep1", "folder1")
     info1.system_libs = ["sysdep1"]
     info2 = CppInfo("dep2", "folder2")
     info2.system_libs = ["sysdep2", "sysdep3"]
     deps_cpp_info = DepsCppInfo()
     deps_cpp_info.add("dep1", DepCppInfo(info1))
     deps_cpp_info.add("dep2", DepCppInfo(info2))
     self.assertListEqual(["sysdep1", "sysdep2", "sysdep3"], list(deps_cpp_info.system_libs))
     self.assertListEqual(["sysdep1"], list(deps_cpp_info["dep1"].system_libs))
     self.assertListEqual(["sysdep2", "sysdep3"], list(deps_cpp_info["dep2"].system_libs))
Ejemplo n.º 11
0
 def cpp_info_build_modules_test(self):
     folder = temp_folder()
     info = CppInfo(folder)
     info.build_modules.append("my_module.cmake")
     info.debug.build_modules = ["mod-release.cmake"]
     deps_cpp_info = DepsCppInfo()
     deps_cpp_info.update(info, "myname")
     self.assertListEqual([os.path.join(folder, "my_module.cmake")],
                          deps_cpp_info["myname"].build_modules_paths)
     self.assertListEqual([os.path.join(folder, "mod-release.cmake")],
                          deps_cpp_info["myname"].debug.build_modules_paths)
Ejemplo n.º 12
0
 def cpp_info_system_libs_test(self):
     info1 = CppInfo("folder1")
     info1.system_libs = ["sysdep1"]
     info2 = CppInfo("folder2")
     info2.system_libs = ["sysdep2", "sysdep3"]
     deps_cpp_info = DepsCppInfo()
     deps_cpp_info.update(info1, "dep1")
     deps_cpp_info.update(info2, "dep2")
     self.assertEqual(["sysdep1", "sysdep2", "sysdep3"], deps_cpp_info.system_libs)
     self.assertEqual(["sysdep1"], deps_cpp_info["dep1"].system_libs)
     self.assertEqual(["sysdep2", "sysdep3"], deps_cpp_info["dep2"].system_libs)
Ejemplo n.º 13
0
 def test_cpp_info_build_modules(self):
     folder = temp_folder()
     info = CppInfo("myname", folder)
     info.build_modules.append("my_module.cmake")
     info.debug.build_modules = ["mod-release.cmake"]
     deps_cpp_info = DepsCppInfo()
     deps_cpp_info.add("myname", DepCppInfo(info))
     self.assertListEqual([os.path.join(folder, "my_module.cmake")],
                          list(deps_cpp_info["myname"].build_modules_paths))
     self.assertListEqual(
         [os.path.join(folder, "mod-release.cmake")],
         list(deps_cpp_info["myname"].debug.build_modules_paths))
Ejemplo n.º 14
0
 def help_test(self):
     imports = DepsCppInfo()
     imports.includedirs.append("C:/whatever")
     imports.includedirs.append("C:/whenever")
     imports.libdirs.append("C:/other")
     imports.libs.extend(["math", "winsock", "boost"])
     child = DepsCppInfo()
     child.includedirs.append("F:/ChildrenPath")
     child.cppflags.append("cxxmyflag")
     imports._dependencies["Boost"] = child
     output = repr(imports)
     imports2 = DepsCppInfo.loads(output)
     self._equal(imports, imports2)
Ejemplo n.º 15
0
 def help_test(self):
     imports = DepsCppInfo()
     imports.includedirs.append("C:/whatever")
     imports.includedirs.append("C:/whenever")
     imports.libdirs.append("C:/other")
     imports.libs.extend(["math", "winsock", "boost"])
     child = DepsCppInfo()
     child.includedirs.append("F:/ChildrenPath")
     child.cppflags.append("cxxmyflag")
     imports._dependencies["Boost"] = child
     output = repr(imports)
     imports2 = DepsCppInfo.loads(output)
     self._equal(imports, imports2)
Ejemplo n.º 16
0
 def test_deps_cpp_info_components_includedirs(self):
     info = CppInfo("my_lib", "root")
     info.components["component"].includedirs = ["include1", "include2"]
     info.components["component"].filter_empty = False
     dep_info = DepCppInfo(info)
     expected = [
         os.path.join("root", "include1"),
         os.path.join("root", "include2")
     ]
     self.assertListEqual(expected, list(dep_info.include_paths))
     deps_cpp_info = DepsCppInfo()
     deps_cpp_info.add("my_lib", dep_info)
     self.assertListEqual(expected, list(deps_cpp_info.includedirs))
Ejemplo n.º 17
0
 def help_test(self):
     deps_cpp_info = DepsCppInfo()
     deps_cpp_info.includedirs.append("C:/whatever")
     deps_cpp_info.includedirs.append("C:/whenever")
     deps_cpp_info.libdirs.append("C:/other")
     deps_cpp_info.libs.extend(["math", "winsock", "boost"])
     child = DepsCppInfo()
     child.includedirs.append("F:/ChildrenPath")
     child.cppflags.append("cxxmyflag")
     deps_cpp_info._dependencies["Boost"] = child
     fakeconan = namedtuple("Conanfile", "deps_cpp_info cpp_info")
     output = TXTGenerator(fakeconan(deps_cpp_info, None)).content
     deps_cpp_info2 = DepsCppInfo.loads(output)
     self._equal(deps_cpp_info, deps_cpp_info2)
Ejemplo n.º 18
0
 def deps_cpp_info_components_test(self):
     folder = temp_folder()
     info = CppInfo(folder)
     # Create file so path is not cleared
     save(os.path.join(folder, "include", "my_file.h"), "")
     info.components["Component"].libs = ["libcomp"]
     dep_info = DepCppInfo(info)
     deps_cpp_info = DepsCppInfo()
     deps_cpp_info.update(dep_info, "my_lib")
     self.assertListEqual(["libcomp"], deps_cpp_info.libs)
     self.assertListEqual(["libcomp"], deps_cpp_info["my_lib"].components["Component"].libs)
     self.assertListEqual([os.path.join(folder, "include")], deps_cpp_info.include_paths)
     self.assertListEqual([os.path.join(folder, "include")],
                          deps_cpp_info["my_lib"].components["Component"].include_paths)
Ejemplo n.º 19
0
 def test_cpp_info_build_modules_old_behavior(self):
     folder = temp_folder()
     info = CppInfo("myname", folder)
     info.build_modules = [
         "old.cmake"
     ]  # Test old behavior with .cmake build modules as list
     deps_cpp_info = DepsCppInfo()
     deps_cpp_info.add("myname", DepCppInfo(info))
     for gen in [
             "cmake", "cmake_multi", "cmake_find_package",
             "cmake_find_package_multi"
     ]:
         assert list(deps_cpp_info["myname"].build_modules_paths[gen]) ==\
                [os.path.join(folder, "old.cmake")]
Ejemplo n.º 20
0
 def component_default_dirs_deps_cpp_info_test(self):
     folder = temp_folder()
     info = CppInfo(folder)
     info.components["Component"]
     info.components["Component"].filter_empty = False  # For testing purposes
     dep_info = DepCppInfo(info)
     deps_cpp_info = DepsCppInfo()
     deps_cpp_info.update(dep_info, "my_lib")
     self.assertListEqual([os.path.join(folder, "include")], deps_cpp_info.includedirs)
     self.assertListEqual([], deps_cpp_info.srcdirs)
     self.assertListEqual([os.path.join(folder, "lib")], deps_cpp_info.libdirs)
     self.assertListEqual([os.path.join(folder, "bin")], deps_cpp_info.bindirs)
     self.assertListEqual([os.path.join(folder, "")], deps_cpp_info.builddirs)
     self.assertListEqual([os.path.join(folder, "res")], deps_cpp_info.resdirs)
     self.assertListEqual([os.path.join(folder, "Frameworks")], deps_cpp_info.frameworkdirs)
Ejemplo n.º 21
0
    def initialize(self, settings, env, local=None):
        if isinstance(self.generators, str):
            self.generators = [self.generators]
        # User defined options
        self.options = create_options(self)
        self.requires = create_requirements(self)
        self.settings = create_settings(self, settings, local)
        try:
            if self.settings.os_build and self.settings.os:
                self.output.writeln("*"*60, front=Color.BRIGHT_RED)
                self.output.writeln("  This package defines both 'os' and 'os_build' ",
                                    front=Color.BRIGHT_RED)
                self.output.writeln("  Please use 'os' for libraries and 'os_build'",
                                    front=Color.BRIGHT_RED)
                self.output.writeln("  only for build-requires used for cross-building",
                                    front=Color.BRIGHT_RED)
                self.output.writeln("*"*60, front=Color.BRIGHT_RED)
        except ConanException:
            pass

        # needed variables to pack the project
        self.cpp_info = None  # Will be initialized at processing time
        self.deps_cpp_info = DepsCppInfo()

        # environment variables declared in the package_info
        self.env_info = None  # Will be initialized at processing time
        self.deps_env_info = DepsEnvInfo()

        # user declared variables
        self.user_info = None
        # Keys are the package names, and the values a dict with the vars
        self.deps_user_info = DepsUserInfo()

        # user specified env variables
        self._conan_env_values = env.copy()  # user specified -e
Ejemplo n.º 22
0
    def _get_conanfile(settings, frameworks=False, system_libs=False):
        conan_file = ConanFileMock()
        conan_file.settings = settings
        conan_file.source_folder = "my_cache_source_folder"
        conan_file.build_folder = "my_cache_build_folder"
        conan_file.deps_env_info = DepsEnvInfo()
        conan_file.deps_user_info = DepsUserInfo()
        conan_file.deps_cpp_info = DepsCppInfo()
        cpp_info = CppInfo("/root")
        cpp_info.include_paths.append("path/to/include1")
        cpp_info.lib_paths.append("path/to/lib1")
        cpp_info.libs.append("mylib")
        cpp_info.bindirs = "path/to/bin1"
        cpp_info.cflags.append("c_flag1")
        cpp_info.cxxflags.append("cxx_flag1")
        cpp_info.defines.append("mydefine1")
        if system_libs:
            cpp_info.system_libs.append("system_lib1")
        if frameworks:
            cpp_info.frameworks = ["AVFoundation", "VideoToolbox"]
            cpp_info.framework_paths.extend(['path/to/Frameworks1', 'path/to/Frameworks2'])

        conan_file.deps_cpp_info.update(cpp_info, "zlib")
        conan_file.env_info = EnvInfo()
        return conan_file
Ejemplo n.º 23
0
    def initialize(self, settings, env):
        if isinstance(self.generators, str):
            self.generators = [self.generators]
        # User defined options
        self.options = create_options(self)
        self.requires = create_requirements(self)
        self.settings = create_settings(self, settings)

        if 'cppstd' in self.settings.fields:
            conan_v2_behavior("Setting 'cppstd' is deprecated in favor of 'compiler.cppstd',"
                              " please update your recipe.", v1_behavior=self.output.warn)

        # needed variables to pack the project
        self.cpp_info = None  # Will be initialized at processing time
        self._conan_dep_cpp_info = None  # Will be initialized at processing time
        self.deps_cpp_info = DepsCppInfo()

        # environment variables declared in the package_info
        self.env_info = None  # Will be initialized at processing time
        self.deps_env_info = DepsEnvInfo()

        # user declared variables
        self.user_info = None
        # Keys are the package names (only 'host' if different contexts)
        self.deps_user_info = DepsUserInfo()

        # user specified env variables
        self._conan_env_values = env.copy()  # user specified -e

        if self.description is not None and not isinstance(self.description, six.string_types):
            raise ConanException("Recipe 'description' must be a string.")
Ejemplo n.º 24
0
 def _check_individual_deps(self, client):
     self.assertIn("INCLUDE [", client.user_io.out)
     self.assertIn(".conan/data/Hello0/0.1/lasote/stable",
                   client.user_io.out)
     build_file = os.path.join(client.current_folder, BUILD_INFO)
     content = load(build_file)
     cmakebuildinfo = load(
         os.path.join(client.current_folder, BUILD_INFO_CMAKE))
     self.assertIn(
         "set(CONAN_LIBS helloHello3 helloHello1 helloHello2 helloHello0",
         cmakebuildinfo)
     self.assertIn("set(CONAN_DEPENDENCIES Hello3 Hello1 Hello2 Hello0)",
                   cmakebuildinfo)
     deps_cpp_info = DepsCppInfo.loads(content)
     self.assertEqual(len(deps_cpp_info.include_paths), 4)
     for dep in ("Hello3", "Hello2", "Hello1", "Hello0"):
         self.assertEqual(len(deps_cpp_info[dep].include_paths), 1)
         self.assertEqual(len(deps_cpp_info[dep].lib_paths), 1)
         self.assertEqual(deps_cpp_info[dep].libs, ["hello%s" % dep])
     build_file = os.path.join(client.current_folder, BUILD_INFO_CMAKE)
     content = load(build_file)
     for dep in ("Hello3", "Hello2", "Hello1", "Hello0"):
         self.assertEqual(len(deps_cpp_info[dep].include_paths), 1)
         self.assertIn("set(CONAN_INCLUDE_DIRS_%s " % dep.upper(), content)
         self.assertIn("set(CONAN_LIBS_%s hello%s)" % (dep.upper(), dep),
                       content)
Ejemplo n.º 25
0
    def __init__(self, output, runner, settings, conanfile_directory):
        '''
        param settings: Settings
        '''

        # User defined generators
        self.generators = self.generators if hasattr(self, "generators") else ["txt"]
        self.generators = [self.generators] if isinstance(self.generators, str) \
                                            else self.generators

        # User defined options
        self.options = create_options(self)
        self.requires = create_requirements(self)
        self.settings = create_settings(self, settings)
        self.exports = create_exports(self)

        # needed variables to pack the project
        self.cpp_info = None  # Will be initialized at processing time
        self.deps_cpp_info = DepsCppInfo()
        self.copy = None  # initialized at runtime

        # an output stream (writeln, info, warn error)
        self.output = output
        # something that can run commands, as os.sytem
        self._runner = runner

        self._conanfile_directory = conanfile_directory
Ejemplo n.º 26
0
    def config_patch_test(self):
        conan_file = ConanFileMock()
        conan_file.name = "MyPkg"
        conan_file.settings = Settings()
        conan_file.source_folder = os.path.join(self.tempdir, "src")
        conan_file.build_folder = os.path.join(self.tempdir, "build")
        conan_file.package_folder = os.path.join(self.tempdir, "pkg")
        conan_file.deps_cpp_info = DepsCppInfo()

        msg = "FOLDER: " + conan_file.package_folder
        for folder in (conan_file.build_folder, conan_file.package_folder):
            save(os.path.join(folder, "file1.cmake"), "Nothing")
            save(os.path.join(folder, "file2"), msg)
            save(os.path.join(folder, "file3.txt"), msg)
            save(os.path.join(folder, "file3.cmake"), msg)
            save(os.path.join(folder, "sub", "file3.cmake"), msg)

        cmake = CMake(conan_file, generator="Unix Makefiles")
        cmake.patch_config_paths()
        for folder in (conan_file.build_folder, conan_file.package_folder):
            self.assertEqual("Nothing", load(os.path.join(folder, "file1.cmake")))
            self.assertEqual(msg, load(os.path.join(folder, "file2")))
            self.assertEqual(msg, load(os.path.join(folder, "file3.txt")))
            self.assertEqual("FOLDER: ${CONAN_MYPKG_ROOT}",
                             load(os.path.join(folder, "file3.cmake")))
            self.assertEqual("FOLDER: ${CONAN_MYPKG_ROOT}",
                             load(os.path.join(folder, "sub", "file3.cmake")))
Ejemplo n.º 27
0
    def initialize(self, settings, env):
        if isinstance(self.generators, str):
            self.generators = [self.generators]
        # User defined options
        self.options = create_options(self)
        self.requires = create_requirements(self)
        self.settings = create_settings(self, settings)

        if 'cppstd' in self.settings.fields:
            self.output.warn(
                "Setting 'cppstd' is deprecated in favor of 'compiler.cppstd',"
                " please update your recipe.")

        # needed variables to pack the project
        self.cpp_info = None  # Will be initialized at processing time
        self.deps_cpp_info = DepsCppInfo()

        # environment variables declared in the package_info
        self.env_info = None  # Will be initialized at processing time
        self.deps_env_info = DepsEnvInfo()

        # user declared variables
        self.user_info = None
        # Keys are the package names, and the values a dict with the vars
        self.deps_user_info = DepsUserInfo()

        # user specified env variables
        self._conan_env_values = env.copy()  # user specified -e
Ejemplo n.º 28
0
    def initialize(self, settings, env, buildenv=None):
        self._conan_buildenv = buildenv
        if isinstance(self.generators, str):
            self.generators = [self.generators]
        # User defined options
        self.options = create_options(self)
        self.requires = create_requirements(self)
        self.settings = create_settings(self, settings)

        conan_v2_error("Setting 'cppstd' is deprecated in favor of 'compiler.cppstd',"
                       " please update your recipe.", 'cppstd' in self.settings.fields)

        # needed variables to pack the project
        self.cpp_info = None  # Will be initialized at processing time
        self._conan_dep_cpp_info = None  # Will be initialized at processing time
        self.deps_cpp_info = DepsCppInfo()

        # environment variables declared in the package_info
        self.env_info = None  # Will be initialized at processing time
        self.deps_env_info = DepsEnvInfo()

        # user declared variables
        self.user_info = None
        # Keys are the package names (only 'host' if different contexts)
        self.deps_user_info = DepsUserInfo()

        # user specified env variables
        self._conan_env_values = env.copy()  # user specified -e

        if self.description is not None and not isinstance(self.description, six.string_types):
            raise ConanException("Recipe 'description' must be a string.")

        if not hasattr(self, "virtualenv"):  # Allow the user to override it with True or False
            self.virtualenv = True
Ejemplo n.º 29
0
    def configs_test(self):
        deps_cpp_info = DepsCppInfo()
        deps_cpp_info.includedirs.append("C:/whatever")
        deps_cpp_info.debug.includedirs.append("C:/whenever")
        deps_cpp_info.libs.extend(["math"])
        deps_cpp_info.debug.libs.extend(["debug_Lib"])

        child = DepsCppInfo()
        child.includedirs.append("F:/ChildrenPath")
        child.debug.includedirs.append("F:/ChildrenDebugPath")
        child.cppflags.append("cxxmyflag")
        child.debug.cppflags.append("cxxmydebugflag")
        deps_cpp_info._dependencies["Boost"] = child

        fakeconan = namedtuple(
            "Conanfile", "deps_cpp_info cpp_info deps_env_info env_info")
        output = TXTGenerator(fakeconan(deps_cpp_info, None, None,
                                        None)).content

        deps_cpp_info2 = DepsCppInfo.loads(output)
        self.assertEqual(deps_cpp_info.includedirs, deps_cpp_info2.includedirs)
        self.assertEqual(deps_cpp_info.libdirs, deps_cpp_info2.libdirs)
        self.assertEqual(deps_cpp_info.bindirs, deps_cpp_info2.bindirs)
        self.assertEqual(deps_cpp_info.libs, deps_cpp_info2.libs)
        self.assertEqual(len(deps_cpp_info._dependencies),
                         len(deps_cpp_info2._dependencies))
        self.assertEqual(deps_cpp_info["Boost"].includedirs,
                         deps_cpp_info2["Boost"].includedirs)
        self.assertEqual(deps_cpp_info["Boost"].cppflags,
                         deps_cpp_info2["Boost"].cppflags)
        self.assertEqual(deps_cpp_info["Boost"].cppflags, ["cxxmyflag"])

        self.assertEqual(deps_cpp_info.debug.includedirs,
                         deps_cpp_info2.debug.includedirs)
        self.assertEqual(deps_cpp_info.debug.includedirs, ["C:/whenever"])

        self.assertEqual(deps_cpp_info.debug.libs, deps_cpp_info2.debug.libs)
        self.assertEqual(deps_cpp_info.debug.libs, ["debug_Lib"])

        self.assertEqual(deps_cpp_info["Boost"].debug.includedirs,
                         deps_cpp_info2["Boost"].debug.includedirs)
        self.assertEqual(deps_cpp_info["Boost"].debug.includedirs,
                         ["F:/ChildrenDebugPath"])
        self.assertEqual(deps_cpp_info["Boost"].debug.cppflags,
                         deps_cpp_info2["Boost"].debug.cppflags)
        self.assertEqual(deps_cpp_info["Boost"].debug.cppflags,
                         ["cxxmydebugflag"])
 def help_test(self):
     deps_env_info = DepsEnvInfo()
     deps_cpp_info = DepsCppInfo()
     deps_cpp_info.includedirs.append("C:/whatever")
     deps_cpp_info.includedirs.append("C:/whenever")
     deps_cpp_info.libdirs.append("C:/other")
     deps_cpp_info.libs.extend(["math", "winsock", "boost"])
     child = DepsCppInfo()
     child.includedirs.append("F:/ChildrenPath")
     child.cppflags.append("cxxmyflag")
     deps_cpp_info._dependencies["Boost"] = child
     fakeconan = namedtuple(
         "Conanfile", "deps_cpp_info cpp_info deps_env_info env_info")
     output = TXTGenerator(
         fakeconan(deps_cpp_info, None, deps_env_info, None)).content
     deps_cpp_info2 = DepsCppInfo.loads(output)
     self._equal(deps_cpp_info, deps_cpp_info2)
Ejemplo n.º 31
0
 def variables_setup_test(self):
     conanfile = ConanFile(None, None, Settings({}), None)
     ref = ConanFileReference.loads("MyPkg/0.1@lasote/stables")
     cpp_info = DepsCppInfo()
     cpp_info.defines = ["MYDEFINE1"]
     conanfile.deps_cpp_info.update(cpp_info, ref)
     ref = ConanFileReference.loads("MyPkg2/0.1@lasote/stables")
     cpp_info = DepsCppInfo()
     cpp_info.defines = ["MYDEFINE2"]
     conanfile.deps_cpp_info.update(cpp_info, ref)
     generator = CMakeGenerator(conanfile)
     content = generator.content
     cmake_lines = content.splitlines()
     self.assertIn("set(CONAN_DEFINES_MYPKG -DMYDEFINE1)", cmake_lines)
     self.assertIn("set(CONAN_DEFINES_MYPKG2 -DMYDEFINE2)", cmake_lines)
     self.assertIn("set(CONAN_COMPILE_DEFINITIONS_MYPKG MYDEFINE1)", cmake_lines)
     self.assertIn("set(CONAN_COMPILE_DEFINITIONS_MYPKG2 MYDEFINE2)", cmake_lines)
Ejemplo n.º 32
0
    def __init__(self, output, runner, settings, user=None, channel=None, local=None):
        # User defined generators
        self.generators = self.generators if hasattr(self, "generators") else ["txt"]
        if isinstance(self.generators, str):
            self.generators = [self.generators]

        # User defined options
        self.options = create_options(self)
        self.requires = create_requirements(self)
        self.settings = create_settings(self, settings, local)
        try:
            if self.settings.os_build and self.settings.os:
                output.writeln("*"*60, front=Color.BRIGHT_RED)
                output.writeln("  This package defines both 'os' and 'os_build' ",
                               front=Color.BRIGHT_RED)
                output.writeln("  Please use 'os' for libraries and 'os_build'",
                               front=Color.BRIGHT_RED)
                output.writeln("  only for build-requires used for cross-building",
                               front=Color.BRIGHT_RED)
                output.writeln("*"*60, front=Color.BRIGHT_RED)
        except ConanException:
            pass
        self.exports = create_exports(self)
        self.exports_sources = create_exports_sources(self)
        # needed variables to pack the project
        self.cpp_info = None  # Will be initialized at processing time
        self.deps_cpp_info = DepsCppInfo()

        # environment variables declared in the package_info
        self.env_info = None  # Will be initialized at processing time
        self.deps_env_info = DepsEnvInfo()

        # user declared variables
        self.user_info = None
        # Keys are the package names, and the values a dict with the vars
        self.deps_user_info = DepsUserInfo()

        self.copy = None  # initialized at runtime
        self.copy_deps = None  # initialized at runtime

        # an output stream (writeln, info, warn error)
        self.output = output
        # something that can run commands, as os.sytem
        self._runner = runner

        self.develop = False

        # user specified env variables
        self._env_values = EnvValues()  # Updated at runtime, user specified -e
        self._user = user
        self._channel = channel

        self.in_local_cache = False
        self.description = None
        # Vars to control the build steps (build(), package())
        self.should_configure = True
        self.should_build = True
        self.should_install = True
Ejemplo n.º 33
0
    def build(self, conanfile_path, current_path, test=False, filename=None, profile_name=None):
        """ Call to build() method saved on the conanfile.py
        param conanfile_path: the original source directory of the user containing a
                            conanfile.py
        """
        logger.debug("Building in %s" % current_path)
        logger.debug("Conanfile in %s" % conanfile_path)

        if filename and filename.endswith(".txt"):
            raise ConanException("A conanfile.py is needed to call 'conan build'")

        conanfile_file = os.path.join(conanfile_path, filename or CONANFILE)

        try:
            output = ScopedOutput("Project", self._user_io.out)
            conan_file = self._loader(current_path).load_conan(conanfile_file, output,
                                                               consumer=True)
        except NotFoundException:
            # TODO: Auto generate conanfile from requirements file
            raise ConanException("'%s' file is needed for build.\n"
                                 "Create a '%s' and move manually the "
                                 "requirements and generators from '%s' file"
                                 % (CONANFILE, CONANFILE, CONANFILE_TXT))
        try:
            build_info_file = os.path.join(current_path, BUILD_INFO)
            if os.path.exists(build_info_file):
                try:
                    deps_cpp_info = DepsCppInfo.loads(load(build_info_file))
                    conan_file.deps_cpp_info = deps_cpp_info
                except:
                    pass

            env_file = os.path.join(current_path, "conanenv.txt")
            if os.path.exists(env_file):
                try:
                    deps_env_info = DepsEnvInfo.loads(load(env_file))
                    conan_file.deps_env_info = deps_env_info
                except:
                    pass

            os.chdir(current_path)
            conan_file._conanfile_directory = conanfile_path
            # Append env_vars to execution environment and clear when block code ends
            profile = self._read_profile(profile_name)
            env_vars = self._read_profile_env_vars(profile)
            with environment_append(env_vars):
                conan_file.build()

            if test:
                conan_file.test()
        except ConanException:
            raise  # Raise but not let to reach the Exception except (not print traceback)
        except Exception:
            import traceback
            trace = traceback.format_exc().split('\n')
            raise ConanException("Unable to build it successfully\n%s" % '\n'.join(trace[3:]))
Ejemplo n.º 34
0
    def _loads_cpp_info(text):
        pattern = re.compile(r"^\[([a-zA-Z0-9._:-]+)\]([^\[]+)", re.MULTILINE)

        try:
            # Parse the text
            data = defaultdict(lambda: defaultdict(dict))
            for m in pattern.finditer(text):
                var_name = m.group(1)
                lines = []
                for line in m.group(2).splitlines():
                    line = line.strip()
                    if not line or line[0] == "#":
                        continue
                    lines.append(line)
                if not lines:
                    continue

                tokens = var_name.split(":")
                if len(tokens) == 2:  # has config
                    var_name, config = tokens
                else:
                    config = None
                if 'system_libs' in var_name:
                    tokens = var_name.split("system_libs_", 1)
                    field = 'system_libs'
                else:
                    tokens = var_name.split("_", 1)
                    field = tokens[0]
                dep = tokens[1] if len(tokens) == 2 else None
                if field == "cppflags":
                    field = "cxxflags"
                data[dep][config][field] = lines

            # Build the data structures
            deps_cpp_info = DepsCppInfo()
            for dep, configs_cpp_info in data.items():
                if dep is None:
                    cpp_info = deps_cpp_info
                else:
                    cpp_info = deps_cpp_info._dependencies.setdefault(
                        dep, CppInfo(root_folder=""))

                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']:
                            value = value[0]
                        setattr(item_to_apply, key, value)
            return deps_cpp_info

        except Exception as e:
            logger.error(traceback.format_exc())
            raise ConanException(
                "There was an error parsing conanbuildinfo.txt: %s" % str(e))
Ejemplo n.º 35
0
    def test_types(self):
        deps_cpp_info = DepsCppInfo()
        cpp_info = CppInfo("pkg", "rootpath")
        cpp_info.version = "version"
        cpp_info.libs = ["lib1", "lib2"]
        cpp_info.includedirs = ["include1"]
        deps_cpp_info.add("pkg", DepCppInfo(cpp_info))

        info_for_package = deps_cpp_info["pkg"]

        # Documented as list for 'self.cpp_info' object
        self.assertIsInstance(info_for_package.includedirs, list)
        self.assertIsInstance(info_for_package.libdirs, list)
        self.assertIsInstance(info_for_package.resdirs, list)
        self.assertIsInstance(info_for_package.bindirs, list)
        self.assertIsInstance(info_for_package.builddirs, list)
        self.assertIsInstance(info_for_package.libs, list)
        self.assertIsInstance(info_for_package.defines, list)
        self.assertIsInstance(info_for_package.cflags, list)
        self.assertIsInstance(info_for_package.cppflags, list)
        self.assertIsInstance(info_for_package.cxxflags, list)
        self.assertIsInstance(info_for_package.sharedlinkflags, list)
        self.assertIsInstance(info_for_package.exelinkflags, list)
        self.assertIsInstance(info_for_package.frameworks, list)
        self.assertIsInstance(info_for_package.frameworkdirs, list)
        self.assertIsInstance(info_for_package.rootpath, six.string_types)
        self.assertIsInstance(info_for_package.name, six.string_types)
        self.assertIsInstance(info_for_package.system_libs, list)
        self.assertIsInstance(info_for_package.build_modules, list)
        self.assertIsInstance(info_for_package.components, dict)

        # Documented as list for `deps_cpp_info["pkg"]`
        self.assertIsInstance(info_for_package.include_paths, list)
        self.assertIsInstance(info_for_package.lib_paths, list)
        self.assertIsInstance(info_for_package.bin_paths, list)
        self.assertIsInstance(info_for_package.build_paths, list)
        self.assertIsInstance(info_for_package.res_paths, list)
        self.assertIsInstance(info_for_package.framework_paths, list)
        self.assertIsInstance(info_for_package.build_modules_paths, list)
        self.assertIsInstance(info_for_package.get_name("generator"),
                              six.string_types)
        self.assertIsInstance(info_for_package.version, six.string_types)
        self.assertIsInstance(info_for_package.components, dict)
Ejemplo n.º 36
0
    def __init__(self,
                 output,
                 runner,
                 settings,
                 conanfile_directory,
                 user=None,
                 channel=None):
        # User defined generators
        self.generators = self.generators if hasattr(
            self, "generators") else ["txt"]
        if isinstance(self.generators, str):
            self.generators = [self.generators]

        # User defined options
        self.options = create_options(self)
        self.requires = create_requirements(self)
        self.settings = create_settings(self, settings)
        self.exports = create_exports(self)
        self.exports_sources = create_exports_sources(self)
        # needed variables to pack the project
        self.cpp_info = None  # Will be initialized at processing time
        self.deps_cpp_info = DepsCppInfo()

        # environment variables declared in the package_info
        self.env_info = None  # Will be initialized at processing time
        self.deps_env_info = DepsEnvInfo()

        # user declared variables
        self.user_info = None
        # Keys are the package names, and the values a dict with the vars
        self.deps_user_info = DepsUserInfo()

        self.copy = None  # initialized at runtime

        # an output stream (writeln, info, warn error)
        self.output = output
        # something that can run commands, as os.sytem
        self._runner = runner

        self.conanfile_directory = conanfile_directory
        self._scope = None

        self.develop = False

        # user specified env variables
        self._env_values = EnvValues()  # Updated at runtime, user specified -e
        self._user = user
        self._channel = channel

        # Are we in local cache? Suggest a better name
        self.in_local_cache = False

        # Init a description
        self.description = None
Ejemplo n.º 37
0
    def parse_test(self):
        text = """[includedirs]
C:/Whenever
[includedirs_Boost]
F:/ChildrenPath
[includedirs_My_Lib]
mylib_path
[includedirs_My_Other_Lib]
otherlib_path
        """
        deps_info = DepsCppInfo.loads(text)
        self.assertEqual(deps_info.includedirs, ['C:/Whenever'])
        self.assertEqual(deps_info["Boost"].includedirs, ['F:/ChildrenPath'])
        self.assertEqual(deps_info["My_Lib"].includedirs, ['mylib_path'])
        self.assertEqual(deps_info["My_Other_Lib"].includedirs, ['otherlib_path'])
Ejemplo n.º 38
0
 def _check_individual_deps(self, client):
     self.assertIn("INCLUDE [", client.user_io.out)
     self.assertIn(".conan/data/Hello0/0.1/lasote/stable", client.user_io.out)
     build_file = os.path.join(client.current_folder, BUILD_INFO)
     content = load(build_file)
     deps_cpp_info = DepsCppInfo.loads(content)
     self.assertEqual(len(deps_cpp_info.include_paths), 4)
     for dep in ("Hello3", "Hello2", "Hello1", "Hello0"):
         self.assertEqual(len(deps_cpp_info[dep].include_paths), 1)
         self.assertEqual(len(deps_cpp_info[dep].lib_paths), 1)
         self.assertEqual(deps_cpp_info[dep].libs, ["hello%s" % dep])
     build_file = os.path.join(client.current_folder, BUILD_INFO_CMAKE)
     content = load(build_file)
     for dep in ("Hello3", "Hello2", "Hello1", "Hello0"):
         self.assertEqual(len(deps_cpp_info[dep].include_paths), 1)
         self.assertIn("set(CONAN_INCLUDE_DIRS_%s " % dep.upper(), content)
         self.assertIn("set(CONAN_LIBS_%s hello%s)" % (dep.upper(), dep), content)
Ejemplo n.º 39
0
    def build(self, conanfile_path, current_path, test=False):
        """ Call to build() method saved on the conanfile.py
        param conanfile_path: the original source directory of the user containing a
                            conanfile.py
        """
        logger.debug("Building in %s" % current_path)
        logger.debug("Conanfile in %s" % conanfile_path)
        conanfile_file = os.path.join(conanfile_path, CONANFILE)

        try:
            conan_file = self._loader(current_path).load_conan(conanfile_file, consumer=True)
        except NotFoundException:
            # TODO: Auto generate conanfile from requirements file
            raise ConanException("'%s' file is needed for build.\n"
                               "Create a '%s' and move manually the "
                               "requirements and generators from '%s' file"
                               % (CONANFILE, CONANFILE, CONANFILE_TXT))
        try:
            build_info_file = os.path.join(current_path, BUILD_INFO)
            if os.path.exists(build_info_file):
                try:
                    deps_cpp_info = DepsCppInfo.loads(load(build_info_file))
                    conan_file.deps_cpp_info = deps_cpp_info
                except:
                    pass

            os.chdir(current_path)
            conan_file.build()
            if test:
                conan_file.test()
        except ConanException:
            raise  # Raise but not let to reach the Exception except (not print traceback)
        except Exception:
            import traceback
            trace = traceback.format_exc().split('\n')
            raise ConanException("Unable to build it successfully\n%s" % '\n'.join(trace[3:]))