Maven/Scons for DeviceAccess

Maven can be bent to create a build cycle for C++ projects using Scons. An overview is presented here.

Quick Info

Currently the whole Maven/Scons infrastructure is located in the sub-directory maven in SVN: https://www-acc.gsi.de/svn/bel/frontend/trunk. The required projects are built in a directory structure. Related projects such as nameservice (nameserver, nsrvtcpip, nsrvclient, devicefactory, ...) are grouped together. The C++ sources are linked relative to the pom-files.

.
|-- accdata
|   |-- i386
|   |   |-- pom.xml
|   |   `-- target
|   |-- pom.xml
|   |-- ppc
|   |   |-- pom.xml
|   |   `-- target
|   `-- src
|       |-- SConscript
|       `-- svn -> ../../../accdata/
|-- accdevice
|   |-- i386
|   |   |-- pom.xml
|   |   `-- target
|   |-- pom.xml
|   |-- ppc
|   |   |-- pom.xml
|   |   `-- target
|   `-- src
|       |-- SConscript
|       `-- svn -> ../../../accdevice/
|-- alarm
|   |-- i386
|   |   |-- pom.xml
|   |   `-- target
|   |-- pom.xml
|   |-- ppc
|   |   |-- pom.xml
|   |   `-- target
|   `-- src
|       |-- SConscript
|       `-- svn -> ../../../alarm/
|-- corbaifc
|   |-- i386
|   |   |-- pom.xml
|   |   `-- target
|   |-- pom.xml
|   |-- ppc
|   |   |-- pom.xml
|   |   `-- target
|   `-- src
|       |-- SConscript
|       `-- svn -> ../../../corbaifc/
|-- cpu87
|   |-- kernel
|   |   |-- pom.xml
|   |   |-- src
|   |   `-- target
|   |-- pom.xml
|   |-- ppc
|   |   |-- pom.xml
|   |   `-- target
|   `-- src
|       |-- SConscript
|       `-- svn -> ../../../cpu87/
|-- dbs
|   |-- i386
|   |   |-- pom.xml
|   |   `-- target
|   |-- pom.xml
|   |-- ppc
|   |   |-- pom.xml
|   |   `-- target
|   `-- src
|       |-- SConscript
|       `-- svn -> ../../../dbs
|-- device
|   |-- i386
|   |   |-- pom.xml
|   |   `-- target
|   |-- pom.xml
|   |-- ppc
|   |   |-- pom.xml
|   |   `-- target
|   `-- src
|       |-- SConscript
|       `-- svn -> ../../../device
|-- devman
|   |-- i386
|   |   |-- pom.xml
|   |   `-- target
|   |-- pom.xml
|   |-- ppc
|   |   |-- pom.xml
|   |   `-- target
|   `-- src
|       |-- SConscript
|       `-- svn -> ../../../devman
|-- eq-models
|   |-- i386
|   |   |-- cia
|   |   |-- dskm
|   |   |-- dsm
|   |   |-- dsme
|   |   |-- eqps.txt
|   |   |-- lsa
|   |   |-- lsad
|   |   |-- mkeqp.sh
|   |   |-- pom.xml
|   |   |-- skeleton
|   |   `-- slits
|   |-- pom.xml
|   `-- ppc
|       |-- bc
|       |-- bcu
|       |-- cehv
|       |-- cm
|       |-- cs
|       |-- dc
|       |-- dci
|       |-- dgx
|       |-- di
|       |-- dpx
|       |-- ds
|       |-- dtc
|       |-- dti
|       |-- dttc
|       |-- dtx
|       |-- dx
|       |-- ec
|       |-- eqps.txt
|       |-- esau
|       |-- fbsd
|       |-- hfs
|       |-- hfu
|       |-- hfum
|       |-- hvdm
|       |-- ips
|       |-- iqx
|       |-- it
|       |-- mb
|       |-- md
|       |-- me
|       |-- mk
|       |-- mkeqp.sh
|       |-- ms
|       |-- mx
|       |-- pla
|       |-- pom.xml
|       |-- ppos
|       |-- pzui
|       |-- rpg
|       |-- skeleton
|       |-- sthv
|       |-- swpz
|       |-- tfs
|       |-- tg
|       |-- tgx
|       |-- ug
|       `-- vvc
|-- equinf
|   |-- pom.xml
|   |-- ppc
|   |   |-- pom.xml
|   |   `-- target
|   `-- src
|       |-- SConscript
|       `-- svn -> ../../../equinf/
|-- header
|   |-- accmsg
|   |   |-- i386
|   |   |-- noarch
|   |   |-- pom.xml
|   |   `-- src
|   |-- dependency
|   |   `-- pom.xml
|   |-- incasl
|   |   |-- pom.xml
|   |   |-- src
|   |   `-- target
|   |-- incvme
|   |   |-- pom.xml
|   |   |-- src
|   |   `-- target
|   `-- pom.xml
|-- message
|   |-- pom.xml
|   |-- src
|   |   |-- SConscript
|   |   `-- svn -> ../../../message/
|   `-- target
|       |-- SConstruct
|       |-- build
|       |-- install
|       |-- maven_scons.ini
|       |-- message-1.0.3-SNAPSHOT.zip
|       `-- site_scons
|-- nameservice
|   |-- client
|   |   |-- i386
|   |   |-- pom.xml
|   |   |-- ppc
|   |   `-- src
|   |-- devicefactory
|   |   |-- i386
|   |   |-- pom.xml
|   |   |-- ppc
|   |   `-- src
|   |-- pom.xml
|   |-- server
|   |   |-- i386
|   |   |-- pom.xml
|   |   `-- src
|   `-- tcpip
|       |-- i386
|       |-- pom.xml
|       |-- ppc
|       `-- src
|-- nativedevice
|   |-- i386
|   |   |-- pom.xml
|   |   `-- target
|   |-- pom.xml
|   |-- ppc
|   |   |-- pom.xml
|   |   `-- target
|   `-- src
|       |-- SConscript
|       `-- svn -> ../../../nativedevice/
|-- os
|   |-- i386
|   |   |-- pom.xml
|   |   `-- target
|   |-- pom.xml
|   |-- ppc
|   |   |-- pom.xml
|   |   `-- target
|   `-- src
|       |-- SConscript
|       `-- svn -> ../../../os/
|-- pom.xml
|-- subscriptionservice
|   |-- i386
|   |   |-- pom.xml
|   |   `-- target
|   |-- pom.xml
|   `-- src
|       |-- SConscript
|       `-- svn -> ../../../subscriptionservice
|-- usrs
|   |-- i386
|   |   |-- pom.xml
|   |   `-- target
|   |-- pom.xml
|   |-- ppc
|   |   |-- pom.xml
|   |   `-- target
|   `-- src
|       |-- SConscript
|       `-- svn -> ../../../usrs/
`-- vmedevice
    |-- pom.xml
    |-- ppc
    |   |-- pom.xml
    |   `-- target
    `-- src
        |-- SConscript
        `-- svn -> ../../../vmedevice/



Configuration

Useful information on how to configure everything for maven, e.g. security settings etc: https://www-acc.gsi.de/wiki/IN/Maven

Usage

Build on Command Line

  • Create/cd to a workspace
  • Checkout sources (requires valid ACC account): svn co https://www-acc.gsi.de/svn/bel/frontend/trunk
  • cd to <workspace>/trunk/maven
  • Build a dependency tree: mvn dependency:tree
  • Build the sources: mvn clean compile
  • Build the sources on several cores in parallel (faster): mvn -TC1 compile
  • Install the artifacts in the local repository: mvn (-TC1) install
  • Install the artifacts to Sonatype Nexus Repository: mvn deploy
  • Build the tests (if available): mvn test
  • Build parts of a reactor: mvn compile -am -pl :eqmodel_dsm oder mvn compile -am -pl dsm

  • Deploy the artifacts to server for release: TODO deploy to productive server
  • Change artifact version numbers: TODO change artifact versions
  • TODO ...

Import / Build In Eclipse

  • Configure Eclipse Indigo according to Configuring the Maven instance used in Eclipse
  • In Eclipse's Project Explorer:
    • Right-click and import...Maven>Existing Maven Projects
    • Browse for project to be imported in <workspace>/trunk/maven and allow Eclipse time for analysis
    • Select <project>-parents only, uncheck anything in the folders i386/ppc
    • The sources are accessible in the subfolder src/svn. The sources in <workspace>/trunk are softlinked.
    • Add the C/C++-project nature to allow auto-completion: right-click on the project, select New > Convert to a C/C++ Project (Adds C/C++ nature); select "Makefile project" and "Linux GCC Tool Chain". This adds the proper C++ include files to the project.
    • If Eclipse is properly configured and has rebuilt its indexes no errors should appear.
  • Build a project:
    • Right-click on the project-parent and select Run As
    • Select the supported Maven goal, e.g. Maven build
    • The "Edit Configuration" dialog appears if the Maven goal is selected for the first time
    • Enter a valid maven goal, e.g. compile and select the options, e.g. Skip Tests, Update Snapshots, ...
    • Clicking "Run" executes the desired Maven goal and displays the output in an Eclipse Console View.
    • Run configurations for the projects in the workspace can be edited in Run>Run Configurations...Maven Build

DeviceAccess Eclipse Plugin

Main Features
  • Import and automatic configuration of Maven/SCons projects into an Eclipse Indigo workspace
  • Automatic creation of (configurable) Maven goals for usage within Eclipse Indigo during import
  • Additional View of available Maven Goals per Maven/C++ project
Update Site

Plugin for Eclipse Indigo SR2 on RedHat6: https://www-acc.gsi.de/data/eclipse/deviceaccess
Requirements

Debugging in Eclipse

  • Add a debug configuration via Run > Debug Configurations...C/C++ Application
    • On Main Tab: select the application itself
    • On Main Tab: select Debug as Build Configuration
    • On Main Tab: disable auto build
    • On Arguments Tab: configure the required program arguments, e.g. for devman -f *.dbs
    • On Environment Tab: specify the environment variables
Name Value
ACC_NAMESERVER_HOST localhost
ACC_NAMESERVER_PORT 64291
LD_LIBRARY_PATH full path to library folder
    • On Debugger Tab: Check Use full file path to set breakpoints
    • On Debugger Tab: Check Shared Libraries>Load shared library symbols automatically
    • On Source Tab: specify the source folders if necessary (e.g. for shared libraries sources)

Build Output

During build the binaries are created in <workspace>/<project>/<platform>/target/build .

Packaging (examples)

Building an assembly with Maven

Add the maven-assembly plugin to Maven's pom.xml, e.g. devman-parent/i386/pom.xml:

<build>
  <plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.3</version>
        <configuration>
            <descriptors>
                <!-- XML file that contains the files/contents of the target package -->
                <descriptor>myAssembly.xml</descriptor>
            </descriptors>
        </configuration>
    </plugin>
  </plugins>
</build>

Command:

 mvn assembly:single (after mvn package)
Bind Assembly Build into Packaging Phase

To execute the assembly:single goal during packaging the pom needs to be configured like this:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <descriptors>
                    <!-- XML file that contains the files/contents of the target package -->
                    <descriptor>localDevmanAssembly.xml</descriptor>
                </descriptors>
                <attach>false</attach>
                <appendAssemblyId>false</appendAssemblyId>
                <finalName>foo</finalName>
            </configuration>
        <executions>
          <execution>
            <id>make-assembly</id> <!-- this is used for inheritance merges -->
            <phase>package</phase> <!-- bind to the packaging phase -->
            <goals>
              <goal>single</goal>  <!-- goal to execute during packaging phase -->
            </goals>
          </execution>
        </executions>
        </plugin>
    </plugins>
Including additional Files in an Assembly such as Start Scripts

An example of a configuration file for an assembly is presented below (myAssembly.xml). The location of such a configuration file is the same directory as the maven-pom-file of the current platform, e.g. devman/i386/.

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">

<id>localDevmanAssembly</id>

<!-- output format, e.g. zip, dir, ... -->
<formats>
  <format>dir</format>
</formats>

<includeBaseDirectory>false</includeBaseDirectory>

<!-- files / directories to be copied into the assembly -->
<fileSets>
  <fileSet>
    <directory>${basedir}/src</directory>
    <outputDirectory>/</outputDirectory>
    <includes>
      <include>solveigh.dbs</include>    <!-- device configuration -->
      <include>devman.sh</include>    <!-- start script -->
    </includes>
  </fileSet> 
</fileSets>

<dependencySets>
    <dependencySet>
        <outputDirectory>/</outputDirectory>
        <useProjectArtifact>false</useProjectArtifact>
        <unpack>true</unpack>
        <includes>
            <include>*:*:zip:*</include>
        </includes>
        <excludes>
            <exclude>*:*:zip:meta</exclude>
      <exclude>*scons*:*:zip</exclude>
        </excludes>
        <!--  not really sure, see http://jira.codehaus.org/browse/MASSEMBLY-614 , but this works -->
        <useTransitiveFiltering>false</useTransitiveFiltering>        
        <unpackOptions>
            <excludes>
                <exclude>meta.ini</exclude>
                  <exclude>include</exclude>
                  <exclude>include/**</exclude>
                  <exclude>usr/include</exclude>
                  <exclude>usr/include/**</exclude>
            </excludes>
        </unpackOptions>
    </dependencySet>
</dependencySets>

</assembly>

DeviceAccess Test environment

To test the device access software locally the following components are required:
  • .../nameservice/server/i386_test
  • .../devman/i386_test
  • device model, e.g. eq-models/i386/kgb
The test configurations contains start scripts to start the software locally using local environment variables.

Build an assembly for testing:

cd to .../nameservice/server/i386_test bzw. .../devman/i386_test
mvn -TC1 compile package assembly:single
cd to .../nameservice/server/i386_test/target/foo
start ./nameserver.sh
cd to .../devman/i386_test/target/foo
start ./devman.sh
Client for testing purposes

TODO: build client assembly with maven

Building an assembly with opkg

TODO

Uploading Schema/XML Files To Webdav Server

Prerequisite: Maven Secure settings have to be configured as descriped on: https://www-acc.gsi.de/wiki/IN/Maven

The equipment model schema files in the project usrgen are uploaded to the webdav server during the deploy phase:

cd maven/code-generation/fe-usrgen
mvn deploy

The XML files for therapy-usrs are located in the usrs project and will also be uploaded to the webdav server during the deploy phase:

cd maven/usrs
mvn deploy

The nameserver's right XSD schema is uploaded in a similar way.

Software Configuration

Environment variables such as ACC_NAMESERVER_HOST / ACC_NAMESERVER_PORT that are required for running binaries such as devman / nameserver / etc. have to be provided externally or in the start script.

Configuration files such as rights.xml or the device manager database (*.dbs) have to be provided externally and will not be contents of an assembly.

Additional Information

https://sites.google.com/site/nickfolse/eclipse-scons---simple-c-project

http://sconsolidator.com/

-- SolveighMatthies - 08 Feb 2013
Topic revision: r17 - 18 Apr 2013, SolveighMatthies
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback