def expand_filename_pattern(self, pattern, base_dir, sourcefile=None):
        expandedPattern = substitute_vars([pattern], self, sourcefile)
        assert len(expandedPattern) == 1
        expandedPattern = expandedPattern[0]
        if expandedPattern != pattern:
            logging.debug("Expanded variables in expression %r to %r.",
                          pattern, expandedPattern)
        fileList = util.expand_filename_pattern(expandedPattern, base_dir)
        fileList.sort()
        if not fileList:
            logging.warning("No files found matching %r.", pattern)
        return fileList