1
0
Fork 0

More accurate commands to reproduce build

Added command to create a link to a compilation database and switch
directory to run tidy and format.
This commit is contained in:
Mikhail Goncharov 2020-12-11 16:35:58 +01:00
parent 2e9a9563e1
commit 1d3a3049bb
3 changed files with 16 additions and 4 deletions

View file

@ -145,8 +145,8 @@ class PhabTalk:
class Step:
def __init__(self):
self.name = ''
def __init__(self, name=''):
self.name = name
self.success = True
self.duration = 0.0
self.reproduce_commands = []

View file

@ -117,14 +117,25 @@ if __name__ == '__main__':
report.success = True
cmake = run_step('cmake', report, lambda s, r: cmake_report(args.projects, s, r))
commands_in_build = True
if cmake.success:
ninja_all = run_step('ninja all', report, ninja_all_report)
if ninja_all.success:
run_step('ninja check-all', report, ninja_check_all_report)
if args.check_clang_tidy:
if commands_in_build:
s = Step('')
s.reproduce_commands.append('cd ..')
commands_in_build = False
report.steps.append(s)
run_step('clang-tidy', report,
lambda s, r: clang_tidy_report.run('HEAD~1', os.path.join(scripts_dir, 'clang-tidy.ignore'), s, r))
if args.check_clang_format:
if commands_in_build:
s = Step('')
s.reproduce_commands.append('cd ..')
commands_in_build = False
report.steps.append(s)
run_step('clang-format', report,
lambda s, r: clang_format_report.run('HEAD~1', os.path.join(scripts_dir, 'clang-format.ignore'), s, r))
logging.debug(report)

View file

@ -168,7 +168,7 @@ def run(projects: str, repo_path: str, config_file_path: str = None, *, dry_run:
result = subprocess.call(cmd, env=env, shell=True, cwd=build_dir)
commands.append('cmake ' + ' '.join(_create_args(config, llvm_enable_projects, False)))
commands.append('# ^note that compiler cache arguments are omitted')
_link_compile_commands(config, repo_path, build_dir)
_link_compile_commands(config, repo_path, build_dir, commands)
return result, build_dir, [os.path.join(build_dir, 'CMakeCache.txt')], commands
@ -187,7 +187,7 @@ def secure_delete(path: str):
shutil.rmtree(path, onerror=del_rw)
def _link_compile_commands(config: Configuration, repo_path: str, build_dir: str):
def _link_compile_commands(config: Configuration, repo_path: str, build_dir: str, commands: List[str]):
"""Link compile_commands.json from build to root dir"""
if config.operating_system != OperatingSystem.Linux:
return
@ -196,6 +196,7 @@ def _link_compile_commands(config: Configuration, repo_path: str, build_dir: str
if os.path.exists(target_path):
os.remove(target_path)
os.symlink(source_path, target_path)
commands.append(f'ln -s $PWD/compile_commands.json ../compile_commands.json')
if __name__ == '__main__':