def deploy_symbols(sourcedir): # 要排除的目录或者文件 (小写) exclude_dirs = ['3rdparty', '.vs'] exclude_files = ['libmysql.dll', 'dbghelp.dll', 'pcre8.dll', 'zlib.dll'] for dirpath, dirnames, filenames in os.walk(sourcedir): dirnames[:] = [d for d in dirnames if d.lower() not in exclude_dirs] filenames[:] = [f for f in filenames if f.lower() not in exclude_files] for filename in filenames: extname = Common.get_file_ext(filename) if extname not in ['.exe', '.dll', '.pdb']: continue fullpath = os.path.join(dirpath, filename) deploy_file(fullpath)
def deploy_file(filepath): basename = os.path.basename(filepath) extname = Common.get_file_ext(basename) if extname not in ['.exe', '.dll', '.pdb']: return if extname == '.pdb': filehash = Common.get_pdb_hash(filepath) elif extname in ['.dll', '.exe']: filehash = Common.get_pe_hash(filepath) target_filepath = '{symstore}/{filename}/{hash}/{filename}'.format( symstore = project_symstoredir, hash = filehash, filename = basename.replace('-pre', '') ) os.makedirs(os.path.dirname(target_filepath), exist_ok=True) shutil.copyfile(filepath, target_filepath)