Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protobuf/grpc: Add proper module/script installation and CI build test #117

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/buildcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,12 @@ jobs:
run: |
python ifex/schema/ifex_to_json_schema.py >temp-schema
python ifex/schema/pretty_print_json.py temp-schema >ifex-core-idl-schema.json

- name: Clone uservices repository
run: |
git clone https://github.com/COVESA/uservices/

- name: Run protobuf->IFEX translation
run: |
ifexconv_protobuf uservices/src/main/proto/vehicle/propulsion/engine/v1/engine_service.proto >engine_service.ifex
cat engine_service.ifex
21 changes: 21 additions & 0 deletions ifex/scripts/protobuf_ifex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 MBition GmbH.
# SPDX-License-Identifier: MPL-2.0

# User-invocation script for protobuf-to-ifex

from other.protobuf import protobuf_to_ifex
import argparse

def protobuf_to_ifex_run():

parser = argparse.ArgumentParser(description='Runs Protobuf to IFEX translator.')
parser.add_argument('input', metavar='file.proto', type=str, help='path to input .proto file')

try:
args = parser.parse_args()
proto_ast = protobuf_to_ifex.proto_ast_from_input(args.input)
ifex_ast = protobuf_to_ifex.proto_to_ifex(proto_ast)
print(protobuf_to_ifex.ifex_ast_as_yaml(ifex_ast))

except Exception as e:
print(f"ERROR: Conversion error resulting from {args.input}: {e}")
Empty file added other/__init__.py
Empty file.
Empty file added other/protobuf/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion other/protobuf/protobuf_ast_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from dataclasses import is_dataclass
from ifex.model.type_checking_constructor_mixin import add_constructor
import protobuf_ast
import other.protobuf.protobuf_ast as protobuf_ast

def add_constructors_to_protobuf_ast_model() -> None:
""" Mix-in the type-checking constructor support into each of the protobuf_ast classes: """
Expand Down
4 changes: 2 additions & 2 deletions other/protobuf/protobuf_lark.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file is part of the IFEX project

from lark import Lark, logger, Tree, Token
from protobuf_ast import Option, EnumField, Enumeration, MapField, Field, Import, Message, RPC, Service, Proto
from other.protobuf.protobuf_ast import Option, EnumField, Enumeration, MapField, Field, Import, Message, RPC, Service, Proto
import lark
import re
import sys
Expand Down Expand Up @@ -39,7 +39,7 @@


# Use protobuf_construction mixin
import protobuf_ast_construction
import other.protobuf.protobuf_ast_construction as protobuf_ast_construction
protobuf_ast_construction.add_constructors_to_protobuf_ast_model()

# Remove lines matching regexp
Expand Down
4 changes: 2 additions & 2 deletions other/protobuf/protobuf_to_ifex.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# This file is part of the IFEX project

from ifex.model.ifex_ast_construction import add_constructors_to_ifex_ast_model, ifex_ast_as_yaml
from protobuf_lark import create_proto_ast
from other.protobuf.protobuf_lark import create_proto_ast
import ifex.model.ifex_ast as ifex
import protobuf_ast as pb
import other.protobuf.protobuf_ast as pb
import os
import sys

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ def get_template_files():
[console_scripts]
ifexgen=ifex.scripts.generator:ifex_generator_run
ifexgen_dbus=ifex.scripts.generator_dbus:ifex_dbus_generator_run
ifexconv_protobuf=ifex.scripts.protobuf_ifex:protobuf_to_ifex_run
'''
)
Loading