Пример #1
0
    def _loads(self, text):
        yml = yaml.safe_load(text)
        self._ws_generator = yml.pop("workspace_generator", None)
        yml.pop("name", None)
        ws_layout = yml.pop("layout", None)
        if ws_layout:
            ws_layout = get_editable_abs_path(ws_layout, self._base_folder,
                                              self._cache.cache_folder)
        generators = yml.pop("generators", None)
        if isinstance(generators, str):
            generators = [generators]

        root_list = yml.pop("root", [])
        if isinstance(root_list, str):
            root_list = root_list.split(",")

        self._root = [ConanFileReference.loads(s.strip())
                      for s in root_list if s.strip()]
        if not self._root:
            raise ConanException("Conan workspace needs at least 1 root conanfile")

        editables = yml.pop("editables", {})
        for ref, data in editables.items():
            workspace_package = LocalPackage(self._base_folder, data,
                                             self._cache, ws_layout, generators, ref)
            package_name = ConanFileReference.loads(ref)
            self._workspace_packages[package_name] = workspace_package
        for package_name in self._root:
            if package_name not in self._workspace_packages:
                raise ConanException("Root %s is not defined as editable" % str(package_name))

        if yml:
            raise ConanException("Workspace unrecognized fields: %s" % yml)
Пример #2
0
    def __init__(self, base_folder, data, cache, ws_layout, ws_generators, ref):
        if not data or not data.get("path"):
            raise ConanException("Workspace editable %s does not define path" % str(ref))
        self._base_folder = base_folder
        self._conanfile_folder = data.pop("path", None)  # The folder with the conanfile
        layout = data.pop("layout", None)
        if layout:
            self.layout = get_editable_abs_path(layout, self._base_folder, cache.cache_folder)
        else:
            self.layout = ws_layout

        generators = data.pop("generators", None)
        if isinstance(generators, str):
            generators = [generators]
        if generators is None:
            generators = ws_generators
        self.generators = generators

        if data:
            raise ConanException("Workspace unrecognized fields: %s" % data)