summaryrefslogtreecommitdiff
path: root/utils/codegen/ipc/tools
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-08-08 18:13:00 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-08-15 23:59:08 +0300
commit50c92cc7e2924009ecab3e4004448b01d687707c (patch)
treec22b49816a3c79dae4727780962aa0928df42b52 /utils/codegen/ipc/tools
parentd3bf27180ef1d91b86b7b87a2378e559eaff5455 (diff)
meson: Move all code generation scripts to utils/codegen/
We have multiple code generation scripts in utils/, mixed with other miscellaneous utilities, as well as a larger code base based on mojom in utils/ipc/. To make code sharing easier between the generator scripts, without creating a mess in the utils/ directory, move all the code generation code to utils/codegen/. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Diffstat (limited to 'utils/codegen/ipc/tools')
-rw-r--r--utils/codegen/ipc/tools/README4
-rw-r--r--utils/codegen/ipc/tools/diagnosis/crbug_1001171.py51
2 files changed, 55 insertions, 0 deletions
diff --git a/utils/codegen/ipc/tools/README b/utils/codegen/ipc/tools/README
new file mode 100644
index 00000000..961cabd2
--- /dev/null
+++ b/utils/codegen/ipc/tools/README
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: CC0-1.0
+
+Files in this directory are imported from 9be4263648d7 of Chromium. Do not
+modify them manually.
diff --git a/utils/codegen/ipc/tools/diagnosis/crbug_1001171.py b/utils/codegen/ipc/tools/diagnosis/crbug_1001171.py
new file mode 100644
index 00000000..40900d10
--- /dev/null
+++ b/utils/codegen/ipc/tools/diagnosis/crbug_1001171.py
@@ -0,0 +1,51 @@
+# Copyright 2019 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Helper context wrapper for diagnosing crbug.com/1001171.
+
+This module and all uses thereof can and should be removed once
+crbug.com/1001171 has been resolved.
+"""
+
+from __future__ import print_function
+
+import contextlib
+import os
+import sys
+
+
+@contextlib.contextmanager
+def DumpStateOnLookupError():
+ """Prints potentially useful state info in the event of a LookupError."""
+ try:
+ yield
+ except LookupError:
+ print('LookupError diagnosis for crbug.com/1001171:')
+ for path_index, path_entry in enumerate(sys.path):
+ desc = 'unknown'
+ if not os.path.exists(path_entry):
+ desc = 'missing'
+ elif os.path.islink(path_entry):
+ desc = 'link -> %s' % os.path.realpath(path_entry)
+ elif os.path.isfile(path_entry):
+ desc = 'file'
+ elif os.path.isdir(path_entry):
+ desc = 'dir'
+ print(' sys.path[%d]: %s (%s)' % (path_index, path_entry, desc))
+
+ real_path_entry = os.path.realpath(path_entry)
+ if (path_entry.endswith(os.path.join('lib', 'python2.7'))
+ and os.path.isdir(real_path_entry)):
+ encodings_dir = os.path.realpath(
+ os.path.join(real_path_entry, 'encodings'))
+ if os.path.exists(encodings_dir):
+ if os.path.isdir(encodings_dir):
+ print(' %s contents: %s' % (encodings_dir,
+ str(os.listdir(encodings_dir))))
+ else:
+ print(' %s exists but is not a directory' % encodings_dir)
+ else:
+ print(' %s missing' % encodings_dir)
+
+ raise