aboutsummaryrefslogtreecommitdiffstats
path: root/vagrant/README.md
blob: 71fa071cb46ba75d78c5087bf25447af8e4a1d27 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!-- Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->

# Create C++ / Java dev environment on CentOS using VirtualBox and Vagrant

## Prerequisites
* [Install VirtualBox](https://www.virtualbox.org/wiki/Downloads)
* [Install Vagrant](https://www.vagrantup.com/downloads.html)

## Create dev environment

#### 1. Change working directory to &lt;vespa-source&gt;/vagrant

    cd <vespa-source>/vagrant

#### 2. Choose dev environment

##### a. For a dev environment with plain centos/7 and no GUI:

    export VESPA_VAGRANT_VM_BOX=centos/7
    export VESPA_VAGRANT_DISABLE_GUI=true

##### b. For a dev environment with GUI and CLion:

Create centos7-desktop box:

* Install packer by following guide at [packer.io](https://www.packer.io/intro/getting-started/install.html)

* Clone boxcutter centos repo and build the box:
```
git clone https://github.com/boxcutter/centos.git
./bin/box build centos7-desktop.json virtualbox
```

Example exports:

    export VESPA_VAGRANT_VM_BOX="centos7-desktop"
    export VESPA_VAGRANT_VM_BOX_URL="$HOME/git/boxcutter/centos/box/virtualbox/centos7-desktop-xx.yyyy.z.box"


#### 3. Install Vagrant VirtualBox Guest Additions plugin
This is required for mounting shared folders and get mouse pointer integration and seamless windows in the virtual CentOS desktop.

    vagrant plugin install vagrant-vbguest

#### 4. Start and provision the environment

    vagrant up

#### 5. Connect to machine via SSH
SSH agent forwarding is enabled to ensure easy interaction with GitHub inside the machine.

    vagrant ssh

#### 6. Checkout vespa source inside virtual machine
This is needed in order to compile and run tests fast on the local file system inside the virtual machine.

    git clone git@github.com:vespa-engine/vespa.git

## Build Java modules
Please follow the build instructions described [here](../README.md#build-java-modules).


## Build C++ modules
Please follow the build instructions described [here](../README.md#build-c-modules).
Skip these steps if doing development with CLion.


## Build and Develop using CLion
CLion is installed as part of the environment and is recommended for C++ development.

#### 1. Bootstrap C++ building
cd to the vespa/ directory created by git clone and execute:

    ./bootstrap.sh java
    ./bootstrap-cpp.sh . .

#### 2. Start CLion
Open a terminal inside the virtual CentOS desktop (password is "vagrant") and run:

    clion

When prompted, configure toolchains as follows:

    CMake: /usr/bin/cmake3
    Make: /usr/bin/make
    C Compiler: /opt/rh/devtoolset-8/root/usr/bin/cc
    C++ Compiler: /opt/rh/devtoolset-8/root/usr/bin/c++

#### 3. Open the Vespa Project
Go to *File* -> *Open* and choose &lt;vespa-source>&gt;/CMakeLists.txt.

#### 4. Set compiler threads
Go to *File* -> *Settings* -> *Build, Execution, Deployment* -> *CMake*.
Under *Build Options* specify "-j 4" and click *Apply*.

#### 5. Run bootstrap again

    ./bootstrap-cpp.sh . .

(Some of the changes made by it are undone by clion on the first startup.)

#### 6. Build all modules
Choose target **all_modules** from the set of build targets at the top right and click build.

## Starting and stopping the Vagrant machine
Use `vagrant suspend` to suspend the machine and then `vagrant resume` to resume it later on.
Alternatively use `vagrant halt` + `vagrant up` to shutdown and reboot. Latter approach is slower but requires less disk space since RAM content is not persisted to host.