summaryrefslogtreecommitdiff
path: root/README
blob: 9d86af5c7372c8d6698fa1a424eb60967a35a72f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
GENIVI_CommonAPI-D-Bus
======================
:Author: Juergen Gehring - juergen.gehring@bmw.de, Manfred Bathelt - manfred.bathelt@bmw.de
:doctitle: GENIVI_CommonAPI-D-Bus

Copyright
---------
Copyright (C) 2013, GENIVI Alliance, Inc.
Copyright (C) 2013, BMW AG

This file is part of GENIVI Project IPC Common API.
 
Contributions are licensed to the GENIVI Alliance under one or more
Contribution License Agreements or MPL 2.0 .
 
(C) Copyright
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed with
this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
For further information see https://collab.genivi.org/wiki/display/genivi/SysInfraEGCommonIDLCommonAPIGuide

== License
This project is licensed under MPL 2.0

Contribution is done under GENIVI CLA or MPL2.0. 

== Version
The current version can be taken from the git.

== Common API Overview

Common API and its mechanism specific bindings (e.g. Common API D-Bus) provide a set of libraries and tools to work with 
RPC communication in a way independent of wich mechanism is used. It consist currently consists of four subprojects:
----
CommonAPI - This is the base C++ library, which provides the application interface for users and can 
            load runtime bindings such as dbus. 
CommonAPI-Tools - The eclipse based tools for CommonAPI. This is essentially the code generator for 
                  Franca -> Common API C++ code. 
CommonAPI-D-Bus - This is the D-Bus binding C++ library, which provides the necesary code to communicate 
                  over D-Bus. This is invisible to the application code, and simply needs to be linked against.
                  (This is the current package.) 
CommonAPI-D-Bus-Tools - The eclipse based tools for CommonAPI D-Bus. This is the code generator for 
                        Franca -> Common API D-Bus C++ code.
----
== Build Instructions

=== Requirements

To build this package the CommonAPI library and a version of libdbus patched with the marshaling patch must be available through PkgConfig.

Instructions for making a patched version of libdbus available in /usr/local:
----
# wget http://dbus.freedesktop.org/releases/dbus/dbus-1.4.16.tar.gz

# tar -xzf dbus-1.4.16.tar.gz

# cd dbus-1.4.16

# patch -p1 < /path/to/dbus-DBusMessage-add-support-for-custom-marshaling.patch

# ./configure --prefix=/usr/local

# make -C dbus 

# sudo make -C dbus install
# sudo make install-pkgconfigDATA
----
The path to CommonAPI and patched libdbus pkgconfig files must be added to the PKG_CONFIG_PATH for the entire build process.

For example, if CommonAPI and patched dbus are available in /usr/local, set the PKG_CONFIG_PATH variable as follows:
----
# export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" 
----

=== Instructions
Use autotools to build this package withthe above requirements available through Pkgconfig :
----
# autoreconf -i
# ./configure
# make
# sudo make install (or alternative install process, eg. checkinstall on debian-based distributions, such as Ubuntu)
----
To build the Windows version with Visual Studio, you can use the solution file CommonAPI-DBus.sln. It is configured to build CommonAPI-DBus as a static library.
Add the path of CommonAPI.lib to "Additional Library Directories"

== Linking against CommonAPI-D-Bus

CommonAPI-D-Bus requires successful activation of all static initialization code on library load. Therefore it is necessary to
activate certain linker flags to ensure this is always the case. These are specified in the pkg-config files, but are also
listed here. In case of dynamic linking (.so) --no-as-needed must be specified for the CommonAPI-D-Bus library:
----
-Wl,--no-as-needed -lCommonAPI-DBus -Wl,--as-needed 
----

In case of static linking --whole-archive must be specified:
----
-Wl,--whole-archive libCommonAPI-DBus.a -Wl,--no-whole-archive 
----

=== Linking generated proxies & stubs

Generated proxies and stubs also require successful activation of all static initialization code on load.
If they are provided in either a static or dynamic library to the application they must also be linked wrapped in the
flags described above.

=== Building and executing the Unit Tests
----
# export GTEST_CONFIG=/path/to/gtest-1.6.0/scripts/gtest-config
# autoreconf -i
# ./configure
# make check
----
In order to execute the unit tests, the test framework "Google Test" (available at https://code.google.com/p/googletest/)
needs to be available on your system. Google Test comes with a subfolder called "scripts", there you will find a file called
"gtest-config". The path to this script has to be set via the environment variable GTEST_CONFIG. After having done so,
CommonAPI and CommonAPI-D-Bus can be built and the make command "check" can be executed.

"make check" builds and executes all tests. As the tests are developed as regression tests, the test output is limited to
"OK" and "ERROR" for each test performed.


== Configuring the D-Bus middleware binding

=== Well known name
The well known name that may be used to identify and dynamically load the D-Bus middleware binding is "DBus".


=== Defining D-Bus Service Parameters
Normally, a CommonAPI address, format
----
<Domain>:<ServiceID>:<InstanceID>
----

is mapped to a D-Bus address the following way:
----
# D-Bus Interface Name = ServiceID 
# D-Bus Connection Name = InstanceID
# D-Bus Object Path = InstanceID with a preceding '/' and all '.' replaced with '/' 
----
For Domain, only the value "local" is allowed in this context, and it has no influence on the associated D-Bus service address values.

In case a proxy or a service should not use the default mapping, it is possible to define config files that use the CommonAPI Address
as a key in order to map any combination of D-Bus address values to it. The config files can be defined locally per binary, globally
per binary or globally for all binaries. If more than one config file is defined and a CommonAPI address is defined more than once
across several config files, the locally defined values override the global ones. If a CommonAPI address is defined more than once
within a single file, the first definition found will be the only definition used.

Note: Only one managing interface can be defined per D-Bus object path!

CommonAPI D-Bus Config files have to be named this way:
----
# Binary local: "<FqnOfBinary>_dbus.conf", e.g. "/usr/bin/myBinary_dbus.conf" if the binary is "/usr/bin/myBinary"
# Binary global: "/etc/CommonApiDBus/<NameOfBinary>_dbus.conf", e.g. "/etc/CommonApiDBus/myBinary_dbus.conf"
# Global: "/etc/CommonApiDBus/dbusAddresses.conf"
----

Each config file may have an arbitrary number of entries of the following format, with each entry being separated from the others by a newline:
----
[<CommonAPI Address>]
dbus_connection=<valid D-Bus Connection Name>
dbus_object=<valid D-Bus Object Path>
dbus_interface=<valid D-Bus Interface Name>
dbus_predefined=<true/false>
----
All "dbus_*"-values are optional. For each such omitted value the default value as described above will be used. For "dbus_predefined",
the default value is "false".

"dbus_predefined" should be used if the associated service of a proxy is a legacy service that does not provide the
"org.freedesktop.DBus.ObjectManager" interface.
----
# If "dbus_predefined" is set to "false" (which is default), a proxy will try to verify the existence of the specific interface
  at the specific connection name and object path, using the "org.freedesktop.DBus.ObjectManager" interface, before it is marked as available.
# If "dbus_predefined" is set to "true", a proxy is marked as available as soon as the connection name of the associated
  service is visible. No further checks will be performed.
----

=== Defining D-Bus Factory Parameters
If a section in a config file starts with "factory$", it defines a factory configuration, which can be referred to at factory creation.
The name of the factory configuration follows the $ sign.
----
[factory$<Factory Name>]
dbus_bustype=<valid D-Bus Bustype>
----
All "dbus_*"-values are optional. For each such omitted value the default value as described below will be used. 

# dbus_bustype may be set to "session" or "system" for communication on the user's session bus or on the system wide bus. The default value is "session"

== Remarks on Windows version

On Windows systems there are some drawbacks:
# Calling disconnect and later connect on the same DBusConnection somehow damages the libdbus connection. On Linux
implementation this all works fine.
# The DBusLoadTest revealed that a number of more than about 50 proxies slows down the dbus communication
significantly. That's why we run the DBusLoadTest on windows with just 50 instead of 100 proxies.

== Working on the code & contribution

.First get the code from the git:
        git clone 

.Get an overview of all branches:
        git branch

.Switch to the branch you want to work on (master is the feature branch) and verify that it has switched (* changed)
        git checkout <your branch>
        git branch

.Best practice is to create a local branch based on the current branch:
        git branch working_branch

Start working, best practice is to commit smaller, compilable pieces during the development process that makes it easier to handle later on.

.If you want to commit you changes, send them to the author, you can create a patch like this:
        git format-patch working_branch <your branch>

This creates a set of patches that are published via the mailing list.The patches will be discussed and then merged & uploaded on the git by the maintainer.

Patches can be accepted either under GENIVI Cla or MPL 2.0 (see section License). Please be sure that the signed-off-by is set correctly. For more, check out http://gerrit.googlecode.com/svn/documentation/2.0/user-signedoffby.html