Skip to content

Commit

Permalink
ui: Only import plugins with an index.ts
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
stevegolton committed Oct 24, 2024
1 parent 23f82f5 commit 3f8589a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tools/gen_ui_imports
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 3f8589a

Please sign in to comment.