diff --git a/scripts/flitcli/flit_disguise.py b/scripts/flitcli/flit_disguise.py index 51faf08b..85bec40c 100644 --- a/scripts/flitcli/flit_disguise.py +++ b/scripts/flitcli/flit_disguise.py @@ -88,6 +88,7 @@ import argparse import csv import glob +import multiprocessing as mp import os import re import subprocess as subp @@ -148,20 +149,15 @@ def populate_parser(parser=None): analysis done by someone with the anonymized file(s). ''') - parser.add_argument('--fields', default='file,function,test', + parser.add_argument('-j', '--jobs', default=None, help=''' - A comma-separated list of fields you want to - disguise. This will not effect the generated - disguise map, all fields will be present there. It - will just impact the disguising and the undo - operations. - - Available fields are - (1) "file": source file name and file path - (including compiled object file(s)), - (2) "function": function name, both mangled and - demangled, and - (3) "test": name of the test. + When generating the disguise map, we may need to + compile the gtrun executable using the + autogenerated flit Makefile. This flag specifies + the number of jobs to give to GNU make. The + default behavior is to defer to the MAKEFLAGS + environment variable. If that variable is not set, + then we will use the number of processors. ''') parser.add_argument('file', nargs='?', help=''' @@ -176,11 +172,18 @@ def populate_parser(parser=None): ''') return parser -def generate_disguise_map(outfile='disguise.csv'): +def generate_disguise_map(outfile='disguise.csv', jobs=None): 'Generate the disguise map, often called from the Makefile' + if not jobs and not hasattr(os.environ, 'MAKEFLAGS'): + jobs = mp.cpu_count() + # make sure gtrun is compiled - subp.check_call(['make', 'gtrun']) + make_args = ['make', 'gtrun'] + if jobs: + make_args.append('-j{}'.format(jobs)) + subp.check_call(make_args) + makevars = util.extract_make_vars() # get list of source files