def write_cmakelists(dev_packages, dev_package_specs, build_system, path_fixer): package_cmake_args = extract_cmake_args(dev_packages, dev_package_specs) cmakelists = init_cmakelists() remaining_packages = copy.copy(dev_packages) while remaining_packages != []: for dp in remaining_packages: spec = dev_package_specs[dp] dep_dict = spec.dependencies_dict() if not any(other for other in remaining_packages if other in dep_dict): # package is a leaf. package_dependencies\ = intersection(dev_packages, dep_dict.keys()) # Fix install / stage paths. path_fixer.set_packages(dp, *package_dependencies) package_cmake_args[dp]\ = [path_fixer.fix(val, build_directory= build_directory_for(spec.package), package_name=dp) for val in package_cmake_args[dp]] add_package_to_cmakelists(cmakelists, dp, spec, package_dependencies, package_cmake_args[dp], build_system) remaining_packages.remove(dp)
def _add(self, spec, directory_layout=None, explicit=False): """Add an install record for this spec to the database. Assumes spec is installed in ``layout.path_for_spec(spec)``. Also ensures dependencies are present and updated in the DB as either intsalled or missing. """ if not spec.concrete: raise NonConcreteSpecAddError( "Specs added to DB must be concrete.") for dep in spec.dependencies(_tracked_deps): dkey = dep.dag_hash() if dkey not in self._data: self._add(dep, directory_layout, explicit=False) key = spec.dag_hash() if key not in self._data: installed = False path = None if not spec.external and directory_layout: path = directory_layout.path_for_spec(spec) try: directory_layout.check_installed(spec) installed = True except DirectoryLayoutError as e: tty.warn( 'Dependency missing due to corrupt install directory:', path, str(e)) # Create a new install record with no deps initially. new_spec = spec.copy(deps=False) self._data[key] = InstallRecord(new_spec, path, installed, ref_count=0, explicit=explicit) # Connect dependencies from the DB to the new copy. for name, dep in spec.dependencies_dict(_tracked_deps).iteritems(): dkey = dep.spec.dag_hash() new_spec._add_dependency(self._data[dkey].spec, dep.deptypes) self._data[dkey].ref_count += 1 # Mark concrete once everything is built, and preserve # the original hash of concrete specs. new_spec._mark_concrete() new_spec._hash = key else: # If it is already there, mark it as installed. self._data[key].installed = True self._data[key].explicit = explicit
def _add(self, spec, directory_layout=None, explicit=False): """Add an install record for this spec to the database. Assumes spec is installed in ``layout.path_for_spec(spec)``. Also ensures dependencies are present and updated in the DB as either intsalled or missing. """ if not spec.concrete: raise NonConcreteSpecAddError( "Specs added to DB must be concrete.") for dep in spec.dependencies(_tracked_deps): dkey = dep.dag_hash() if dkey not in self._data: self._add(dep, directory_layout, explicit=False) key = spec.dag_hash() if key not in self._data: installed = bool(spec.external) path = None if not spec.external and directory_layout: path = directory_layout.path_for_spec(spec) try: directory_layout.check_installed(spec) installed = True except DirectoryLayoutError as e: tty.warn( 'Dependency missing due to corrupt install directory:', path, str(e)) # Create a new install record with no deps initially. new_spec = spec.copy(deps=False) self._data[key] = InstallRecord( new_spec, path, installed, ref_count=0, explicit=explicit) # Connect dependencies from the DB to the new copy. for name, dep in iteritems(spec.dependencies_dict(_tracked_deps)): dkey = dep.spec.dag_hash() new_spec._add_dependency(self._data[dkey].spec, dep.deptypes) self._data[dkey].ref_count += 1 # Mark concrete once everything is built, and preserve # the original hash of concrete specs. new_spec._mark_concrete() new_spec._hash = key else: # If it is already there, mark it as installed. self._data[key].installed = True self._data[key].explicit = explicit
def write_cmakelists(packages, package_specs, build_system, path_fixer): package_cmake_args = extract_cmake_args(packages, package_specs) cmakelists = init_cmakelists() remaining_packages = copy.copy(packages) while remaining_packages != []: for package in remaining_packages: spec = package_specs[package] dep_dict = spec.dependencies_dict() if not any(other for other in remaining_packages if other in dep_dict): # package is a leaf. package_dependencies\ = intersection(packages, dep_dict.keys()) # Fix install / stage paths. path_fixer.set_packages(package, *package_dependencies) package_cmake_args[package]\ = [path_fixer.fix(val) for val in \ package_cmake_args[package]] add_package_to_cmakelists(cmakelists, package, package_dependencies, package_cmake_args[package], build_system) remaining_packages.remove(package)
def _add( self, spec, directory_layout=None, explicit=False, installation_time=None ): """Add an install record for this spec to the database. Assumes spec is installed in ``layout.path_for_spec(spec)``. Also ensures dependencies are present and updated in the DB as either installed or missing. Args: spec: spec to be added directory_layout: layout of the spec installation **kwargs: explicit Possible values: True, False, any A spec that was installed following a specific user request is marked as explicit. If instead it was pulled-in as a dependency of a user requested spec it's considered implicit. installation_time Date and time of installation """ if not spec.concrete: raise NonConcreteSpecAddError( "Specs added to DB must be concrete.") # Retrieve optional arguments installation_time = installation_time or _now() for dep in spec.dependencies(_tracked_deps): dkey = dep.dag_hash() if dkey not in self._data: extra_args = { 'explicit': False, 'installation_time': installation_time } self._add(dep, directory_layout, **extra_args) key = spec.dag_hash() if key not in self._data: installed = bool(spec.external) path = None if not spec.external and directory_layout: path = directory_layout.path_for_spec(spec) try: directory_layout.check_installed(spec) installed = True except DirectoryLayoutError as e: tty.warn( 'Dependency missing due to corrupt install directory:', path, str(e)) # Create a new install record with no deps initially. new_spec = spec.copy(deps=False) extra_args = { 'explicit': explicit, 'installation_time': installation_time } self._data[key] = InstallRecord( new_spec, path, installed, ref_count=0, **extra_args ) # Connect dependencies from the DB to the new copy. for name, dep in iteritems(spec.dependencies_dict(_tracked_deps)): dkey = dep.spec.dag_hash() new_spec._add_dependency(self._data[dkey].spec, dep.deptypes) self._data[dkey].ref_count += 1 # Mark concrete once everything is built, and preserve # the original hash of concrete specs. new_spec._mark_concrete() new_spec._hash = key else: # If it is already there, mark it as installed. self._data[key].installed = True self._data[key].explicit = explicit