mirror of
https://github.com/D4C1-Labs/Flipper-ARF.git
synced 2026-04-29 09:55:12 +00:00
118 lines
2.7 KiB
Python
118 lines
2.7 KiB
Python
load("@rules_proto//proto:defs.bzl", "proto_library")
|
|
load("@rules_python//python:defs.bzl", "py_binary")
|
|
load("@nanopb_pypi//:requirements.bzl", "requirement")
|
|
load("@rules_proto_grpc//:defs.bzl", "proto_plugin")
|
|
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
|
|
load("//extra/bazel:nanopb_cc_proto_library.bzl", "cc_nanopb_proto_library")
|
|
load("@rules_python//python/pip_install:requirements.bzl", "compile_pip_requirements")
|
|
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
licenses(["notice"])
|
|
|
|
exports_files(["LICENSE.txt"])
|
|
|
|
cc_library(
|
|
name = "nanopb",
|
|
srcs = [
|
|
"pb_common.c",
|
|
"pb_decode.c",
|
|
"pb_encode.c",
|
|
],
|
|
hdrs = [
|
|
"pb.h",
|
|
"pb_common.h",
|
|
"pb_decode.h",
|
|
"pb_encode.h",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
copy_file(
|
|
name = "protoc-gen-nanopb.py",
|
|
src = "generator/protoc-gen-nanopb",
|
|
out = "generator/protoc-gen-nanopb.py",
|
|
allow_symlink = True,
|
|
)
|
|
|
|
py_binary(
|
|
name = "protoc-gen-nanopb",
|
|
srcs = glob([
|
|
"generator/**/*.py",
|
|
]) + [
|
|
":protoc-gen-nanopb.py",
|
|
],
|
|
data = glob([
|
|
"generator/**/*.proto",
|
|
]),
|
|
imports = [
|
|
"generator",
|
|
],
|
|
deps = [
|
|
requirement("grpcio-tools"),
|
|
],
|
|
)
|
|
|
|
proto_plugin(
|
|
name = "nanopb_plugin",
|
|
options = [
|
|
'--library-include-format=quote',
|
|
],
|
|
outputs = [
|
|
"{protopath}.pb.h",
|
|
"{protopath}.pb.c",
|
|
],
|
|
separate_options_flag = True,
|
|
tool = ":protoc-gen-nanopb",
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
proto_library(
|
|
name = "descriptor",
|
|
srcs = [
|
|
"generator/proto/google/protobuf/descriptor.proto",
|
|
],
|
|
strip_import_prefix = "generator/proto/",
|
|
)
|
|
|
|
proto_library(
|
|
name = "nanopb_proto",
|
|
srcs = [
|
|
"generator/proto/nanopb.proto",
|
|
],
|
|
strip_import_prefix = "generator/proto/",
|
|
deps = [":descriptor"],
|
|
)
|
|
|
|
cc_nanopb_proto_library(
|
|
name = "test_compilation",
|
|
protos = [":descriptor"],
|
|
visibility = ["//visibility:private"],
|
|
)
|
|
|
|
proto_library(
|
|
name = "all_types_proto",
|
|
srcs = ["tests/alltypes/alltypes.proto"],
|
|
)
|
|
|
|
cc_nanopb_proto_library(
|
|
name = "all_types_nanopb",
|
|
protos = [":all_types_proto"],
|
|
nanopb_options_files = ["tests/alltypes/alltypes.options"],
|
|
visibility = ["//visibility:private"],
|
|
)
|
|
|
|
cc_test(
|
|
name = "bazel_options_support",
|
|
srcs = ["tests/bazel_options_support/bazel_options_support.cc"],
|
|
deps = [":all_types_nanopb"],
|
|
)
|
|
|
|
# Run `bazel run //:requirements.update` if you want to update the requirements.
|
|
compile_pip_requirements(
|
|
name = "requirements",
|
|
extra_args = ["--allow-unsafe"],
|
|
requirements_in = "extra/requirements.txt",
|
|
requirements_txt = "extra/requirements_lock.txt",
|
|
)
|