Commit 7cca0e02 authored by Henrique Nakashima's avatar Henrique Nakashima Committed by Commit Bot

[Lorenz] generate_json_dependency_graph.py can run on another checkout

Add the -d, --checkout-dir option to specify a different directory. This
helps especially when generating graphs at previous commits.

Change-Id: I5d4a107a85d6e2ecc4cbb884d8d1fab8ee31d2db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2518790Reviewed-by: default avatarMohamed Heikal <mheikal@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823765}
parent 3e46e955
......@@ -18,8 +18,6 @@ import package_dependency
import serialization
import subprocess_utils
SRC_PATH = pathlib.Path(__file__).resolve().parents[3] # src/
JDEPS_PATH = SRC_PATH.joinpath('third_party/jdk/current/bin/jdeps')
DEFAULT_ROOT_TARGET = 'chrome/android:monochrome_public_bundle'
......@@ -163,9 +161,11 @@ def main():
'--target',
default=DEFAULT_ROOT_TARGET,
help='Root build target.')
arg_parser.add_argument('-d',
'--checkout-dir',
help='Path to the chromium checkout directory.')
arg_parser.add_argument('-j',
'--jdeps-path',
default=JDEPS_PATH,
help='Path to the jdeps executable.')
arg_parser.add_argument('-g',
'--gn-path',
......@@ -173,8 +173,18 @@ def main():
help='Path to the gn executable.')
arguments = arg_parser.parse_args()
if arguments.checkout_dir:
src_path = pathlib.Path(arguments.checkout_dir)
else:
src_path = pathlib.Path(__file__).resolve().parents[3]
if arguments.jdeps_path:
jdeps_path = pathlib.Path(arguments.jdeps_path)
else:
jdeps_path = src_path.joinpath('third_party/jdk/current/bin/jdeps')
# gn and git must be run from inside the git checkout.
os.chdir(SRC_PATH)
os.chdir(src_path)
print('Getting list of dependency jars...')
gn_desc_output = _run_gn_desc_list_dependencies(arguments.build_output_dir,
......@@ -188,8 +198,8 @@ def main():
jdeps_process_number = math.ceil(multiprocessing.cpu_count() / 2)
with multiprocessing.Pool(jdeps_process_number) as pool:
jar_paths = [target_jar for _, target_jar in target_jars]
jdeps_outputs = pool.map(
functools.partial(_run_jdeps, arguments.jdeps_path), jar_paths)
jdeps_outputs = pool.map(functools.partial(_run_jdeps, jdeps_path),
jar_paths)
print('Parsing jdeps output...')
jdeps_parser = JavaClassJdepsParser()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment