コード例 #1
0
ファイル: library.py プロジェクト: hotgloupi/configure.py
    def _find_include_directories(self, include_directories):
        env_dirs = self._env_include_directories()
        if not self.find_includes:
            return tools.unique(self._env_include_directories() + include_directories)
        all_found = True
        for include in self.find_includes:
            all_found = any(
                path.exists(dir_, include) for dir_ in env_dirs
            )
            tools.debug("Search '%s':" % include, all_found)
            if not all_found: break

        if all_found:
            tools.debug("Include directories for", self.name, "found in env variables")
            return env_dirs
        tools.debug("Include directories for", self.name, "not found in env variables")
        results = []
        include_directories += env_dirs
        for p in self.prefixes:
            include_directories.append(path.join(p, 'include'))
        if self.use_system_paths:
            include_directories += self.include_system_paths()
        tools.debug("Search include directories for library", self.name)

        dirs = []
        for directory_name in self.include_directory_names:
            dirs.extend(path.join(dir_, directory_name) for dir_ in include_directories)
        include_directories = tools.unique(dirs)

        for include in self.find_includes:
            dirname, basename = path.split(include)
            name, ext = path.splitext(basename)
            found = False
            for dir_ in include_directories:
                tools.debug("Searching '%s' in directory '%s'" % (include, dir_))
                files = tools.find_files(
                    working_directory = path.join(dir_, dirname),
                    name = name,
                    extensions = [ext],
                    recursive = False,
                )
                if files:
                    found = True
                    tools.verbose("Found %s header '%s' in '%s'" % (self.name, include, dir_))
                    results.append(dir_)
                    break
            if not found:
                tools.fatal(
                    "Cannot find include file '%s' for library %s:" % (include, self.name),
                    "\t* Set 'include_directories' when creating the library",
                    "\t* Set the environment variable '%s_INCLUDE_DIRECTORY'" % self.name.upper(),
                    "\t* Set the environment variable '%s_INCLUDE_DIRECTORIES'" % self.name.upper(),
                    "\t* Set the environment variable '%s_PREFIX'" % self.name.upper(),
                    "\t* Set the environment variable '%s_PREFIXES'" % self.name.upper(),
                    "\t* Set the environment variable 'PREFIX'",
                    "\t* Set the environment variable 'PREFIXES'",
                    sep='\n'
                )
        return results
コード例 #2
0
ファイル: library.py プロジェクト: hotgloupi/configure.py
 def _find_files(self, directory, name, extensions):
     tools.debug("Searching for {%s}%s{%s}.%s library files in directory '%s'" % (
         str(self.name_prefixes), name,
         str(self.name_suffixes),
         str(extensions),
         directory
     ))
     files = tools.find_files(
         working_directory = directory,
         name = name,
         prefixes = self.name_prefixes,
         extensions = extensions,
         suffixes = self.name_suffixes,
         recursive = False,
     )
     if files:
         tools.debug("Found {%s}%s{%s} library files [%s] in directory '%s'" % (
             str(self.name_prefixes), name, str(self.name_suffixes),
             ', '.join(files),
             directory,
         ))
         files = list(path.absolute(directory, f) for f in files)
     return files