Skip to content

Commit ec570e6

Browse files
committed
Place the version number in one file (VERSION)
1 parent d32e6d8 commit ec570e6

File tree

7 files changed

+59
-27
lines changed

7 files changed

+59
-27
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ build
1313
osi
1414
.project
1515
doc/html
16-
doc/latex
16+
doc/latex
17+
osi_version.proto
18+
version.py

CMakeLists.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
cmake_minimum_required(VERSION 3.7)
22

3-
# set name and version of the project
43
project(open_simulation_interface)
5-
set(VERSION_MAJOR 2)
6-
set(VERSION_MINOR 1)
7-
set(VERSION_PATCH 1)
84

5+
# read the version number from the file "VERSION"
6+
file(STRINGS "VERSION" VERSION_CONTENTS)
7+
foreach(LINE ${VERSION_CONTENTS})
8+
string(REGEX REPLACE " |\t" "" LINE ${LINE})
9+
string(REGEX MATCH "^[^=]+" VERSION_NAME ${LINE})
10+
string(REPLACE "${VERSION_NAME}=" "" VERSION_VALUE ${LINE})
11+
set(${VERSION_NAME} "${VERSION_VALUE}")
12+
endforeach()
13+
14+
configure_file(osi_version.proto.in ${CMAKE_CURRENT_SOURCE_DIR}/osi_version.proto)
915

1016
find_package(Protobuf 2.6.1 REQUIRED)
1117

1218
set(OSI_PROTO_FILES
19+
osi_version.proto
1320
osi_common.proto
1421
osi_datarecording.proto
1522
osi_detectedlandmark.proto

VERSION

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
VERSION_MAJOR = 2
2+
VERSION_MINOR = 2
3+
VERSION_PATCH = 0

osi_common.proto

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,6 @@ option optimize_for = SPEED;
44

55
package osi;
66

7-
//
8-
// \brief The interface version number.
9-
//
10-
// The field containing the version number. Should be left on default, not to be modified by sender.
11-
// Increments will happen as part of changes to the whole interface.
12-
//
13-
message InterfaceVersion
14-
{
15-
// Major version number.
16-
//
17-
optional uint32 major = 1 [default = 2];
18-
19-
// Minor version number.
20-
//
21-
optional uint32 minor = 2 [default = 1];
22-
23-
// Patch version number.
24-
//
25-
optional uint32 patch = 3 [default = 1];
26-
}
277

288
//
299
// \brief A cartesian 3D vector for positions, velocities or accelerations.
@@ -238,6 +218,7 @@ message BaseMoving
238218
optional Vector3d position = 2;
239219

240220
// The relative orientation of the object w.r.t its parent frame.
221+
//
241222
optional Orientation3d orientation = 3;
242223

243224
// The relative velocity of the object w.r.t. its parent frame and parent velocity.

osi_groundtruth.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ syntax = "proto2";
22

33
option optimize_for = SPEED;
44

5+
import "osi_version.proto";
56
import "osi_common.proto";
67
import "osi_environment.proto";
78
import "osi_landmark.proto";

osi_version.proto.in

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
syntax = "proto2";
2+
3+
option optimize_for = SPEED;
4+
5+
package osi;
6+
7+
//
8+
// \brief The interface version number.
9+
//
10+
// The field containing the version number. Should be left on default, not to be modified by sender.
11+
// Increments will happen as part of changes to the whole interface.
12+
//
13+
message InterfaceVersion
14+
{
15+
// Major version number.
16+
//
17+
optional uint32 major = 1 [default = @VERSION_MAJOR@];
18+
19+
// Minor version number.
20+
//
21+
optional uint32 minor = 2 [default = @VERSION_MINOR@];
22+
23+
// Patch version number.
24+
//
25+
optional uint32 patch = 3 [default = @VERSION_PATCH@];
26+
}

setup.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,21 @@
99
from setuptools import setup
1010
from setuptools.command.install import install
1111

12+
# configure the version number
13+
from shutil import copyfile
14+
copyfile('VERSION', 'version.py')
15+
from version import *
16+
with open("osi_version.proto.in", "rt") as fin:
17+
with open("osi_version.proto", "wt") as fout:
18+
for line in fin:
19+
lineConfigured = line.replace('@VERSION_MAJOR@',str(VERSION_MAJOR))
20+
lineConfigured = lineConfigured.replace('@VERSION_MINOR@',str(VERSION_MINOR))
21+
lineConfigured = lineConfigured.replace('@VERSION_PATCH@',str(VERSION_PATCH))
22+
fout.write(lineConfigured)
23+
1224
package_name = 'osi'
1325
package_path = os.path.join(os.getcwd(), package_name)
1426

15-
1627
class GenerateProtobuf(install):
1728

1829
@staticmethod
@@ -33,6 +44,7 @@ def find_protoc():
3344
return protoc
3445

3546
osi_files = (
47+
'osi_version.proto',
3648
'osi_common.proto',
3749
'osi_datarecording.proto',
3850
'osi_detectedlandmark.proto',
@@ -74,7 +86,7 @@ def run(self):
7486

7587
setup(
7688
name='open-simulation-interface',
77-
version='2.1.1',
89+
version=str(VERSION_MAJOR)+'.'+str(VERSION_MINOR)+'.'+str(VERSION_PATCH),
7890
description='A generic interface for the environmental perception of'
7991
'automated driving functions in virtual scenarios.',
8092
author='Carlo van Driesten, Timo Hanke, Nils Hirsenkorn,'

0 commit comments

Comments
 (0)