From 3f8589ae5a266d3091fd1dc5974d23116eca9743 Mon Sep 17 00:00:00 2001 From: Steve Golton Date: Thu, 24 Oct 2024 15:17:41 +0100 Subject: [PATCH] ui: Only import plugins with an index.ts - Currently if a plugin dir is left empty, perfetto will try to import it and the build will fail. - This CL adds a check to ensure plugin dirs actually contain an index.ts before adding it to the import list. Change-Id: I262a2cd10ccadcef87179cc18ca80e39e10bebba --- tools/gen_ui_imports | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/gen_ui_imports b/tools/gen_ui_imports index 3cae5c071b..9c3a96dc6d 100755 --- a/tools/gen_ui_imports +++ b/tools/gen_ui_imports @@ -49,9 +49,15 @@ def to_camel_case(s): return first + ''.join(x.title() for x in rest) +def is_plugin_dir(dir): + # Ensure plugins contain a file called index.ts. This avoids the issue empty + # dirs are detected as plugins. + return os.path.isdir(dir) and os.path.exists(os.path.join(dir, 'index.ts')) + + def gen_imports(input_dir, output_path): paths = [os.path.join(input_dir, p) for p in os.listdir(input_dir)] - paths = [p for p in paths if os.path.isdir(p)] + paths = [p for p in paths if is_plugin_dir(p)] paths.sort() output_dir = os.path.dirname(output_path) @@ -60,6 +66,7 @@ def gen_imports(input_dir, output_path): imports = [] registrations = [] for path in paths: + # Get out if rel_path = os.path.relpath(path, output_dir) snake_name = os.path.basename(path) camel_name = to_camel_case(snake_name)