#!/usr/bin/env python3 # This file is part of MegBrain. # Copyright (c) 2014-2021 Megvii Inc. All rights reserved. import argparse import os import re import subprocess import tempfile from functools import partial from multiprocessing import Manager from tqdm.contrib.concurrent import process_map # change workspace to MegBrain root dir os.chdir(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) failed_files = Manager().list() def process_file(file, clang_format, write): source = open(file, "r").read() source = re.sub(r"MGB_DEFINE(?P([^\\]|\n)*?)// *{", r"class MGB_DEFINE\g{", source) source, count = re.subn(r"(?