Wiki

Clone wiki

occam-web / Beginners-Guide / 5.Building-the-Dummy-Program

PREVIOUS: Defining the Object Output

Building the OCCAM object

Having our OCCAM object configured with all of the inputs and outputs required to run our dummy program, the next step is to tell OCCAM how to build it.

Create a build file

In order to build the object, particularly our dummy simulator, we will create a build script in our object. In order to do that, navigate into the object folder, and create the build.sh file:

$ touch ~/occam_workspace/simulator-ExampleSim/build.sh

Using your favourite text editor, change the file contents to:

# Install dependencies
apt-get install -y build-essential libjsoncpp-dev
# Go into the program directory
cd dummy_program
# Compile the simulator
g++ -o dummy -std=c++11 main.cpp -ljsoncpp

Note: If you need other software (e.g. Java) you must install it with this script.

Edit object.json

Now that we have created the build script, we need to tell OCCAM how to use it. In order to do that, we need to edit the object description file (object.json) to look like this:

"architecture": "x86-64",
"environment": "ubuntu:14.04",
"build": {
    "script": "build.sh",
    "language": "bash"
}

The following two lines tell OCCAM which architecture and environment it needs to use:

"architecture": "x86-64",
"environment": "ubuntu:14.04",
Note: it is assumed you followed the installation instructions on this wiki, and already have the ubuntu:14.04 environment.

And the last section, tells OCCAM which file it needs to run using which language:

"build": {
    "script": "build.sh",
    "language": "bash"
}

Your object description file (object.json) should look like this:

{
    "type": "simulator",
    "id": "95fdb476-8984-11e6-8e21-1c1b0d0a9044",
    "name": "ExampleSim",
    "configurations": [
        {
            "schema": "config_schema.json",
            "file": "input.json",
            "name": "Configuration Options"
        }
    ],
    "inputs": [
        {
            "type": "volume"
        }
    ],
    "outputs": [
        {
            "createIn": "new_output",
            "file": "statistics.json",
            "schema": "output_schema.json",
            "type": "application/json"
        }
    ],
    "architecture": "x86-64",
    "environment": "ubuntu:14.04",
    "build": {
        "script": "build.sh",
        "language": "bash"
    }
}

Committing the changes

After the changes are made, don't forget to commit them.

$ git add build.sh
$ git add object.json
$ git commit -am "Added building script"
$ occam commit

Build the object

Finally, we can build our OCCAM object. In order to do that, run the following command:

$ occam build

Note: whenever you commit a new version of the object, you need execute the build command before you can use it!

NEXT: Running the Dummy Program

Updated