pw_emu: Add bazel python build

Change-Id: I5486b14072315c25e7e4df2d59f98d523ced8068
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/217053
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Commit-Queue: Austin Foxley <afoxley@google.com>
Reviewed-by: Octavian Purdila <tavip@google.com>
This commit is contained in:
Austin Foxley 2024-06-20 22:06:25 +00:00 committed by CQ Bot Account
parent d65c4f2ea2
commit b1a86a0d33

134
pw_emu/py/BUILD.bazel Normal file
View File

@ -0,0 +1,134 @@
# Copyright 2024 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
load("//pw_build:python.bzl", "pw_py_test")
py_library(
name = "pw_emu",
srcs = [
"pw_emu/__init__.py",
"pw_emu/__main__.py",
"pw_emu/core.py",
"pw_emu/frontend.py",
"pw_emu/pigweed_emulators.py",
"pw_emu/qemu.py",
"pw_emu/renode.py",
],
imports = ["."],
deps = [
"//pw_build/py:pw_build",
"//pw_env_setup/py:pw_env_setup",
"@python_packages_psutil//:pkg",
"@python_packages_pyserial//:pkg",
],
)
pw_py_test(
name = "cli_test",
srcs = [
"tests/cli_test.py",
],
imports = ["."],
main = "tests/cli_test.py",
# TODO: b/348410988 - Test relies on PW_ROOT
tags = ["manual"],
deps = [
":config_helper",
":mock_emu_frontend",
":pw_emu",
],
)
pw_py_test(
name = "core_test",
srcs = [
"tests/core_test.py",
],
data = [":mock_emu"],
main = "tests/core_test.py",
# TODO: b/348410988 - Test relies on gdb in environment
tags = ["manual"],
deps = [
":config_helper",
":mock_emu_frontend",
":pw_emu",
],
)
pw_py_test(
name = "frontend_test",
srcs = [
"tests/frontend_test.py",
],
data = [":mock_emu"],
main = "tests/frontend_test.py",
# TODO: b/348410988 - Test relies on gdb in environment
tags = ["manual"],
deps = [
":config_helper",
":mock_emu_frontend",
":pw_emu",
],
)
pw_py_test(
name = "qemu_test",
srcs = [
"tests/qemu_test.py",
],
data = [":mock_emu"],
main = "tests/qemu_test.py",
# TODO: b/348410988 - Test relies on PW_ROOT
tags = ["manual"],
deps = [
":config_helper",
":mock_emu_frontend",
":pw_emu",
],
)
pw_py_test(
name = "renode_test",
srcs = [
"tests/renode_test.py",
],
data = [":mock_emu"],
main = "tests/renode_test.py",
# TODO: b/348410988 - Test relies on PW_ROOT
tags = ["manual"],
deps = [
":config_helper",
":mock_emu_frontend",
":pw_emu",
],
)
py_binary(
name = "mock_emu",
srcs = ["mock_emu.py"],
)
py_library(
name = "config_helper",
srcs = ["tests/config_helper.py"],
imports = ["tests"],
)
py_library(
name = "mock_emu_frontend",
srcs = ["mock_emu_frontend.py"],
imports = ["."],
deps = ["//pw_env_setup/py:pw_env_setup"],
)