Skip to content

Commit

Permalink
pw_emu: Add user APIs and the command line interface
Browse files Browse the repository at this point in the history
Add the user APIs, the command line interface, as well as related
tests and documentation.

Change-Id: I8990acc938dc918331508fc18fb1b2863d9adeed
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/173611
Presubmit-Verified: CQ Bot Account <[email protected]>
Commit-Queue: Octavian Purdila <[email protected]>
Reviewed-by: Armando Montanez <[email protected]>
  • Loading branch information
tavip authored and CQ Bot Account committed Oct 13, 2023
1 parent dd397f9 commit 842b244
Show file tree
Hide file tree
Showing 11 changed files with 1,227 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pigweed.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"module": "pw_system.console",
"function": "main"
},
"emu": {
"module": "pw_emu.__main__",
"function": "main"
},
"format": {
"module": "pw_presubmit.format_code",
"function": "main"
Expand Down
1 change: 1 addition & 0 deletions pw_cli/py/pw_cli/pw_command_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def _register_builtin_plugins(registry: plugins.Registry) -> None:
# Register these by name to avoid circular dependencies.
registry.register_by_name('bloat', 'pw_bloat.__main__', 'main')
registry.register_by_name('doctor', 'pw_doctor.doctor', 'main')
registry.register_by_name('emu', 'pw_emu.__main__', 'main')
registry.register_by_name('format', 'pw_presubmit.format_code', 'main')
registry.register_by_name('keep-sorted', 'pw_presubmit.keep_sorted', 'main')
registry.register_by_name('logdemo', 'pw_cli.log', 'main')
Expand Down
3 changes: 3 additions & 0 deletions pw_emu/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ API reference
:name: pw_emu
:tagline: Emulators frontend

.. automodule:: pw_emu.frontend
:members:

.. automodule:: pw_emu.core
:noindex:
:members:
Expand Down
8 changes: 8 additions & 0 deletions pw_emu/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ CLI reference
.. pigweed-module-subpage::
:name: pw_emu
:tagline: Pigweed emulator frontend

.. argparse::
:module: pw_emu.__main__
:func: get_parser
:prog: pw emu
:nodefaultconst:
:nodescription:
:noepilog:
4 changes: 4 additions & 0 deletions pw_emu/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ how to access the emulator channels (e.g. socket ports, pty paths)
.. mermaid::

graph TD;
TemporaryEmulator & pw_emu_cli[pw emu cli] <--> Emulator
Emulator <--> Launcher & Connector
Launcher <--> Handles
Connector <--> Handles
Launcher <--> Config
Expand All @@ -28,6 +30,8 @@ how to access the emulator channels (e.g. socket ports, pty paths)

The implementation uses the following classes:

* :py:class:`pw_emu.frontend.Emulator`: the user visible API

* :py:class:`pw_emu.core.Launcher`: an abstract class that starts an
emulator instance for a given configuration and target

Expand Down
4 changes: 4 additions & 0 deletions pw_emu/py/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ pw_python_package("py") {
]
sources = [
"pw_emu/__init__.py",
"pw_emu/__main__.py",
"pw_emu/core.py",
"pw_emu/frontend.py",
"pw_emu/pigweed_emulators.py",
]
tests = [
"tests/__init__.py",
"tests/cli_test.py",
"tests/common.py",
"tests/core_test.py",
"tests/frontend_test.py",
]
pylintrc = "$dir_pigweed/.pylintrc"
mypy_ini = "$dir_pigweed/.mypy.ini"
Expand Down
Loading

0 comments on commit 842b244

Please sign in to comment.