Skip to content

Commit

Permalink
Move protobuf/gRPC support to new file structure
Browse files Browse the repository at this point in the history
Signed-off-by: Gunnar Andersson <[email protected]>
  • Loading branch information
gunnar-mb committed Jan 7, 2025
1 parent 703c711 commit 3a9a567
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#!/bin/bash

# A small test script to use https://github.com/COVESA/uservices
# as a quite comprehensive input test suite, (it is defined in protobuf/gRPC IDL)
# and convert as much as possible using the protobuf/grpc->IFEX converter

# Normalize current directory
cd "$(dirname "$0")"

P2I=../input_filters/protobuf_to_ifex.py

# Clone if not existing
if [ ! -d uservices ] ; then
(set -x ; git clone https://github.com/COVESA/uservices)
Expand All @@ -17,7 +23,7 @@ echo "Running protobuf_to_ifex on all uservices proto files"
find uservices/ -name '*.proto' | while read f ; do
echo "=== $f ==="
ifexname="$(echo "$(basename "$f")" | sed 's/.proto/.ifex/g')"
python protobuf_to_ifex.py "$f" >".output/$ifexname"
python $P2I "$f" >".output/$ifexname"
if [ $? -eq 0 ] ; then
echo "$f" >>.ok
else
Expand Down
File renamed without changes.
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 models.ifex.ifex_ast_construction import add_constructors_to_ifex_ast_model, ifex_ast_as_yaml
from other.protobuf.protobuf_lark import create_proto_ast
from models.protobuf.protobuf_lark import create_proto_ast
import models.ifex.ifex_ast as ifex
import other.protobuf.protobuf_ast as pb
import models.protobuf.protobuf_ast as pb
import os
import sys

Expand Down
8 changes: 5 additions & 3 deletions other/protobuf/README.md → models/protobuf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
- `protobuf_lark.py` - Input parser, creates Protobuf AST
- `protobuf_ast.py` - Dataclass definitions for a Protobuf AST
- `protobuf_ast_construction.py` - Define helper functions that build AST nodes
- `protobuf_to_ifex.py` - AST Model-to-model transformation Protobuf->IFEX

## How to run

For simple conversions or tests, the protobuf_to_ifex.py has a main method and can be run as a script directly. It will print out the
result as IFEX Core IDL in YAML text:
Go to input_filters/protobuf directory to find the converter.

For simple conversions or tests, the protobuf_to_ifex.py has a main method and
can be run as a script directly. It will print out the result as IFEX Core IDL
in YAML text:

```
python protobuf_to_ifex.py <input.proto>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from dataclasses import is_dataclass
from models.ifex.type_checking_constructor_mixin import add_constructor
import other.protobuf.protobuf_ast as protobuf_ast
import models.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
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 other.protobuf.protobuf_ast import Option, EnumField, Enumeration, MapField, Field, Import, Message, RPC, Service, Proto
from models.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 other.protobuf.protobuf_ast_construction as protobuf_ast_construction
import models.protobuf.protobuf_ast_construction as protobuf_ast_construction
protobuf_ast_construction.add_constructors_to_protobuf_ast_model()

# Remove lines matching regexp
Expand Down
2 changes: 1 addition & 1 deletion packaging/entrypoints/protobuf_ifex.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# User-invocation script for protobuf-to-ifex

from other.protobuf import protobuf_to_ifex
from input_filters.protobuf import protobuf_to_ifex
import argparse

def protobuf_to_ifex_run():
Expand Down

0 comments on commit 3a9a567

Please sign in to comment.