[libcamera-devel,v5,02/23] utils: ipc: add generator script
diff mbox series

Message ID 20201205103106.242080-3-paul.elder@ideasonboard.com
State Superseded
Delegated to: Paul Elder
Headers show
Series
  • IPA isolation implementation
Related show

Commit Message

Paul Elder Dec. 5, 2020, 10:30 a.m. UTC
We want to avoid changing our copy of mojo to make updates easier. Some
parameters in the mojo generator script needs to be changed though; add
a wrapper script that sets these parameters.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---
No change in v5

No change in v4

Changes in v3:
- add SPDX and copyright and file description block
- add todo for sys.pycache_prefix for python3.8+

Changes in v2:
- add descriptions to python setup
- disable pycache
---
 utils/ipc/generate.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100755 utils/ipc/generate.py

Comments

Niklas Söderlund Dec. 18, 2020, 3:53 p.m. UTC | #1
Hi Paul,

Thanks for your work.

On 2020-12-05 19:30:45 +0900, Paul Elder wrote:
> We want to avoid changing our copy of mojo to make updates easier. Some
> parameters in the mojo generator script needs to be changed though; add
> a wrapper script that sets these parameters.
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> 
> ---
> No change in v5
> 
> No change in v4
> 
> Changes in v3:
> - add SPDX and copyright and file description block
> - add todo for sys.pycache_prefix for python3.8+
> 
> Changes in v2:
> - add descriptions to python setup
> - disable pycache
> ---
>  utils/ipc/generate.py | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
>  create mode 100755 utils/ipc/generate.py
> 
> diff --git a/utils/ipc/generate.py b/utils/ipc/generate.py
> new file mode 100755
> index 00000000..8771e0a6
> --- /dev/null
> +++ b/utils/ipc/generate.py
> @@ -0,0 +1,29 @@
> +#!/usr/bin/env python3
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright (C) 2020, Google Inc.
> +#
> +# Author: Paul Elder <paul.elder@ideasonboard.com>
> +#
> +# generate.py - Run mojo code generator for generating libcamera IPC files
> +
> +import os
> +import sys
> +
> +# TODO set sys.pycache_prefix for >= python3.8
> +sys.dont_write_bytecode = True
> +
> +import mojo.public.tools.bindings.mojom_bindings_generator as generator
> +
> +def _GetModulePath(path, output_dir):
> +  return os.path.join(output_dir, path.relative_path())
> +
> +# Override the mojo code generator's generator list to only contain our
> +# libcamera generator
> +generator._BUILTIN_GENERATORS = {'libcamera': 'mojom_libcamera_generator'}
> +
> +# Override the mojo code generator's _GetModulePath method to not add
> +# the '-module' suffix when searching for mojo modules, so that we can
> +# pass the path to the mojom module without having to trim the '-module' suffix
> +generator._GetModulePath = _GetModulePath
> +
> +generator.main()
> -- 
> 2.27.0
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch
diff mbox series

diff --git a/utils/ipc/generate.py b/utils/ipc/generate.py
new file mode 100755
index 00000000..8771e0a6
--- /dev/null
+++ b/utils/ipc/generate.py
@@ -0,0 +1,29 @@ 
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (C) 2020, Google Inc.
+#
+# Author: Paul Elder <paul.elder@ideasonboard.com>
+#
+# generate.py - Run mojo code generator for generating libcamera IPC files
+
+import os
+import sys
+
+# TODO set sys.pycache_prefix for >= python3.8
+sys.dont_write_bytecode = True
+
+import mojo.public.tools.bindings.mojom_bindings_generator as generator
+
+def _GetModulePath(path, output_dir):
+  return os.path.join(output_dir, path.relative_path())
+
+# Override the mojo code generator's generator list to only contain our
+# libcamera generator
+generator._BUILTIN_GENERATORS = {'libcamera': 'mojom_libcamera_generator'}
+
+# Override the mojo code generator's _GetModulePath method to not add
+# the '-module' suffix when searching for mojo modules, so that we can
+# pass the path to the mojom module without having to trim the '-module' suffix
+generator._GetModulePath = _GetModulePath
+
+generator.main()