tools: python amalgamation for tools/tracebox etc
Before this change:
the business logic for tools/{tracebox, record_android_trace, ...}
was in the file itself and the manifest was replaced in-place
when invoking tools/roll-prebuilts.
This still made it impossible to share code between tools
without copy/pasting.
With this change:
- Move the business logic to python/xxx
- Add an amalgamator that follows includes. Only the form
'from perfetto.xxx import yyy' is supported.
- Keep the amalgamated files in tools/traceconv
No code sharing / major refactorings are made by this change.
They can happen as a follow-up though
Change-Id: I7420387881e6ef1e109abae6380dde7c06ac1b27
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 901f812..5307e5a 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -76,6 +76,7 @@
results += RunAndReportIfLong(CheckBannedCpp, input, output)
results += RunAndReportIfLong(CheckSqlMetrics, input, output)
results += RunAndReportIfLong(CheckTestData, input, output)
+ results += RunAndReportIfLong(CheckAmalgamatedPythonTools, input, output)
return results
@@ -291,3 +292,21 @@
)
]
return []
+
+
+def CheckAmalgamatedPythonTools(input_api, output_api):
+ tool = 'tools/gen_amalgamated_python_tools'
+
+ # If no GN files were modified, bail out.
+ def build_file_filter(x):
+ return input_api.FilterSourceFile(x, files_to_check=('python/.*$', tool))
+
+ if not input_api.AffectedSourceFiles(build_file_filter):
+ return []
+ if subprocess.call([tool, '--check-only']):
+ return [
+ output_api.PresubmitError(
+ 'amalgamated python tools/ are out of date. ' + 'Run ' + tool +
+ ' to update them.')
+ ]
+ return []