Skip to content

Commit f4b0340

Browse files
authored
Merge pull request #245 from OpenSimulationInterface/feature/proto3-script
Add proto3 support via script to map file syntax
2 parents c504e32 + c015e2e commit f4b0340

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,21 @@ script:
7575
- cd build
7676
- cmake --build . --target install
7777
- cd ..
78+
- cp VERSION VERSION.SAVED
7879
- echo "" >> VERSION
7980
- echo "VERSION_PATCH = \"GitHub_MasterBranch\"" >> VERSION
8081
- cd build
8182
- cmake -D FILTER_PROTO2CPP_PY_PATH=${DEPS_DIR}/proto2cpp ..
8283
- doxygen
8384
- cd ..
8485
- python test_cases_doc.py
86+
- mv VERSION.SAVED VERSION
87+
- sh convert-to-proto3.sh
88+
- mkdir -p build3
89+
- cd build3
90+
- cmake -D CMAKE_PREFIX_PATH:PATH=${DEPS_DIR}/protobuf/install ..
91+
- cmake --build .
92+
- cd ..
8593

8694
# Deploy the documentation on github (only for master branch).
8795
deploy:

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ The compatibility of both recorded files and code remains.
7575
- Clarification of text passages explaining the message content
7676

7777

78+
Proto3 Support
79+
--------------
80+
81+
For users that need to use proto3 syntax, for example because the language
82+
binding of choice only supports proto3 syntax out of the box, a shell script
83+
called `convert-to-proto3.sh` is supplied that converts all proto files to
84+
proto3 syntax. If this is run prior to building, the resulting libaries will
85+
use proto3, with the on-the-wire format remaining compatible between proto2
86+
and proto3 libraries.
87+
7888
Packaging
7989
---------
8090

convert-to-proto3.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
# This shell script converts all proto files to proto3 syntax, which can
4+
# then be used as a stand in for the proto2 syntax files. The resulting
5+
# on-the-wire format should be compatible with the proto2-based formats
6+
# in all respects.
7+
#
8+
# Call this script prior to building normally if you want/need to use
9+
# proto3 syntax, e.g. for language bindings that do not support proto2,
10+
# like C#.
11+
12+
test -f osi_version.proto && rm osi_version.proto
13+
14+
for f in osi_version.proto.in osi_*.proto
15+
do
16+
mv $f $f.pb2 && sed -e 's/syntax *= *"proto2";/syntax = "proto3";/' -e 's/^\([ \t]*\)optional /\1/' $f.pb2 > $f
17+
done
18+
19+
mv CMakeLists.txt CMakeLists.txt.pb2 && sed -e 's/find_package(Protobuf 2.6.1 REQUIRED)/find_package(Protobuf 3.0.0 REQUIRED)/' CMakeLists.txt.pb2 > CMakeLists.txt

0 commit comments

Comments
 (0)