aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: bf04feaa00cb4c543ae2e81af36f665417202214 (plain)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# Overview

libWeave is the library with device side implementation of Weave protocol.

# Sources

Sources are located in git repository at
https://weave.googlesource.com/weave/libweave/


# Install Repo

Make sure you have a bin/ directory in your home directory
and that it is included in your path:

```
mkdir ~/bin
PATH=~/bin:$PATH
```

Download the [Repo tool](https://gerrit.googlesource.com/git-repo) and ensure
that it is executable:

```
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
```

# Checkout code

```
mkdir ~/weave
cd ~/weave
repo init -u https://weave.googlesource.com/weave/manifest
repo sync
```

This checks out libweave and its dependencies into the ~/weave directory.

# libweave Directory structure

| Path                     | Description                        |
|--------------------------|------------------------------------|
| include/                 | Includes to be used by device code |
| src/                     | Implementation sources             |
| examples/                | Example of device code             |
| third_party/             | Dependencies                       |
| Makefile, \*.mk files    | Build files                        |


# Quick start on Debian/Ubuntu

### Install prerequisites

```
sudo apt-get update
sudo apt-get install \
  autoconf \
  automake \
  binutils \
  cmake \
  g++ \
  hostapd \
  libavahi-client-dev \
  libcurl4-openssl-dev \
  libevent-dev \
  libexpat1-dev \
  libssl-dev \
  libtool
```

# Prerequisites

### Common

  - autoconf
  - automake
  - binutils
  - libtool
  - libexpat1-dev

### For tests

  - cmake
  - gtest (included; see third_party/googletest/googletest/)
  - gmock (included; see third_party/googletest/googlemock/)

### For examples

  - cmake
  - hostapd
  - libavahi-client-dev
  - libcurl4-openssl-dev
  - libevhtp (included; see third_party/libevhtp/)
  - libevent-dev

# Compiling

From the `libweave` directory:

The `make --jobs/-j` flag is encouraged, to speed up build time. For example

```
make -j
```

which happens to be the same as

```
make all -j
```

### Build library

```
make out/Debug/libweave.so
```

### Build examples

```
make all-examples
```

See [the examples README](/examples/daemon/README.md) for details.

### Cross-compiling

#### libweave users

In order to cross-compile, all you need to configure is CC/CXX/AR.

```
make CC=your-cc CXX=your-cxx AR=your-ar
```

So if you have a toolchain in a path like `/opt/vendor/bin/arm-linux-gcc`, do:

```
make \
  CC=/opt/vendor/bin/arm-linux-gcc \
  CXX=/opt/vendor/bin/arm-linux-g++ \
  AR=/opt/vendor/bin/arm-linux-ar
```

#### libweave developers

*** note
**Note:** This is only for developers who are hacking on libweave itself.
***

The build supports transparently downloading & using a few cross-compilers.
Just add `cross-<arch>` to the command line in addition to the target you
want to actually build.

This will cross-compile for an armv7 (hard float) target:

```
make cross-arm all-libs
```

This will cross-compile for a mips (little endian) target:

```
make cross-mipsel all-libs
```

# Testing

### Run tests

```
make test
make export-test
```

or

```
make testall
```

### Cross-testing

The build supports using qemu to run non-native tests.

This will run armv7 tests through qemu:

```
make cross-arm testall
```

# Making changes

The [Android Developing site](https://source.android.com/source/developing.html)
has a lot of good tips for working with git and repo in general.  The tips below
are meant as a quick cheat sheet rather than diving deep into relevant topics.

### Configure git
Make sure to have correct user in local or global config e.g.:

```
git config --local user.name "User Name"
git config --local user.email user.name@example.com
```

### Start local branch

```
repo start <branch name> .
```

### Edit code and commit locally e.g.

```
git commit -a -v
```

### Upload CL

```
repo upload .
```

### Request code review

Go to the url from the output of `repo upload` and add reviewers.