Beispiel #1
0
def DoGetFiles(config: Config,
               toolMiniConfig: ToolMinimalConfig,
               currentDir: str,
               allowRecursiveScan: bool = False) -> List[str]:
    """
    :param currentDir: currentDir must be part of a package root
    :param allowRecursiveScan: if True and not a sdk build all subdirectories will be scanned
    """
    if allowRecursiveScan and config.IsSDKBuild:
        config.DoPrintWarning("recursive is ignored for sdk builds")

    if ToolConfigPackageRootUtil.TryFindRootDirectory(
            toolMiniConfig.RootDirectories, currentDir) is None:
        raise UsageErrorException(
            "the folder '{0}' does not reside inside one of the root dirs".
            format(currentDir))

    theFiles = []  # type: List[str]
    if not config.IsSDKBuild:
        if allowRecursiveScan:
            theFiles += IOUtil.FindFileByName(currentDir, config.GenFileName,
                                              toolMiniConfig.IgnoreDirectories)
        else:
            theFile = IOUtil.Join(currentDir, config.GenFileName)
            if not os.path.isfile(theFile):
                raise Exception("File not found: '{0}'".format(theFile))
            theFiles.append(theFile)
    return theFiles