Event Store logo

sss https://eventstore.org Menu

Developer Blog

Easier Development Builds on Unix-like Operating Systems

  |   Written by: James Nugent   |   Tutorials

A common complaint we’ve heard about Event Store since it was originally open sourced is that it’s complex to make development builds locally - and they were slow - and thus the project was hard to contribute to. As part of our recent work on Event Store v3.1.0 (more on this in another post) we decided to rectify this.

Event Store is primarily written in C#, and builds on Mono on Linux and MacOS and the CLR. However, to support custom projections we have a library named js1, which uses the Google V8 JavaScript engine, and consequently have to build that, as well as the interop code which allows us to use it from managed code.

Being C++, this is platform specific code, so we had to deal with the fact that the standard compiler is different on all of the major platforms we support (GCC on Linux, Clang/LLVM on macOS, and Visual C++ on Windows). V8 imparts its own requirements - it has it’s own build system named “gyp” which in turn makes use of Python. On Windows that requires a Unix-like environment in the form of Cygwin.

The Event Store build system has been through a number of iterations. The one in place for the longest used Powershell on Windows and Bash on Linux and macOS, and allowed building the entire codebase including all of the dependencies with a single command, assuming that a C++ compiler, C# compiler, git and Subversion (for V8 and it’s dependencies) were available.

Most of the 20 minute plus build was in building V8 and the ICU libraries, however we rarely change the version of V8 we target. Our wrapper code tends only to change when bug fixing (such as the changes in XXXXXXX for const correctness), or when upgrading V8. Consequently we decided to build libjs1 for all of our target platforms and check the resulting binaries into the repository.

This has cut the build time down to seconds, provided you are running either on Ubuntu 14.04 (LTS), Amazon Linux 2015.03, macOS 10.10 or Windows, and means the only dependencies for building are git and either Mono or the CLR build tools. To us this seems like a worthwhile tradeoff for the increased size of the repository - after all cloning is an infrequent operation, and if it is, shallow clones can often be used. As part of this we also dropped support for building binaries for 32-bit CPUs.

Building on supported platforms

# Building Event Store from source using a pre-built libjs1
$ git clone https://github.com/EventStore/EventStore
$ cd EventStore
$ ./build.sh [<version=>] [<configuration=release>] [<distro-platform-override>]

The version number must be a full, four part CLR-compatible version number (we use the semantic version number with 0 as the last component). The configuration can be either debug or release, depending on whether you want the DEBUG flag to be defined at build time. The distro-platform-override can be used to override the operating system detection which determines the version of libjs1 which will be used. It will take the form of something like ubuntu-14.04 or osx-10.10.

The output will be produced in bin/, relative to the root of the repository, and can either be run directly with Mono, or be statically linked with the Mono framework using the scripts in scripts/package-mono.

If you are running an operating system other than Ubuntu 14.04 (LTS), Amazon Linux 2015.03 or macOS 10.10, you will first need to compile libjs1 - see instructions below.

Building on unsupported platforms

If you need to build on another platform or are working on code which modifies libjs1 or upgrades V8, there are scripts which detect the operating system and variant (for Linux and macOS) and ensure the libjs1 binaries end up in the correct place in the build tree. If you need to build for such a platform you still need to meet the dependencies of building V8 - a C++ compiler, subversion and git all on $PATH.

Building libjs1 on macOS

$ git clone https://github.com/EventStore/EventStore
$ scripts/build-js1/build-js1-mac.sh

The libjs1.dylib binary will be built and moved to src/libs/ directory tree, under the appropriate platform directory.

Once this is complete, the standard build instructions (above) can be used to compile the rest of Event Store.

Building libjs1 on Linux

$ git clone https://github.com/EventStore/EventStore
$ scripts/build-js1/build-js1-linux.sh [werror=no]

Setting werror=no may be necessary if the version of GCC installed produces warnings as errors whilst compiling V8. The libjs1.so binary will be built and moved to src/libs/ directory tree, under the appropriate platform directory.

Once this is complete, the standard build instructions (above) can be used to compile the rest of Event Store.

Subscribe to the Event Store blog

Get the latest news and tutorials when they are released

You might also like

    Data ingestion with Logstash and EventStore

      |   Written by: Riccardo Di Nuzzo   |   Tutorials

    In this post our challenge is to load a CSV file and ingest it using the Event Store HTTP API to be ingested. To be precise, we want to convert this: ```csv Europe,Italy,Clothes,Online,M,12/17/2013,278155219,1/10/2014,1165,109.28,35.84,127311.20,41753.60,85557.60 ``` To this (which is an example of an HTTP POST to the Event Store HTTP API): ```shell [ { "eventId": "fbf4b1a1-b4a3-4dfe-a01f-ec52c34e16e4", "eventType": "InboundDataReceived", "data": { "message": "Europe,Italy,Clothes,Online,M,12/17/2013,278155219,1/10/2014,1165,109.28,35.84,127311.20,41753.60,85557.60" }, "metadata": { "host": "box-1", "path": "/usr/data/sales.csv" } } ] ``` In this example...

    Read article

    Playing with Projections

      |   Written by: Chris Ward   |   Tutorials

    Projections are common concept in event sourcing that allow you to create queries of your events and streams of events. Last year I attended Michel Grootjans's "[playing with projections](https://github.com/michelgrootjans/playing_with_projections)" workshop that taught attendees how to create projections in a variety of programming languages. I decided to convert the workshop exercises to use [Event Store's internal projections](/docs/projections/index.html) engine and show how to use our projections API. The data set is player interactions with a quiz. Visit...

    Read article

    Catch-up subscriptions with the Event Store

      |   Written by: James Nugent   |   Tutorials

    We have had many questions about how to use the catch-up subscriptions in the C# Event Store Client API. In this post I’ll build out a simple example of a console application which receives a callback each time an event is written to the built-in statistics stream. Contrary to what some have thought, catch-up subscriptions are implemented as part of the client, and have been available in the client API version 1.1.0 which has been...

    Read article