Git Product home page Git Product logo

build-common-api-cpp-native's Introduction

Build CommonAPI (script)

A bash script to automate building of Common API libraries.

Build Status

Originally this encoded the steps from two similar tutorials named:

"CommonAPI C++ D-Bus and SOME/IP and in 10 minutes (from scratch)"

You can find the tutorials on the associated wiki

The User Guide also provides similar and deeper information. Please follow the links to that guide from the main documentation

The script includes D-Bus and SOME/IP versions of CommonAPI C++. After running the compilation script you can choose to run either one of the simple client/server ping-pong test.

NOTE Java versions above 8 are not guaranteed to work with the code generators. Read KNOWN BUGS section.

Supported distros and container build

There is no significant testing on distros - you have to try for yourself. It was developed originally on Fedora 29.

But to have a guaranteed repeatable setup, the run_in_docker.sh script runs everything in a repeatable container setup using Docker. It uses Ubuntu 18.04 as the base but explicitly requests OpenJDK 1.8.x (i.e. Java 8) instead of what 18.04 otherwise uses by default. This is because recent Java versions seem unsupported by the current code generators and will fail with the message about "An illegal reflective operation".

The Travis build test does not invoke our docker script and runs the build script directly in whatever the environment is that Travis uses.
The travis file specifies "xenial" setup, which should be Ubuntu 16.04. I think 16.04 normally installs openjdk8 by default, but this is also specified in the Travis file.

Usage

I still recommend you go through the manual steps to learn how to do this in general - that's the idea of the tutorial of course. My purpose of storing the FIDL example files in the repository and scripting all of this is

  1. To prepare a simple automated test, repeatable, to quickly review upgrades of these components.

  2. To have a repeatable setup to use in other projects that develop using CommonAPI C++ and vSomeIP. This project can be used to set up the environment that is then used by the other development project. (Not for final product development really, but during the exploration/development of other individual software parts using these technologies)

Historical links to the original instructions:

What this does in detail

Everything is in one big script...
Of course many other ways could be done to break this apart, use proper build/make tools, avoid rebuilding what has been done successfully and so on. This is not intended for production use, in which all of those things would be set up in the actual build system being used.

This is just a crude way to test all of these parts (with continuous build/test in .travis) and get a repeatable setup:

The script does all of this:

  1. Downloads and compiles from source:
  • BOOST (vSomeIP dependency)
  • vSomeIP
  • D-Bus, libdbus (including applying some necessary patches)
  • Common API Runtimes for Core, D-Bus, and SomeIP
  1. Installs all results in a local directory! This test environment tries hard to not affect your system installation at all if run natively (but using the container version is recommended in any case).

  2. Downloads binaries for the CommonAPI C++ code generators from the official releases. Using the releases is recommended for these technologies. (Of course a project for repeatable builds of the code generators could be useful too, but it is not in scope here)

Each built/downloaded program is a fixed version, editable in the script itself when updates are needed. Please refer to the top of the build-commonapi.sh script for the versions.

  1. Provides a trivial HelloWorld client/server example for Franca IDL and simple "main.cpp" test-executables for each.

  2. Generate CommonAPI binding code for the HelloWorld example with the included code generator versions (D-Bus and SomeIP). Note: CommonAPI-for-WAMP also exists but is not yet included here.

  3. Compile the HelloWorld example code into test executables, by means of a provided simple cmake file, CMakeLists.txt

  4. Run the tests. (Notably, D-Bus is likely to fail -- see bugs section)

RUNNING EXAMPLES

When you run the compiled HelloWorld examples, please note:

  1. You might need to set the LD_LIBRARY_PATH variable to the location of the built libraries. E.g. /install/lib Do it by:
   $ export LD_LIBRARY_PATH="$PWD/install/lib:$LD_LIBRARY_PATH"

($PWD will expand correctly assuming you are standing in the project directory)

or local environment for running the program only

   LD_LIBARY_PATH="..." ./HelloWorldSomeIPService

(and so on...)

  1. If you run the docker build then the container exits after it is done building. You may want to find it in the docker list, start it, and execute a shell (or run tests directly) in the container. ALSO: READ THE BUGS SECTION! The project dir is at /workdir.

    The container is named on creation, so we can use this: buildcapicxx

$ docker ps -a
$ docker start buildcapicxx
$ docker exec -ti buildcapcixx bash

   (in container)
# cd /workdir

KNOWN BUGS

  • Running the code generators with Java version above 8 either gives warning or even error! No need to report that problem, check your java version and/or try to fix the upstream.

  • D-Bus test fails! In the run_in_docker.sh version, everything compiles but the DBus HelloWorld client program fails. This could possibly be due to docker container running unprivileged(?) or maybe the container lacks some D-Bus configuration, or possibly the correct (patched) library is not being picked up and instead the system-installed one. I have little interest in the D-Bus binding at the moment, and more in SOME/IP so if someone wants to investigate the reason and fix or report, please do so!

TODO

Please refer to GitHub Tickets.

build-common-api-cpp-native's People

Contributors

asit-dhal avatar gunnarx avatar phongt avatar zuijiawoniu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

build-common-api-cpp-native's Issues

Code generation fails (known java version incompatibility?)

The following failure occurs on a modern installation, in this case Fedora 29:

java -version
openjdk 11.0.2 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+7)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+7, mixed mode, sharing)

Once the installation script gets to the code-generation stage (code generators have been downloaded). In fact, it happens even if you check the version:

project/cgen/commonapi-generator/commonapi-generator-linux-x86_64 --version
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.eclipse.osgi.storage.FrameworkExtensionInstaller (file:/home/user/devel/GENIVI/franca_ara_integration/dependencies/build-common-api-cpp-native/project/cgen/commonapi-generator/plugins/org.eclipse.osgi_3.10.2.v20141020-1740.jar) to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of org.eclipse.osgi.storage.FrameworkExtensionInstaller
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

The text still says warning, but this also throws a dialog window which calls it an error.

When the script runs it will further report:

FAILED!  Message follows:
Command ./cgen/commonapi-generator/commonapi-generator-linux-x86_64 -sk ./fidl/HelloWorld.fidl failed -- check above for details

(and so on...)

That code generation failed is of course also later noticed and reported by the main script:

FAILED!  Message follows:
Expected result file HelloWorldDBusDeployment.cpp not present (not built)!

(repeated)

This seems to be a known issue. With openjdk-11 however, an error is reported as opposed to a warning, and no code is generated.

Assume this is just the next step of previously known java version incompatibility. This version of the code generators were made for Java 8, apparently.

Upstream issue:
COVESA/capicxx-core-tools#15

Solution: I have no other good solution but to ensure the installed java version is java 8.

I'd be happy to receive a patch from someone, that sets up a local java installation as part of the script so that the system does not need to downgrade its main installation.

SOME/IP lib not found

Hello,

While running the SOME/IP examples I got this error:

$ ./project/build/HelloWorldSomeIPClient 
[2019-07-22 15:42:30.318990] [0x00007f5e2b3cbb80] [error]   Loading failed: (libvsomeip-cfg.so.2: cannot open shared object file: No such file or directory)
Service Discovery module could not be loaded!

Doing $ export LD_LIBRARY_PATH="<PATH_TO_REPO>/vsomeip/build" fixed it. Maybe this should be added to the script?

Thank you.

Include the CommonAPI for WAMP runtime/tools

For completeness, the project should include the runtime and generators, and to generate/run test binaries also for CommonAPI for WAMP.

Note that this ticket is not an indication of a plan (by me) to do this any time soon. It is mostly documenting that this is lacking and if anyone else would like to provide this, it is of course appreciated

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.