Skip to content

Latest commit

 

History

History
460 lines (338 loc) · 18.2 KB

BUILDING.md

File metadata and controls

460 lines (338 loc) · 18.2 KB

Building from Source

Table of Contents

General

The source code is built using CMake, the process of building uscxml is essentially the same on every platform:

  1. Read the Platform Notes below to prepare your system.

  2. Checkout uscxml into a convenient directory:

    git clone git://github.com/tklab-tud/uscxml.git

  3. Create a new directory for an out-of-source build. I usually create sub-directories in <USCXML_SRC>/build/.

  4. Run cmake (or ccmake / CMake-GUI) to create the files required by your actual build-system.

  5. Use your actual build-system or development environment to build uscxml.

  6. Optionally build the language bindings to embed the SCXML interpreter in another language.

  7. Read the SCXML draft and have a look at the tests to get started.

If you want to build for another IDE or build-system, just create a new out-of-source build directory and start over with CMake. To get an idea of supported IDEs and build-environments on your platform, type cmake --help or run the CMake-GUI and look for the Generators section at the end of the output. Default on Unices is Makefiles.

Note: If you plan to use Eclipse CDT, you cannot have a build directory anywhere under the source directory - just create the build directory anywhere else. This only applies to the Eclipse CDT project generator.

Note: You cannot build the language bindings with the Visual Studio project as it croaks when calling SWIG, just have another build directory with the "NMake Makefiles" project generator.

Build Dependencies

Overview of the uscxml dependencies. See the Platform Notes for details.

Note: We download pre-compiled versions of most dependencies at CMake configure-time. If you want to provide you own libraries, remove them from <USCXML_SRC>/contrib/prebuilt/ and provide your own.

<tr>
	<td rowspan="3"><b>Mac OSX</b></td>
		<td><a href="http://developer.apple.com/xcode/">XCode</a><br />required</td>
		<td>4.2.1 works</td>
		<td>Apples SDK with all the toolchains.</td></tr>
	<tr>
		<td><a href="http://www.macports.org/">MacPorts</a><br />recommended</td>
		<td>>= 2.0.3</td>
		<td>Build system for a wide selection of open-source packages.</td></tr>
	<tr>
		<td><a href="http://www.xmlsoft.org">libxml2</a><br />pre-installed</td>
		<td>>= 2.6.16</td>
		<td>Actual XML parser used by Arabica.</td></tr>
</tr>

<tr>
	<td rowspan="1"><b>Linux</b></td>
		<td><a href="http://www.xmlsoft.org">libxml2</a><br />required</td>
		<td>>= 2.6.16</td>
		<td>Actual XML parser used by Arabica.</td></tr>
</tr>

<tr>
<td rowspan="1"><b>Windows</b></td>
	<td<a href="http://www.microsoft.com/visualstudio/en-us">Visual&nbsp;Studio&nbsp;10</a><br />required</td>
	<td>v10 pro works</td>
	<td>As a student, you can get your version through MSAA.</td></tr>
</tr>
PlatformDependencyVersionComment
Everyone CMake
required
>= 2.8.6 The build-system used for uscxml.
SWIG
optional
>= 2.0.6 Generates language bindings to embed uSCXML in other target languages.
libevent
pre-compiled
>= 2.1.x Event queues with callbacks and the HTTP server.
curl
pre-compiled / required
>= 7.29.0 URL downloads.
v8
pre-compiled
svn checkout ECMAScript datamodel implementation.
SWI Prolog
pre-compiled for unices
>= 6.3.x Prolog datamodel implementation.
glog
pre-compiled
>= 0.3.3 Logging library.
Arabica
pre-compiled
>= git checkout XML DOM / XPath / XML Events.
SQLite
optional
>= 3.7.15.2 Persistence and sqlite invoker.
OpenSceneGraph
optional
>= 3.1.X 3D invokers (scenegraph, osgconvert).
Doxygen
recommended
Used by make docs to generate documentation from source comments.

Platform Notes

The following sections will detail the preparation of the respective platforms to ultimately compile uscxml.

Mac OSX

You will have to install CMake via Macports:

sudo port install cmake

The rest is pre-installed or downloaded at configure-time as pre-compiled libraries. Just download the source and invoke CMake to create Makefiles or a Xcode project.

Console / Make

$ cd <USCXML_SRCDIR>
$ mkdir -p build/cli && cd build/cli
$ cmake ../..
[...]
-- Build files have been written to: .../build/cli
$ make

You can test whether everything works by starting the uscxml-browser with a test.scxml file:

$ ./bin/uscxml-browser ../../test/uscxml/test-ecmascript.scxml

Xcode

$ cd <USCXML_SRCDIR>
$ mkdir -p build/xcode && cd build/xcode
$ cmake -G Xcode ../..
[...]
-- Build files have been written to: .../build/xcode
$ open uscxml.xcodeproj

You can of course reuse the same source directory for many build directories.

Linux

Depending on your distribution, you will most likely have apt-get or yum available as package managers. If you do not, I'll have to assume that you are knowledgable enough to resolve build dependencies on your own.

Preparing apt-get based distributions

This would be all distributions based on Debian, like Ubuntu, Linux Mint and the like.

# build system and compiler
$ sudo apt-get install git cmake cmake-curses-gui make g++

# uscxml required dependencies
$ sudo apt-get install libxml2-dev libcurl4-openssl-dev

There may still be packages missing due to the set of dependencies among packages in the various distributons. Try to run CMake and resolve dependencies until you are satisfied.

Preparing yum based distributions

This would be all distributions based on Redhat, e.g. Fedora.

# build system and compiler
$ sudo yum install git cmake cmake-gui gcc-c++

# uscxml required dependencies
$ sudo yum install xml2-devel libcurl-devel

Fedora 20

Here is a complete walk-through to get uscxml running on Fedora 20, starting with the net installer.

# get us git and the developer tools
$ sudo yum install git gcc-c++ cmake

# uscxml required dependencies
$ sudo yum install libxml2-devel libcurl-devel

This is sufficient to get uscxml to build. If you want some more functionality, install some more libraries:

# SWI prolog datamodel
$ sudo yum install pl-devel

# OpenAL invoker
$ sudo yum install openal-soft-devel libsndfile-devel

# scenegraph and osgconvert invoker
$ sudo yum install OpenSceneGraph-devel mesa-libGL-devel

# ffmpeg invoker (add repository from http://rpmfusion.org)
$ sudo yum install ffmpeg-devel ffmpeg-compat-devel

# calendar invoker
$ sudo yum install libical-devel

# expect invoker
$ sudo yum install expect-devel tk-devel

# instant messaging invoker
$ sudo yum install libpurple-devel

Console / Make

Instructions are a literal copy of building uscxml for MacOSX on the console from above:

$ cd <USCXML_SRCDIR>
$ mkdir -p build/cli && cd build/cli
$ cmake ../..
[...]
-- Build files have been written to: .../build/cli
$ make

You can test whether everything works by starting the uscxml-browser with a test.scxml file:

$ ./bin/uscxml-browser ../../test/uscxml/test-ecmascript.scxml

Eclipse CDT

Note: Eclipse does not like the project to be a subdirectory in the source. You have to choose your build directory with the generated project accordingly.

$ mkdir -p ~/Desktop/build/uscxml/eclipse && cd ~/Desktop/build/uscxml/eclipse
$ cmake -G "Eclipse CDT4 - Unix Makefiles" <USCXML_SRCDIR>
[...]
-- Build files have been written to: .../build/uscxml/eclipse

Now open Eclipse CDT and import the out-of-source directory as an existing project into workspace, leaving the "Copy projects into workspace" checkbox unchecked. There are some more detailed instruction available in the CMake wiki as well.

Windows

Building from source on windows is somewhat more involved and instructions are necessarily in prose form. These instructions were created using Windows 7 and MS Visual Studio 2010.

Prepare compilation

  1. Use git to checkout the source from git://github.com/tklab-tud/uscxml.git into any convenient directory.

  2. Start the CMake-GUI and enter the checkout directory in the "Where is the source code" text field. Choose any convenient directory to build the binaries in.

  3. Hit "Configure" and choose your toolchain and compiler - I only tested with Visual Studio 10. Hit "Configure" again until there are no more red items in the list. If these instructions are still correct and you did as described above, you should be able to "Generate" the Visual Project Solution.

Now you can generate the MS Visual Studio project file <USCXML_BUILDIR>/uscxml.sln. Just open it up to continue in your IDE.

Note: We only tested with the MSVC compiler. You can try to compile with MinGW but you would have to build all the dependent libraries as well.

Note: We do no provide prebuilt dependencies for MSVC18.x (Visual Studio 2012 / 2013). You can still use the bindings for C#, but not the native C++ libraries.

iOS

We provide prebuilts and CMake toolchain files for iOS and the iOS simulator. The easiest way to get iOS binaries is to run:

$ pwd
<USCXML_SRC>
$ ./contrib/build-scripts/build-uscxml-ios.sh

This will build uSCXML with the latest iOS SDK that is installed on your system. If you prefer an older SDK, you can export IOS_SDK_VERSION=6.1 but you have to make sure it's actually installed. Have a look at the build script and the toolchain files at contrib/cmake/CrossCompile-* if you run into issues.

The build script above will build a universal binary for simulator and device, both in release and debug configuration. If you just want a specific configuration for e.g. the simulator, you can invoke CMake yourself:

$ pwd
<USCXML_SRC>
$ mkdir build/iossim && cd build/iossim
$ cmake -DCMAKE_TOOLCHAIN_FILE=../../contrib/cmake/CrossCompile-iOS-Sim.cmake ../..
$ make -j4 

Note: We did not compile the prebuilts for iOS with 64Bit yet. As such, you will not get binaries build for arm64. The main culprit is, again, curl which assumes the size of an int to be the identical.

Raspberry Pi

To compile uSCXML on Raspberry Pi you will need to, at a minimum, install the following packages. This assumes that you run Raspberry, the Debian variant.

$ sudo apt-get install cmake libxml2-dev libcurl4-gnutls-dev

Now you can compile uSCXML like on any other platform:

$ git clone --depth 1 https://github.com/tklab-tud/uscxml.git
$ mkdir -p uscxml/build/raspberry && cd uscxml/build/raspberry
$ cmake ../..
$ make

If you want an ECMAScript datamodel or LUA, you will need to install additional packages:

# additional datamodels: ECMAScript, LUA, Prolog
$ sudo apt-get install libjavascriptcoregtk-3.0-dev liblua5.2-dev swi-prolog-nox

# additional invokers
$ sudo apt-get install libical-dev libpurple-dev libopenal-dev libsndfile1-dev libopenscenegraph-dev

Lastly, to get the language bindings install SWIG and the developer kits of the respective language. Older Java versions will work as well (>= 1.5), just make sure JAVA_HOME is set correctly.

# language bindings: Java, CSharp
$ sudo apt-get install swig ant oracle-java8-jdk mono-mcs
$ echo $JAVA_HOME
/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt

Note: The version of the V8 JavaScript engine in Raspbian is not compatible with uSCXML.

Language Bindings

In order to build any language bindings, you will need to have SWIG and the development kit of your target language installed. The set of available language bindings is printed at the end of the CMake invocation:

$ cmake <USCXML_SRC>
...
--   Available custom elements ...... : respond file postpone fetch 
--   Available language bindings .... : csharp java
-- General information:
...

Java

We are relying on CMake's FindJNI.CMake module to find the JNI headers and respective libraries. On unices, it's easiest to check whether jni.h is available in JAVA_HOME:

$ find $JAVA_HOME -name jni.h
/usr/lib/jvm/java-7-openjdk-i386/include/jni.h

In addition, you will need apache's ant in the path or in $ENV{ANT_HOME}/bin:

$ ant -version
Apache Ant(TM) version 1.8.2 compiled on September 22 2011

If both of these are given, you ought to get java as an available language binding and a new target called java for your build system. If you used plain Makefiles (default on unices), you will get everything you need via:

$ make && make java
$ ls lib/*.jnilib lib/*.jar
lib/libuscxmlNativeJava64.jnilib lib/uscxml.jar

The uscxml.jar is to be added to your project's classpath, while the libuscxmlNativeJava64.jnilib (or .so, .dll) needs to be loaded once via System.load() before you can use native objects.

CSharp

For the CSharp bindings, we need to find either csc.exe from the Microsoft.NET framework or dmcs from the mono project. We search the following places for these:

$ENV{CSC_HOME}; $ENV{DMCS_HOME}
"C:/Windows/Microsoft.NET/Framework/v3.5"
"C:/Windows/Microsoft.NET/Framework/v4.0.30319"

If we find one of those binaries (and SWIG obviously), we will enable the language bindings.

$ which dmcs
/opt/local/bin/dmcs

Again, if you used plain Makefiles, you will get everything you need via:

$ make && make csharp
$ find lib -type f -iname *csharp*
lib/csharp/libuscxmlNativeCSharp.so
lib/uscxmlCSharp.dll

The libuscxmlNativeCSharp.so has to be available to your C# runtime, either by installing it in /usr/local/lib or (preferred) by using LD_PRELOAD or SetDllDirectory. See the embedding examples. The uscxmlCSharp.dll contains the managed code portion and needs to be added to your C# project as a reference.

Note: You cannot use uSCXML with Xamarin Studio / Mono on Mac out of the box, as they still have no 64Bit support. The last Macintosh without 64Bit support was the (late 2006) Mac Mini with an Intel Core Duo.

Important Note for Windows

You cannot use CMake projects generated for Visual Studio to build the target language specific part of the various bindings - you have to use nmake at a command prompt. Open a Visual Studio [x64 Win64] Command Prompt (2010) and type:

> cd c:\path\to\build\dir
> cmake -G"NMake Makefiles" c:\path\to\uscxml\source
...
> nmake && nmake csharp && nmake java
...

Optional Functionality

At configure time, CMake will search for various libraries and conditionally compile only the part of uSCXML for which libraries have been found. On unices, it is straight forward to add libraries and - if you installed them to their default location - CMake will usually pick them up. On Windows, however, the process is more complicated. While we try to search in the locations where the various installers saved the header files and libraries, there are some of distributed only as an archive.

If you want to give CMake the best chance of picking up these libraries, put them into the platform prebuilt path. This path is located in <USCXML_SRC>/contrib/prebuilt/<PLATFORM>/<COMPILER>. For Windows 32bit, with MSVC this path is <USCXML_SRC>/contrib/prebuilt/windows-x86/msvc.

For instance, in order to enable the lua datamodel on windows, download the static lua libraries and save the dll in <PREBUILT>/lib/lua52.lib and the header files directly in <PREBUILT>/include/. When you run CMake for the first time, it will automatically create these paths for you.

Note: Actually, we would have to differentiate the various MSVC versions as well: v16 (VS2010) and v18 (VS2012/13) employ a different application binary interface (ABI). This is approach is taken e.g. in uMundo with msvc16 vs msvc18, but not yet realized for uSCXML.

About 32/64Bit Support

We do support both, 32 and 64Bit for Linux and Windows. On Macintosh, most prebuilt dependencies are compiled as universal binaries with 32/64Bit but we build 64Bit binaries exclusively. The reason is that e.g. curl cannot be compiled as a universal binary as its header files make assumptions about the size of an int. Furthermore, most libraries used by invokers are provided by brew or Macports will be 64Bit only and fail to link.

If you feel adventurous, you can uncomment set(CMAKE_OSX_ARCHITECTURES "i386;x86_64") in the topmost CMakeLists.txt and fight your way through the linker errors.