aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2016-01-20 19:34:31 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-01-20 19:34:31 +0000
commita7a2b59c5be551a593c8229200425bf9a3200c25 (patch)
tree4afcd0b9ef626b0c6dbef977e018627a1c451a79
parent0f9e8f40b9af07d51e40ca33a02127b1c0770c0a (diff)
parent159f08a622ac7ec0c1d20308ed367e60eba1482c (diff)
downloadlibweave-a7a2b59c5be551a593c8229200425bf9a3200c25.tar.gz
Merge remote-tracking branch \'weave/master\' into HEAD am: 6c24537704
am: 159f08a622 * commit '159f08a622ac7ec0c1d20308ed367e60eba1482c': Fix clock mock in ComponentManagerTest libweave: Add libgtest.a dependencies to Makefiles Fix assigning error in SecurityManager README: fix typo in examples rule Generate header file dependencies Remove unused function libweave: Remove gyp build files. libweave: Add clang support to Makefile. Fix path in documentation. Update README.md with markdown formatting Rename README to README.md libweave: Build with Makefile instead of GYP.
-rw-r--r--.gitignore2
-rw-r--r--CONTRIBUTORS1
-rw-r--r--Makefile104
-rw-r--r--README131
-rw-r--r--README.md152
-rwxr-xr-xexamples/build.sh22
-rw-r--r--examples/daemon/README106
-rw-r--r--examples/daemon/README.md122
-rw-r--r--examples/daemon/examples.gyp16
-rw-r--r--examples/daemon/ledflasher/daemon.gyp18
-rw-r--r--examples/daemon/light/daemon.gyp18
-rw-r--r--examples/daemon/lock/daemon.gyp18
-rw-r--r--examples/daemon/oven/daemon.gyp18
-rw-r--r--examples/daemon/sample/daemon.gyp18
-rw-r--r--examples/daemon/speaker/daemon.gyp18
-rw-r--r--examples/examples.mk58
-rwxr-xr-xexamples/prerequisites.sh48
-rw-r--r--examples/provider/provider.gyp59
-rw-r--r--file_lists.mk166
-rw-r--r--libweave.gypi151
-rw-r--r--libweave_common.gypi87
-rw-r--r--libweave_standalone.gyp84
-rw-r--r--src/base_api_handler.h3
-rw-r--r--src/component_manager_unittest.cc7
-rw-r--r--src/privet/security_manager.cc3
-rw-r--r--tests.mk58
-rwxr-xr-xthird_party/get_gtest.sh30
-rwxr-xr-xthird_party/get_libevent.sh29
-rw-r--r--third_party/third_party.mk79
29 files changed, 815 insertions, 811 deletions
diff --git a/.gitignore b/.gitignore
index 3ee16a1..a256906 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,5 @@
-*.target.mk
*~
/out/
/third_party/include
/third_party/lib
gomacc.lock
-Makefile
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index b45bd87..0bb7f26 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -19,6 +19,7 @@ Daniel Erat <derat@google.com>
David Zeuthen <zeuthen@google.com>
Gene Gutnik <gene@google.com>
Gerry Fan <gfan@google.com>
+Jacob Marble <jacobmarble@google.com>
Johan Euphrosine <proppy@google.com>
Mike Frysinger <vapier@google.com>
Nathan Bullock <nathanbullock@google.com>
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..ebc8c4c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,104 @@
+# Copyright 2015 The Weave Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Run make with BUILD_MODE=Release for release.
+BUILD_MODE ?= Debug
+
+DEFS_Debug := \
+ -D_DEBUG
+
+DEFS_Release := \
+ -DNDEBUG
+
+INCLUDES := \
+ -I. \
+ -Iinclude \
+ -Ithird_party/chromium \
+ -Ithird_party/include \
+ -Ithird_party/libuweave \
+ -Ithird_party/modp_b64/modp_b64
+
+CFLAGS := \
+ -fno-exceptions \
+ -fPIC \
+ -fvisibility=hidden \
+ -Wall \
+ -Werror \
+ -Wextra \
+ -Wl,--exclude-libs,ALL \
+ -Wno-char-subscripts \
+ -Wno-format-nonliteral \
+ -Wno-missing-field-initializers \
+ -Wno-unused-local-typedefs \
+ -Wno-unused-parameter \
+ -Wpacked \
+ -Wpointer-arith \
+ -Wwrite-strings
+
+CFLAGS_Debug := \
+ -O0 \
+ -g3
+
+CFLAGS_Release := \
+ -Os
+
+CFLAGS_C := \
+ -std=c99
+
+CFLAGS_CC := \
+ -std=c++11
+
+comma := ,
+ifeq (1, $(CLANG))
+ CC = $(shell which clang-3.6)
+ CXX = $(shell which clang++-3.6)
+ CFLAGS := $(filter-out -Wl$(comma)--exclude-libs$(comma)ALL,$(CFLAGS))
+ CFLAGS += \
+ -fno-omit-frame-pointer \
+ -Wno-deprecated-register \
+ -Wno-inconsistent-missing-override
+ ifeq (Debug, $(BUILD_MODE))
+ CFLAGS += \
+ -fsanitize=address
+ LDFLAGS += \
+ -fsanitize=address
+ endif
+endif
+
+# Headers dependencies.
+CFLAGS += -MMD
+OBJFILES = $(shell find out/$(BUILD_MODE)/ -type f -name '*.o')
+-include $(OBJFILES:.o=.d)
+
+###
+# libweave.so
+
+out/$(BUILD_MODE)/libweave.so : out/$(BUILD_MODE)/libweave_common.a
+ $(CXX) -shared -Wl,-soname=libweave.so -o $@ -Wl,--whole-archive $^ -Wl,--no-whole-archive -lcrypto -lexpat -lpthread -lrt
+
+include file_lists.mk third_party/third_party.mk examples/examples.mk tests.mk
+
+###
+# src/
+
+weave_obj_files := $(WEAVE_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o)
+
+# TODO(jacobmarble): There are too many libgtest.a deps in non-test targets. Fix.
+$(weave_obj_files) : out/$(BUILD_MODE)/%.o : %.cc third_party/lib/libgtest.a
+ mkdir -p $(dir $@)
+ $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $<
+
+out/$(BUILD_MODE)/libweave_common.a : $(weave_obj_files) $(third_party_chromium_base_obj_files) $(third_party_chromium_crypto_obj_files) $(third_party_modp_b64_obj_files) $(third_party_libuweave_obj_files)
+ rm -f $@
+ $(AR) crsT $@ $^
+
+all : out/$(BUILD_MODE)/libweave.so out/$(BUILD_MODE)/libweave_exports_testrunner out/$(BUILD_MODE)/libweave_testrunner all-examples
+
+clean :
+ rm -rf out
+
+cleanall : clean clean-gtest clean-libevent
+
+.PHONY : clean cleanall all
+
diff --git a/README b/README
deleted file mode 100644
index c78283b..0000000
--- a/README
+++ /dev/null
@@ -1,131 +0,0 @@
-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
--------
-1. Make sure you have a bin/ directory in your home directory
-and that it is included in your path:
-
- mkdir ~/bin
- PATH=~/bin:$PATH
-
-2. Download the Repo tool and ensure that it is executable:
-
- curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
- chmod a+x ~/bin/repo
-
-Checkout code
--------
- repo init -u https://weave.googlesource.com/weave/manifest
- repo sync
-
-Directory structure
--------------------
-Includes to be used by device code:
- include/
-
-Implementation sources:
- src/
-
-Example of device code:
- examples/
-
-Dependencies:
- third_party/
-
-Build files:
- libweave_standalone.gyp
- libweave_common.gypi
-
-Quick start on Debian/Ubuntu
-----------------------------
-
-Install prerequisites:
-
- examples/prerequisites.sh
-
-Build library, tests, run tests, build example:
-
- examples/build.sh
-
-Execute example (check examples/daemon/README for details):
-
- sudo out/Debug/weave_daemon
-
-
-Prerequisites
--------------
-Common:
-
- autoconf
- automake
- binutils
- libtool
- gyp
- libexpat1-dev
-
-For tests:
-
- gtest
- gmock
-
-For examples:
-
- hostapd
- libavahi-client-dev
- libcurl4-openssl-dev
- libevent 2.1.x-alpha
-
-
-Compiling
----------
-Everywhere below Debug can be replaced with Release.
-
-Generate build files:
-
- gyp -I libweave_common.gypi --toplevel-dir=. --depth=. \
- -f make libweave_standalone.gyp
-
-Build library with tests:
-
- make
-
-Build library only:
-
- make libweave
-
-Testing
--------
-Run unittests tests:
-
- out/Debug/libweave_testrunner
- out/Debug/libweave_exports_testrunner
-
-Making changes
---------------
-Make sure to have correct user in local or global config e.g.:
-
- git config --local user.name "John Doe"
- git config --local user.email johndoe@example.com
-
-Start local branch
-
- repo start <branch name> .
-
-Edit code and commit locally e.g.:
-
- git commit -a -v
-
-Upload CL:
-
- repo upload .
-
-Go to the url from the output of "repo upload" and add reviewers.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..fc042b7
--- /dev/null
+++ b/README.md
@@ -0,0 +1,152 @@
+# 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 and ensure that it is executable:
+
+```
+curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
+chmod a+x ~/bin/repo
+```
+
+# Checkout code
+
+```
+repo init -u https://weave.googlesource.com/weave/manifest
+repo sync
+```
+
+# 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 g++ hostapd libavahi-client-dev libcurl4-openssl-dev libexpat1-dev libnl-3-dev libnl-route-3-dev libssl-dev libtool
+```
+
+# Prerequisites
+
+### Common
+
+ - autoconf
+ - automake
+ - binutils
+ - libtool
+ - libexpat1-dev
+
+### For tests
+
+ - gtest (included; see third_party/get_gtest.sh)
+ - gmock (included; see third_party/get_gtest.sh)
+
+### For examples
+
+ - hostapd
+ - libavahi-client-dev
+ - libcurl4-openssl-dev
+ - libevent 2.1.x-alpha (included; see third_party/get_libevent.sh)
+
+
+# Compiling
+
+The `make --jobs/-j` flag is encouraged, to speed up build time. For example
+
+```
+make all -j
+```
+
+### Build library
+
+```
+make
+
+```
+
+or
+
+```
+make out/Debug/libweave.so
+```
+
+### Build examples
+
+```
+make all-examples
+```
+
+See [the examples README](/examples/daemon/README.md) for details.
+
+# Testing
+
+### Run tests
+
+```
+make test
+make export-test
+```
+
+or
+
+```
+make testall
+```
+
+# Making changes
+
+### 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.
diff --git a/examples/build.sh b/examples/build.sh
index 262c56b..6a2450d 100755
--- a/examples/build.sh
+++ b/examples/build.sh
@@ -3,26 +3,12 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+# Instead of this script, try running "make all -j" and "make testall".
+# TODO: Delete this file after 15-feb-2016.
+
DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
ROOT_DIR=$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)
cd $ROOT_DIR
-gyp -Ilibweave_common.gypi --toplevel-dir=. --depth=. -f make $DIR/daemon/examples.gyp
-
-if [ -z "$BUILD_CONFIG" ]; then
- export BUILD_CONFIG=Debug
-fi
-
-export BUILD_TARGET=$*
-if [ -z "$BUILD_TARGET" ]; then
- export BUILD_TARGET="weave_daemon_examples libweave_testrunner libweave_exports_testrunner"
-fi
-
-export CORES=`cat /proc/cpuinfo | grep processor | wc -l`
-BUILDTYPE=$BUILD_CONFIG make -j $CORES $BUILD_TARGET || exit 1
-
-if [[ $BUILD_TARGET == *"libweave_testrunner"* ]]; then
- out/${BUILD_CONFIG}/libweave_testrunner --gtest_break_on_failure || exit 1
- out/${BUILD_CONFIG}/libweave_exports_testrunner --gtest_break_on_failure || exit 1
-fi
+make all -j
diff --git a/examples/daemon/README b/examples/daemon/README
deleted file mode 100644
index feb57a7..0000000
--- a/examples/daemon/README
+++ /dev/null
@@ -1,106 +0,0 @@
-Overview
---------
-The wrapper implements OS dependent services for libweave
-
-Building
---------
- - prepare environment
- examples/prerequisites.sh
- - build daemon
- examples/build.sh
- - binaries for daemon are in the directory
- out/Debug/
-
-Prepare Host OS
----------------
-enable user-service-publishing in avahi daemon
- file: /etc/avahi/avahi-daemon.conf
- check: disable-user-service-publishing=no
- restart: sudo service avahi-daemon restart
-
-Acquire Registration Ticket
----------------------------
-Goto https://developers.google.com/oauthplayground/
- - "Step 1", paste to "Authorize APIs" with
- https://www.googleapis.com/auth/clouddevices
- click "Authorize APIs", then "Allow" to get an
- "authorization code"
- - "Step 2", "Exchange authorization code for tokens"
- - "Step 3", obtain a registration ticket for your new weave device
- HTTP Method: POST
- Request URI: https://www.googleapis.com/weave/v1/registrationTickets
- Enter request body:
- {
- "userEmail": "me"
- }
- then "Send the request", a ticket id will be returned in
- {
- "userEmail": "user@google.com",
- "kind": "weave#registrationTicket",
- "expirationTimeMs": "1443204934855",
- "deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
- "creationTimeMs": "1443204694855",
- "id": "93019287-6b26-04a0-22ee-d55ad23a4226"
- }
- Note: the ticket "id" is not used within 240 sec, it will be expired.
-
-Register device to cloud
-------------------------
- - copy the ticket "id" generated above
- 93019287-6b26-04a0-22ee-d55ad23a4226
- - go to terminal, register and start the daemon with
-
- sudo out/Debug/weave_daemon_sample --registration_ticket=93019287-6b26-04a0-22ee-d55ad23a4226
-
- you should see something like:
- Publishing service
- Saving settings to /var/lib/weave/weave_settings.json
-
- note: in second and future runs, --registration_ticket
- options is not necessary anymore
-
- - get your device id with
- sudo cat /var/lib/weave/weave_settings.json
- you should see
- ...
- "device_id": 0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d
- ...
-
- this device_id shall be used for future communication
- with your device. it does not expire and no need to
- register.
-
- - verify device is up with Weave Device Manager at
- android: https://play.google.com/apps/testing/com.google.android.apps.weave.management
- chrome: https://chrome.google.com/webstore/detail/weave-device-manager/pcdgflbjckpjmlofgopidgdfonmnodfm
- [need your whitelisted EAP account]
-
-Send Command to the Daemon
---------------------------
- - go to the oauthplayground used for registration ticket command
- in "Step 3", send command with
- HTTP Method: POST
- Request URI: https://www.googleapis.com/weave/v1/commands
- Enter request body:
- {
- "deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
- "name": "_sample.hello",
- "component": "sample",
- "parameters": { "name": "cloud user" }
- }
- "Send the request", you command will be "queued" as its "state"
-
- - verify the command execution observing daemon console logs
-
- - verify the command history with oauthplayground
- Similar to "Acquire Registration Ticket" section in this document,
- except in "step 3", do:
-
- HTTP Method: GET [not POST anymore]
- Request URI: https://www.googleapis.com/weave/v1/commands?deviceId=0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d
-
- "Send the request", you get all of the commands executed on your
- device, find something like
- "kind": "weave#command",
- "name": "_sample.hello",
- ...
diff --git a/examples/daemon/README.md b/examples/daemon/README.md
new file mode 100644
index 0000000..4585b5b
--- /dev/null
+++ b/examples/daemon/README.md
@@ -0,0 +1,122 @@
+# Overview
+
+The wrapper implements OS dependent services for libweave
+
+# Building
+
+### Build daemon examples
+
+The example binaries land in the out/Debug/ directory build all of them at once:
+
+```
+make all-examples
+```
+
+...or one at a time.
+
+```
+make out/Debug/weave_daemon_light
+```
+
+# Prepare Host OS
+
+### Enable user-service-publishing in avahi daemon
+Set disable-user-service-publishing=no in /etc/avahi/avahi-daemon.conf
+
+#### restart avahi
+```
+sudo service avahi-daemon restart
+```
+
+# Control device with the cloud
+
+### Generate registration ticket
+- Go to [OAuth 2.0 Playground](https://developers.google.com/oauthplayground/)
+- "Step 1": Paste https://www.googleapis.com/auth/clouddevices and click to "Authorize APIs"
+- "Step 2": Click "Exchange authorization code for tokens"
+- "Step 3": Fill the form:
+ * HTTP Method: POST
+ * Request URI: https://www.googleapis.com/weave/v1/registrationTickets
+ * Enter request body: ```{"userEmail": "me"}```
+ * Click "Send the request", a ticket id will be returned in
+
+```
+ {
+ "userEmail": "user@google.com",
+ "kind": "weave#registrationTicket",
+ "expirationTimeMs": "1443204934855",
+ "deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
+ "creationTimeMs": "1443204694855",
+ "id": "93019287-6b26-04a0-22ee-d55ad23a4226"
+ }
+```
+- Note: the ticket "id" is not used within 240 sec, it will be expired.
+
+
+### Register device to cloud
+
+- Copy the ticket "id" generated above: ```93019287-6b26-04a0-22ee-d55ad23a4226```
+- Go to terminal, register and start the daemon with
+
+```
+ sudo out/Debug/weave_daemon_sample --registration_ticket=93019287-6b26-04a0-22ee-d55ad23a4226
+```
+
+- See something like:
+
+```
+ Publishing service
+ Saving settings to /var/lib/weave/weave_settings.json
+```
+
+- Note: in second and future runs, --registration_ticket options is not necessary anymore
+- Get your device id with
+
+```
+ sudo cat /var/lib/weave/weave_settings.json
+```
+
+- See something like:
+
+```
+ ...
+ "device_id": 0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d
+ ...
+```
+
+- Use this device_id for future communication with your device. It does not expire.
+- Verify device is up with Weave Device Managers on
+[Android](https://play.google.com/apps/testing/com.google.android.apps.weave.management),
+[Chrome](https://chrome.google.com/webstore/detail/weave-device-manager/pcdgflbjckpjmlofgopidgdfonmnodfm)
+or [Weave Developpers Console](https://weave.google.com/console/)
+
+### Send Command to the Daemon
+
+- Go to [OAuth 2.0 Playground](https://developers.google.com/oauthplayground/)
+- "Step 1": Paste https://www.googleapis.com/auth/clouddevices and click to "Authorize APIs"
+- "Step 2": Click "Exchange authorization code for tokens"
+- "Step 3": Fill the form:
+ * HTTP Method: POST
+ * Request URI: https://www.googleapis.com/weave/v1/commands
+ * Enter request body:
+
+```
+ {
+ "deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
+ "name": "_sample.hello",
+ "component": "sample",
+ "parameters": { "name": "cloud user" }
+ }
+
+```
+
+- "Send the request", you command will be "queued" as its "state"
+- Verify the command execution observing daemon console logs
+- Verify the command usign [Weave Developpers Console](https://weave.google.com/console/)
+- Verify the command history with [OAuth 2.0 Playground](https://developers.google.com/oauthplayground/)
+- "Step 1": Paste https://www.googleapis.com/auth/clouddevices and click to "Authorize APIs"
+- "Step 2": Click "Exchange authorization code for tokens"
+- "Step 3": Fill the form:
+ * HTTP Method: GET
+ * Request URI: https://www.googleapis.com/weave/v1/commands?deviceId=0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d
+ * Click "Send the request", you get all of the commands executed on your device.
diff --git a/examples/daemon/examples.gyp b/examples/daemon/examples.gyp
deleted file mode 100644
index d63c5e4..0000000
--- a/examples/daemon/examples.gyp
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- 'targets': [
- {
- 'target_name': 'weave_daemon_examples',
- 'type': 'none',
- 'dependencies': [
- 'sample/daemon.gyp:weave_daemon_sample',
- 'light/daemon.gyp:weave_daemon_light',
- 'lock/daemon.gyp:weave_daemon_lock',
- 'ledflasher/daemon.gyp:weave_daemon_ledflasher',
- 'speaker/daemon.gyp:weave_daemon_speaker',
- 'oven/daemon.gyp:weave_daemon_oven',
- ]
- }
- ]
-}
diff --git a/examples/daemon/ledflasher/daemon.gyp b/examples/daemon/ledflasher/daemon.gyp
deleted file mode 100644
index 5abfcd6..0000000
--- a/examples/daemon/ledflasher/daemon.gyp
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2015 The Weave Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'weave_daemon_ledflasher',
- 'type': 'executable',
- 'sources': [
- 'ledflasher.cc',
- ],
- 'dependencies': [
- '<@(DEPTH)/libweave_standalone.gyp:libweave',
- '<@(DEPTH)/examples/provider/provider.gyp:libweave_provider',
- ]
- }
- ]
-}
diff --git a/examples/daemon/light/daemon.gyp b/examples/daemon/light/daemon.gyp
deleted file mode 100644
index e8bb646..0000000
--- a/examples/daemon/light/daemon.gyp
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2015 The Weave Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'weave_daemon_light',
- 'type': 'executable',
- 'sources': [
- 'light.cc',
- ],
- 'dependencies': [
- '<@(DEPTH)/libweave_standalone.gyp:libweave',
- '<@(DEPTH)/examples/provider/provider.gyp:libweave_provider',
- ]
- }
- ]
-}
diff --git a/examples/daemon/lock/daemon.gyp b/examples/daemon/lock/daemon.gyp
deleted file mode 100644
index 0402a29..0000000
--- a/examples/daemon/lock/daemon.gyp
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2015 The Weave Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'weave_daemon_lock',
- 'type': 'executable',
- 'sources': [
- 'lock.cc',
- ],
- 'dependencies': [
- '<@(DEPTH)/libweave_standalone.gyp:libweave',
- '<@(DEPTH)/examples/provider/provider.gyp:libweave_provider',
- ]
- }
- ]
-}
diff --git a/examples/daemon/oven/daemon.gyp b/examples/daemon/oven/daemon.gyp
deleted file mode 100644
index 44b4798..0000000
--- a/examples/daemon/oven/daemon.gyp
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2015 The Weave Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'weave_daemon_oven',
- 'type': 'executable',
- 'sources': [
- 'oven.cc',
- ],
- 'dependencies': [
- '<@(DEPTH)/libweave_standalone.gyp:libweave',
- '<@(DEPTH)/examples/provider/provider.gyp:libweave_provider',
- ]
- }
- ]
-}
diff --git a/examples/daemon/sample/daemon.gyp b/examples/daemon/sample/daemon.gyp
deleted file mode 100644
index 29d8235..0000000
--- a/examples/daemon/sample/daemon.gyp
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2015 The Weave Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'weave_daemon_sample',
- 'type': 'executable',
- 'sources': [
- 'sample.cc',
- ],
- 'dependencies': [
- '<@(DEPTH)/libweave_standalone.gyp:libweave',
- '<@(DEPTH)/examples/provider/provider.gyp:libweave_provider',
- ]
- }
- ]
-}
diff --git a/examples/daemon/speaker/daemon.gyp b/examples/daemon/speaker/daemon.gyp
deleted file mode 100644
index 3bf7a91..0000000
--- a/examples/daemon/speaker/daemon.gyp
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2015 The Weave Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'weave_daemon_speaker',
- 'type': 'executable',
- 'sources': [
- 'speaker.cc',
- ],
- 'dependencies': [
- '<@(DEPTH)/libweave_standalone.gyp:libweave',
- '<@(DEPTH)/examples/provider/provider.gyp:libweave_provider',
- ]
- }
- ]
-}
diff --git a/examples/examples.mk b/examples/examples.mk
new file mode 100644
index 0000000..a25194c
--- /dev/null
+++ b/examples/examples.mk
@@ -0,0 +1,58 @@
+# Copyright 2015 The Weave Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+###
+# examples
+
+examples_provider_obj_files := $(EXAMPLES_PROVIDER_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o)
+
+# We don't need libevent.a, but the headers files in third_party/include.
+$(examples_provider_obj_files) : out/$(BUILD_MODE)/%.o : %.cc third_party/lib/libevent.a
+ mkdir -p $(dir $@)
+ $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $<
+
+out/$(BUILD_MODE)/examples_provider.a : $(examples_provider_obj_files)
+ rm -f $@
+ $(AR) crsT $@ $^
+
+# We don't need libevent.a, but the headers files in third_party/include.
+out/$(BUILD_MODE)/examples/daemon/%.o : examples/daemon/%.cc third_party/lib/libevent.a
+ mkdir -p $(dir $@)
+ $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $<
+
+daemon_common_flags := \
+ -Wl,-rpath=out/$(BUILD_MODE)/ \
+ -Lthird_party/lib \
+ -levent \
+ -levent_openssl \
+ -lpthread \
+ -lavahi-common \
+ -lavahi-client \
+ -lexpat \
+ -lcurl \
+ -lssl \
+ -lcrypto
+
+out/$(BUILD_MODE)/weave_daemon_ledflasher : out/$(BUILD_MODE)/examples/daemon/ledflasher/ledflasher.o out/$(BUILD_MODE)/examples_provider.a out/$(BUILD_MODE)/libweave.so
+ $(CXX) -o $@ $^ $(CFLAGS) $(daemon_common_flags)
+
+out/$(BUILD_MODE)/weave_daemon_light : out/$(BUILD_MODE)/examples/daemon/light/light.o out/$(BUILD_MODE)/examples_provider.a out/$(BUILD_MODE)/libweave.so
+ $(CXX) -o $@ $^ $(CFLAGS) $(daemon_common_flags)
+
+out/$(BUILD_MODE)/weave_daemon_lock : out/$(BUILD_MODE)/examples/daemon/lock/lock.o out/$(BUILD_MODE)/examples_provider.a out/$(BUILD_MODE)/libweave.so
+ $(CXX) -o $@ $^ $(CFLAGS) $(daemon_common_flags)
+
+out/$(BUILD_MODE)/weave_daemon_oven : out/$(BUILD_MODE)/examples/daemon/oven/oven.o out/$(BUILD_MODE)/examples_provider.a out/$(BUILD_MODE)/libweave.so
+ $(CXX) -o $@ $^ $(CFLAGS) $(daemon_common_flags)
+
+out/$(BUILD_MODE)/weave_daemon_sample : out/$(BUILD_MODE)/examples/daemon/sample/sample.o out/$(BUILD_MODE)/examples_provider.a out/$(BUILD_MODE)/libweave.so
+ $(CXX) -o $@ $^ $(CFLAGS) $(daemon_common_flags)
+
+out/$(BUILD_MODE)/weave_daemon_speaker : out/$(BUILD_MODE)/examples/daemon/speaker/speaker.o out/$(BUILD_MODE)/examples_provider.a out/$(BUILD_MODE)/libweave.so
+ $(CXX) -o $@ $^ $(CFLAGS) $(daemon_common_flags)
+
+all-examples : out/$(BUILD_MODE)/weave_daemon_ledflasher out/$(BUILD_MODE)/weave_daemon_light out/$(BUILD_MODE)/weave_daemon_lock out/$(BUILD_MODE)/weave_daemon_oven out/$(BUILD_MODE)/weave_daemon_sample out/$(BUILD_MODE)/weave_daemon_speaker
+
+.PHONY : all-examples
+
diff --git a/examples/prerequisites.sh b/examples/prerequisites.sh
index 1b27806..489bb58 100755
--- a/examples/prerequisites.sh
+++ b/examples/prerequisites.sh
@@ -3,6 +3,9 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+# Instead of this script, try running "make all -j".
+# TODO: Delete this file after 15-feb-2016.
+
DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
ROOT_DIR=$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)
@@ -11,7 +14,6 @@ sudo apt-get update && sudo apt-get install ${APT_GET_OPTS} \
automake \
binutils \
g++ \
- gyp \
hostapd \
libavahi-client-dev \
libcurl4-openssl-dev \
@@ -21,47 +23,3 @@ sudo apt-get update && sudo apt-get install ${APT_GET_OPTS} \
libssl-dev \
libtool \
|| exit 1
-
-mkdir -p $ROOT_DIR/third_party/lib $ROOT_DIR/third_party/include 2> /dev/null
-
-# Make gtest and gmock
-cd $ROOT_DIR/third_party
-rm -rf googletest
-
-git clone https://github.com/google/googletest.git || exit 1
-cd $ROOT_DIR/third_party/googletest
-
-# gtest is in process of changing of dir structure and it has broken build
-# files. So this is temporarily workaround to fix that.
-git reset --hard d945d8c000a0ade73585d143532266968339bbb3
-mv googletest googlemock/gtest
-
-for SUB_DIR in googlemock/gtest googlemock; do
- cd $ROOT_DIR/third_party/googletest/$SUB_DIR || exit 1
- autoreconf -fvi || exit 1
- ./configure --disable-shared || exit 1
- make || exit 1
- cp -rf include/* $ROOT_DIR/third_party/include/ || exit 1
- cp -rf lib/.libs/* $ROOT_DIR/third_party/lib/ || exit 1
-done
-rm -rf $ROOT_DIR/third_party/googletest
-
-# Make libevent.
-# Example uses libevent to implement HTTPS server. This capability is
-# available only in version 2.1.x-alpha. Step could be replaced with apt-get
-# in future.
-cd $ROOT_DIR/third_party
-rm -rf libevent
-
-git clone https://github.com/libevent/libevent.git || exit 1
-cd libevent || exit 1
-./autogen.sh || exit 1
-./configure --disable-shared || exit 1
-make || exit 1
-if [ -z "$DISABLE_LIBEVENT_TEST" ]; then
- echo -e "\n\nTesting libevent...\nCan take several minutes.\n"
- make verify || exit 1
-fi
-cp -rf include/* $ROOT_DIR/third_party/include/ || exit 1
-cp -rf .libs/lib* $ROOT_DIR/third_party/lib/ || exit 1
-rm -rf $ROOT_DIR/third_party/libevent
diff --git a/examples/provider/provider.gyp b/examples/provider/provider.gyp
deleted file mode 100644
index 3d13d8f..0000000
--- a/examples/provider/provider.gyp
+++ /dev/null
@@ -1,59 +0,0 @@
-# Copyright 2015 The Weave Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'libweave_provider',
- 'type': 'static_library',
- 'variables': {
- 'deps': [
- 'avahi-client',
- 'expat',
- 'libcurl',
- 'libcrypto',
- 'openssl',
- ]
- },
- 'cflags': [
- '>!@(pkg-config >(deps) --cflags)',
- '-pthread',
- ],
- 'sources': [
- 'avahi_client.cc',
- 'bluez_client.cc',
- 'curl_http_client.cc',
- 'event_http_client.cc',
- 'event_http_server.cc',
- 'event_network.cc',
- 'event_task_runner.cc',
- 'file_config_store.cc',
- 'wifi_manager.cc',
- 'ssl_stream.cc',
- ],
- 'dependencies': [
- '<@(DEPTH)/libweave_standalone.gyp:libweave',
- ],
- 'direct_dependent_settings' : {
- 'variables': {
- 'parent_deps': [
- '<@(deps)'
- ]
- },
- 'link_settings': {
- 'ldflags+': [
- '>!@(pkg-config >(parent_deps) --libs-only-L --libs-only-other)',
- ],
- 'libraries+': [
- '>!(pkg-config >(parent_deps) --libs-only-l)',
- ],
- },
- 'libraries': [
- '-levent',
- '-levent_openssl',
- '-lpthread',
- ]
- }
- }
- ]
-}
diff --git a/file_lists.mk b/file_lists.mk
new file mode 100644
index 0000000..1e78935
--- /dev/null
+++ b/file_lists.mk
@@ -0,0 +1,166 @@
+# Copyright 2015 The Weave Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+WEAVE_SRC_FILES := \
+ src/backoff_entry.cc \
+ src/base_api_handler.cc \
+ src/commands/cloud_command_proxy.cc \
+ src/commands/command_instance.cc \
+ src/commands/command_queue.cc \
+ src/commands/schema_constants.cc \
+ src/component_manager_impl.cc \
+ src/config.cc \
+ src/data_encoding.cc \
+ src/device_manager.cc \
+ src/device_registration_info.cc \
+ src/error.cc \
+ src/http_constants.cc \
+ src/json_error_codes.cc \
+ src/notification/notification_parser.cc \
+ src/notification/pull_channel.cc \
+ src/notification/xml_node.cc \
+ src/notification/xmpp_channel.cc \
+ src/notification/xmpp_iq_stanza_handler.cc \
+ src/notification/xmpp_stream_parser.cc \
+ src/privet/auth_manager.cc \
+ src/privet/cloud_delegate.cc \
+ src/privet/constants.cc \
+ src/privet/device_delegate.cc \
+ src/privet/device_ui_kind.cc \
+ src/privet/openssl_utils.cc \
+ src/privet/privet_handler.cc \
+ src/privet/privet_manager.cc \
+ src/privet/privet_types.cc \
+ src/privet/publisher.cc \
+ src/privet/security_manager.cc \
+ src/privet/wifi_bootstrap_manager.cc \
+ src/privet/wifi_ssid_generator.cc \
+ src/registration_status.cc \
+ src/states/state_change_queue.cc \
+ src/streams.cc \
+ src/string_utils.cc \
+ src/utils.cc
+
+WEAVE_TEST_SRC_FILES := \
+ src/test/fake_stream.cc \
+ src/test/fake_task_runner.cc \
+ src/test/unittest_utils.cc
+
+WEAVE_UNITTEST_SRC_FILES := \
+ src/backoff_entry_unittest.cc \
+ src/base_api_handler_unittest.cc \
+ src/commands/cloud_command_proxy_unittest.cc \
+ src/commands/command_instance_unittest.cc \
+ src/commands/command_queue_unittest.cc \
+ src/component_manager_unittest.cc \
+ src/config_unittest.cc \
+ src/data_encoding_unittest.cc \
+ src/device_registration_info_unittest.cc \
+ src/error_unittest.cc \
+ src/notification/notification_parser_unittest.cc \
+ src/notification/xml_node_unittest.cc \
+ src/notification/xmpp_channel_unittest.cc \
+ src/notification/xmpp_iq_stanza_handler_unittest.cc \
+ src/notification/xmpp_stream_parser_unittest.cc \
+ src/privet/auth_manager_unittest.cc \
+ src/privet/privet_handler_unittest.cc \
+ src/privet/security_manager_unittest.cc \
+ src/privet/wifi_ssid_generator_unittest.cc \
+ src/states/state_change_queue_unittest.cc \
+ src/streams_unittest.cc \
+ src/string_utils_unittest.cc \
+ src/test/weave_testrunner.cc
+
+WEAVE_EXPORTS_UNITTEST_SRC_FILES := \
+ src/weave_unittest.cc
+
+EXAMPLES_PROVIDER_SRC_FILES := \
+ examples/provider/avahi_client.cc \
+ examples/provider/bluez_client.cc \
+ examples/provider/curl_http_client.cc \
+ examples/provider/event_http_client.cc \
+ examples/provider/event_http_server.cc \
+ examples/provider/event_network.cc \
+ examples/provider/event_task_runner.cc \
+ examples/provider/file_config_store.cc \
+ examples/provider/ssl_stream.cc \
+ examples/provider/wifi_manager.cc
+
+THIRD_PARTY_CHROMIUM_BASE_SRC_FILES := \
+ third_party/chromium/base/bind_helpers.cc \
+ third_party/chromium/base/callback_internal.cc \
+ third_party/chromium/base/guid_posix.cc \
+ third_party/chromium/base/json/json_parser.cc \
+ third_party/chromium/base/json/json_reader.cc \
+ third_party/chromium/base/json/json_writer.cc \
+ third_party/chromium/base/json/string_escape.cc \
+ third_party/chromium/base/location.cc \
+ third_party/chromium/base/logging.cc \
+ third_party/chromium/base/memory/ref_counted.cc \
+ third_party/chromium/base/memory/weak_ptr.cc \
+ third_party/chromium/base/rand_util.cc \
+ third_party/chromium/base/rand_util_posix.cc \
+ third_party/chromium/base/strings/string_number_conversions.cc \
+ third_party/chromium/base/strings/string_piece.cc \
+ third_party/chromium/base/strings/stringprintf.cc \
+ third_party/chromium/base/strings/string_util.cc \
+ third_party/chromium/base/strings/string_util_constants.cc \
+ third_party/chromium/base/strings/utf_string_conversion_utils.cc \
+ third_party/chromium/base/third_party/dmg_fp/dtoa.cc \
+ third_party/chromium/base/third_party/dmg_fp/g_fmt.cc \
+ third_party/chromium/base/third_party/icu/icu_utf.cc \
+ third_party/chromium/base/time/clock.cc \
+ third_party/chromium/base/time/default_clock.cc \
+ third_party/chromium/base/time/time.cc \
+ third_party/chromium/base/time/time_posix.cc \
+ third_party/chromium/base/values.cc
+
+THIRD_PARTY_CHROMIUM_BASE_UNITTEST_SRC_FILES := \
+ third_party/chromium/base/bind_unittest.cc \
+ third_party/chromium/base/callback_list_unittest.cc \
+ third_party/chromium/base/callback_unittest.cc \
+ third_party/chromium/base/guid_unittest.cc \
+ third_party/chromium/base/json/json_parser_unittest.cc \
+ third_party/chromium/base/json/json_reader_unittest.cc \
+ third_party/chromium/base/json/json_writer_unittest.cc \
+ third_party/chromium/base/json/string_escape_unittest.cc \
+ third_party/chromium/base/logging_unittest.cc \
+ third_party/chromium/base/memory/ref_counted_unittest.cc \
+ third_party/chromium/base/memory/scoped_ptr_unittest.cc \
+ third_party/chromium/base/memory/weak_ptr_unittest.cc \
+ third_party/chromium/base/move_unittest.cc \
+ third_party/chromium/base/numerics/safe_numerics_unittest.cc \
+ third_party/chromium/base/observer_list_unittest.cc \
+ third_party/chromium/base/rand_util_unittest.cc \
+ third_party/chromium/base/scoped_clear_errno_unittest.cc \
+ third_party/chromium/base/strings/string_number_conversions_unittest.cc \
+ third_party/chromium/base/strings/string_piece_unittest.cc \
+ third_party/chromium/base/strings/string_util_unittest.cc \
+ third_party/chromium/base/strings/stringprintf_unittest.cc \
+ third_party/chromium/base/template_util_unittest.cc \
+ third_party/chromium/base/time/time_unittest.cc \
+ third_party/chromium/base/tuple_unittest.cc \
+ third_party/chromium/base/values_unittest.cc
+
+THIRD_PARTY_CHROMIUM_CRYPTO_SRC_FILES := \
+ third_party/chromium/crypto/p224.cc \
+ third_party/chromium/crypto/p224_spake.cc \
+ third_party/chromium/crypto/sha2.cc
+
+THIRD_PARTY_CHROMIUM_CRYPTO_UNITTEST_SRC_FILES := \
+ third_party/chromium/crypto/p224_spake_unittest.cc \
+ third_party/chromium/crypto/p224_unittest.cc \
+ third_party/chromium/crypto/sha2_unittest.cc
+
+THIRD_PARTY_MODP_B64_SRC_FILES := \
+ third_party/modp_b64/modp_b64.cc
+
+THIRD_PARTY_LIBUWEAVE_SRC_FILES := \
+ third_party/libuweave/src/crypto_hmac.c \
+ third_party/libuweave/src/crypto_utils.c \
+ third_party/libuweave/src/macaroon.c \
+ third_party/libuweave/src/macaroon_caveat.c \
+ third_party/libuweave/src/macaroon_context.c \
+ third_party/libuweave/src/macaroon_encoding.c
+
diff --git a/libweave.gypi b/libweave.gypi
deleted file mode 100644
index 6f64c89..0000000
--- a/libweave.gypi
+++ /dev/null
@@ -1,151 +0,0 @@
-# Copyright 2015 The Weave Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'variables': {
- 'weave_sources': [
- 'src/backoff_entry.cc',
- 'src/base_api_handler.cc',
- 'src/commands/cloud_command_proxy.cc',
- 'src/commands/command_instance.cc',
- 'src/commands/command_queue.cc',
- 'src/commands/schema_constants.cc',
- 'src/component_manager_impl.cc',
- 'src/config.cc',
- 'src/data_encoding.cc',
- 'src/device_manager.cc',
- 'src/device_registration_info.cc',
- 'src/error.cc',
- 'src/http_constants.cc',
- 'src/json_error_codes.cc',
- 'src/notification/notification_parser.cc',
- 'src/notification/pull_channel.cc',
- 'src/notification/xml_node.cc',
- 'src/notification/xmpp_channel.cc',
- 'src/notification/xmpp_iq_stanza_handler.cc',
- 'src/notification/xmpp_stream_parser.cc',
- 'src/privet/auth_manager.cc',
- 'src/privet/cloud_delegate.cc',
- 'src/privet/constants.cc',
- 'src/privet/device_delegate.cc',
- 'src/privet/device_ui_kind.cc',
- 'src/privet/openssl_utils.cc',
- 'src/privet/privet_handler.cc',
- 'src/privet/privet_manager.cc',
- 'src/privet/privet_types.cc',
- 'src/privet/publisher.cc',
- 'src/privet/security_manager.cc',
- 'src/privet/wifi_bootstrap_manager.cc',
- 'src/privet/wifi_ssid_generator.cc',
- 'src/registration_status.cc',
- 'src/states/state_change_queue.cc',
- 'src/streams.cc',
- 'src/string_utils.cc',
- 'src/utils.cc',
- 'third_party/chromium/crypto/p224.cc',
- 'third_party/chromium/crypto/p224_spake.cc',
- 'third_party/chromium/crypto/sha2.cc',
- 'third_party/libuweave/src/crypto_hmac.c',
- 'third_party/libuweave/src/crypto_utils.c',
- 'third_party/libuweave/src/macaroon.c',
- 'third_party/libuweave/src/macaroon_caveat.c',
- 'third_party/libuweave/src/macaroon_context.c',
- 'third_party/libuweave/src/macaroon_encoding.c',
- 'third_party/modp_b64/modp_b64.cc',
- ],
- 'weave_test_sources': [
- 'src/test/fake_stream.cc',
- 'src/test/fake_task_runner.cc',
- 'src/test/unittest_utils.cc',
- ],
- 'weave_unittest_sources': [
- 'src/backoff_entry_unittest.cc',
- 'src/base_api_handler_unittest.cc',
- 'src/commands/cloud_command_proxy_unittest.cc',
- 'src/commands/command_instance_unittest.cc',
- 'src/commands/command_queue_unittest.cc',
- 'src/component_manager_unittest.cc',
- 'src/config_unittest.cc',
- 'src/data_encoding_unittest.cc',
- 'src/device_registration_info_unittest.cc',
- 'src/error_unittest.cc',
- 'src/notification/notification_parser_unittest.cc',
- 'src/notification/xml_node_unittest.cc',
- 'src/notification/xmpp_channel_unittest.cc',
- 'src/notification/xmpp_iq_stanza_handler_unittest.cc',
- 'src/notification/xmpp_stream_parser_unittest.cc',
- 'src/privet/auth_manager_unittest.cc',
- 'src/privet/privet_handler_unittest.cc',
- 'src/privet/security_manager_unittest.cc',
- 'src/privet/wifi_ssid_generator_unittest.cc',
- 'src/states/state_change_queue_unittest.cc',
- 'src/streams_unittest.cc',
- 'src/string_utils_unittest.cc',
- 'src/test/weave_testrunner.cc',
- 'third_party/chromium/crypto/p224_spake_unittest.cc',
- 'third_party/chromium/crypto/p224_unittest.cc',
- 'third_party/chromium/crypto/sha2_unittest.cc',
- ],
- 'weave_exports_unittest_sources': [
- 'src/test/weave_testrunner.cc',
- 'src/weave_unittest.cc',
- ],
- 'base_sources': [
- 'third_party/chromium/base/bind_helpers.cc',
- 'third_party/chromium/base/callback_internal.cc',
- 'third_party/chromium/base/guid_posix.cc',
- 'third_party/chromium/base/json/json_parser.cc',
- 'third_party/chromium/base/json/json_reader.cc',
- 'third_party/chromium/base/json/json_writer.cc',
- 'third_party/chromium/base/json/string_escape.cc',
- 'third_party/chromium/base/memory/ref_counted.cc',
- 'third_party/chromium/base/logging.cc',
- 'third_party/chromium/base/location.cc',
- 'third_party/chromium/base/memory/weak_ptr.cc',
- 'third_party/chromium/base/memory/weak_ptr.cc',
- 'third_party/chromium/base/rand_util.cc',
- 'third_party/chromium/base/rand_util_posix.cc',
- 'third_party/chromium/base/strings/string_number_conversions.cc',
- 'third_party/chromium/base/strings/string_piece.cc',
- 'third_party/chromium/base/strings/stringprintf.cc',
- 'third_party/chromium/base/strings/string_util.cc',
- 'third_party/chromium/base/strings/string_util_constants.cc',
- 'third_party/chromium/base/strings/utf_string_conversion_utils.cc',
- 'third_party/chromium/base/third_party/dmg_fp/g_fmt.cc',
- 'third_party/chromium/base/third_party/dmg_fp/dtoa.cc',
- 'third_party/chromium/base/third_party/icu/icu_utf.cc',
- 'third_party/chromium/base/time/clock.cc',
- 'third_party/chromium/base/time/default_clock.cc',
- 'third_party/chromium/base/time/time.cc',
- 'third_party/chromium/base/time/time_posix.cc',
- 'third_party/chromium/base/values.cc',
- ],
- 'base_unittests': [
- 'third_party/chromium/base/bind_unittest.cc',
- 'third_party/chromium/base/callback_list_unittest.cc',
- 'third_party/chromium/base/callback_unittest.cc',
- 'third_party/chromium/base/guid_unittest.cc',
- 'third_party/chromium/base/json/json_parser_unittest.cc',
- 'third_party/chromium/base/json/json_reader_unittest.cc',
- 'third_party/chromium/base/json/json_writer_unittest.cc',
- 'third_party/chromium/base/json/string_escape_unittest.cc',
- 'third_party/chromium/base/logging_unittest.cc',
- 'third_party/chromium/base/memory/ref_counted_unittest.cc',
- 'third_party/chromium/base/memory/scoped_ptr_unittest.cc',
- 'third_party/chromium/base/memory/weak_ptr_unittest.cc',
- 'third_party/chromium/base/move_unittest.cc',
- 'third_party/chromium/base/numerics/safe_numerics_unittest.cc',
- 'third_party/chromium/base/observer_list_unittest.cc',
- 'third_party/chromium/base/rand_util_unittest.cc',
- 'third_party/chromium/base/scoped_clear_errno_unittest.cc',
- 'third_party/chromium/base/strings/string_number_conversions_unittest.cc',
- 'third_party/chromium/base/strings/string_piece_unittest.cc',
- 'third_party/chromium/base/strings/string_util_unittest.cc',
- 'third_party/chromium/base/strings/stringprintf_unittest.cc',
- 'third_party/chromium/base/template_util_unittest.cc',
- 'third_party/chromium/base/time/time_unittest.cc',
- 'third_party/chromium/base/tuple_unittest.cc',
- 'third_party/chromium/base/values_unittest.cc',
- ],
- },
-}
diff --git a/libweave_common.gypi b/libweave_common.gypi
deleted file mode 100644
index e7b45ce..0000000
--- a/libweave_common.gypi
+++ /dev/null
@@ -1,87 +0,0 @@
-# Copyright 2015 The Weave Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'variables': {
- 'clang%': 0,
- },
- 'target_defaults': {
- 'configurations': {
- 'Release': {
- 'defines': [
- 'NDEBUG',
- ],
- 'cflags': [
- '-Os',
- ],
- },
- 'Debug': {
- 'defines': [
- '_DEBUG',
- ],
- 'cflags': [
- '-O0 ',
- '-g3',
- ],
- },
- },
- 'include_dirs': [
- '.',
- 'include',
- 'third_party/chromium',
- 'third_party/include',
- 'third_party/libuweave',
- 'third_party/modp_b64/modp_b64',
- ],
- 'cflags!': ['-fPIE'],
- 'cflags': [
- '-fno-exceptions',
- '-fPIC',
- '-fvisibility=hidden',
- '-Wall',
- '-Werror',
- '-Wextra',
- '-Wl,--exclude-libs,ALL',
- '-Wno-char-subscripts',
- '-Wno-format-nonliteral',
- '-Wno-missing-field-initializers',
- '-Wno-unused-local-typedefs',
- '-Wno-unused-parameter',
- '-Wpacked',
- '-Wpointer-arith',
- '-Wwrite-strings',
- ],
- 'cflags_cc': [
- '-std=c++11',
- ],
- 'cflags_c': [
- '-std=c99',
- ],
- 'libraries': [
- # 'library_dirs' does not work as expected with make files
- '-Lthird_party/lib',
- ],
- 'library_dirs': ['third_party/lib'],
- },
- 'conditions': [
- ['clang==1', {
- 'target_defaults': {
- 'cflags!': ['-Wl,--exclude-libs,ALL'],
- 'cflags': [
- '-fsanitize=address',
- '-fno-omit-frame-pointer',
- '-Wno-deprecated-register',
- '-Wno-inconsistent-missing-override',
- ],
- 'ldflags': [
- '-fsanitize=address',
- ],
- },
- 'make_global_settings': [
- ['CC','/usr/bin/clang-3.6'],
- ['CXX','/usr/bin/clang++-3.6'],
- ['LINK','/usr/bin/clang++-3.6'],
- ],
- }],
- ]
-}
diff --git a/libweave_standalone.gyp b/libweave_standalone.gyp
deleted file mode 100644
index d36d208..0000000
--- a/libweave_standalone.gyp
+++ /dev/null
@@ -1,84 +0,0 @@
-# Copyright 2015 The Weave Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'includes': [
- 'libweave.gypi',
- ],
- 'target_defaults': {
- 'libraries': [
- '-lcrypto',
- '-lexpat',
- '-lgmock',
- '-lgtest',
- '-lpthread',
- '-lrt',
- ],
- },
- 'targets': [
- {
- 'target_name': 'libweave_common',
- 'type': 'static_library',
- 'include_dirs': [
- '<@(DEPTH)/external',
- ],
- 'sources': [
- '<@(weave_sources)',
- '<@(base_sources)',
- ],
- },
- {
- 'target_name': 'libweave',
- 'type': 'shared_library',
- 'include_dirs': [
- '../libweave/external',
- ],
- 'dependencies': [
- 'libweave_common',
- ],
- 'sources': [
- 'src/empty.cc'
- ],
- },
- {
- 'target_name': 'libweave-test',
- 'type': 'static_library',
- 'standalone_static_library': 1,
- 'include_dirs': [
- '<@(DEPTH)/external',
- ],
- 'sources': [
- '<@(weave_test_sources)',
- ],
- },
- {
- 'target_name': 'libweave_testrunner',
- 'type': 'executable',
- 'include_dirs': [
- '<@(DEPTH)/external',
- ],
- 'dependencies': [
- 'libweave_common',
- 'libweave-test',
- ],
- 'sources': [
- '<@(weave_unittest_sources)',
- '<@(base_unittests)',
- ],
- },
- {
- 'target_name': 'libweave_exports_testrunner',
- 'type': 'executable',
- 'include_dirs': [
- '<@(DEPTH)/external',
- ],
- 'dependencies': [
- 'libweave',
- 'libweave-test',
- ],
- 'sources': [
- '<@(weave_exports_unittest_sources)',
- ],
- },
- ],
-}
diff --git a/src/base_api_handler.h b/src/base_api_handler.h
index 8497692..1dbbac8 100644
--- a/src/base_api_handler.h
+++ b/src/base_api_handler.h
@@ -30,9 +30,6 @@ class BaseApiHandler final {
private:
void UpdateBaseConfiguration(const std::weak_ptr<Command>& command);
void UpdateDeviceInfo(const std::weak_ptr<Command>& command);
- bool UpdateState(const std::string& anonymous_access_role,
- bool discovery_enabled,
- bool pairing_enabled);
void OnConfigChanged(const Settings& settings);
DeviceRegistrationInfo* device_info_;
diff --git a/src/component_manager_unittest.cc b/src/component_manager_unittest.cc
index 519b80a..63fedac 100644
--- a/src/component_manager_unittest.cc
+++ b/src/component_manager_unittest.cc
@@ -18,6 +18,7 @@ namespace weave {
using test::CreateDictionaryValue;
using testing::Return;
+using testing::StrictMock;
namespace {
@@ -69,6 +70,10 @@ bool HasTrait(const base::DictionaryValue& comp, const std::string& trait) {
// }
class ComponentManagerTest : public ::testing::Test {
protected:
+ void SetUp() override {
+ EXPECT_CALL(clock_, Now()).WillRepeatedly(Return(base::Time::Now()));
+ }
+
void CreateTestComponentTree(ComponentManager* manager) {
const char kTraits[] =
R"({"t1":{},"t2":{},"t3":{},"t4":{},"t5":{},"t6":{}})";
@@ -85,7 +90,7 @@ class ComponentManagerTest : public ::testing::Test {
{"t5", "t6"}, nullptr));
}
- test::MockClock clock_;
+ StrictMock<test::MockClock> clock_;
ComponentManagerImpl manager_{&clock_};
};
diff --git a/src/privet/security_manager.cc b/src/privet/security_manager.cc
index 4cd9276..2a3dc08 100644
--- a/src/privet/security_manager.cc
+++ b/src/privet/security_manager.cc
@@ -185,6 +185,9 @@ bool SecurityManager::CreateAccessToken(AuthType auth_type,
std::vector<uint8_t> auth_decoded;
if (auth_type != AuthType::kAnonymous &&
!Base64Decode(auth_code, &auth_decoded)) {
+ Error::AddToPrintf(error, FROM_HERE, errors::kDomain,
+ errors::kInvalidAuthorization,
+ "Invalid auth_code encoding: %s", auth_code.c_str());
return false;
}
diff --git a/tests.mk b/tests.mk
new file mode 100644
index 0000000..7c05017
--- /dev/null
+++ b/tests.mk
@@ -0,0 +1,58 @@
+# Copyright 2015 The Weave Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+###
+# tests
+
+TEST_FLAGS ?= \
+ --gtest_break_on_failure
+
+TEST_ENV ?=
+ifeq (1, $(CLANG))
+ TEST_ENV += ASAN_SYMBOLIZER_PATH=$(shell which llvm-symbolizer-3.6)
+endif
+
+weave_test_obj_files := $(WEAVE_TEST_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o)
+
+# We don't need libgtest.a, but the headers files in third_party/include.
+$(weave_test_obj_files) : out/$(BUILD_MODE)/%.o : %.cc third_party/lib/libgtest.a
+ mkdir -p $(dir $@)
+ $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $<
+
+out/$(BUILD_MODE)/libweave-test.a : $(weave_test_obj_files)
+ $(AR) crs $@ $^
+
+weave_unittest_obj_files := $(WEAVE_UNITTEST_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o)
+
+# We don't need libgtest.a, but the headers files in third_party/include.
+$(weave_unittest_obj_files) : out/$(BUILD_MODE)/%.o : %.cc third_party/lib/libgtest.a
+ mkdir -p $(dir $@)
+ $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $<
+
+out/$(BUILD_MODE)/libweave_testrunner : $(weave_unittest_obj_files) $(third_party_chromium_crypto_unittest_obj_files) $(third_party_chromium_base_unittest_obj_files) out/$(BUILD_MODE)/libweave_common.a out/$(BUILD_MODE)/libweave-test.a
+ $(CXX) -o $@ $^ $(CFLAGS) -lcrypto -lexpat -lgmock -lgtest -lpthread -lrt -Lthird_party/lib
+
+test : out/$(BUILD_MODE)/libweave_testrunner
+ $(TEST_ENV) $< $(TEST_FLAGS)
+
+###
+# export tests
+
+weave_exports_unittest_obj_files := $(WEAVE_EXPORTS_UNITTEST_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o)
+
+# We don't need libgtest.a, but the headers files in third_party/include.
+$(weave_exports_unittest_obj_files) : out/$(BUILD_MODE)/%.o : %.cc third_party/lib/libgtest.a
+ mkdir -p $(dir $@)
+ $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $<
+
+out/$(BUILD_MODE)/libweave_exports_testrunner : $(weave_exports_unittest_obj_files) out/$(BUILD_MODE)/libweave.so out/$(BUILD_MODE)/libweave-test.a out/$(BUILD_MODE)/src/test/weave_testrunner.o
+ $(CXX) -o $@ $^ $(CFLAGS) -lcrypto -lexpat -lgmock -lgtest -lpthread -lrt -Lthird_party/lib -Wl,-rpath=out/$(BUILD_MODE)/
+
+export-test : out/$(BUILD_MODE)/libweave_exports_testrunner
+ $(TEST_ENV) $< $(TEST_FLAGS)
+
+testall : test export-test
+
+.PHONY : test export-test testall
+
diff --git a/third_party/get_gtest.sh b/third_party/get_gtest.sh
new file mode 100755
index 0000000..0a2e952
--- /dev/null
+++ b/third_party/get_gtest.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# Copyright 2015 The Weave Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Make gtest and gmock.
+cd $(dirname "$0")
+THIRD_PARTY=$(pwd)
+
+mkdir -p include lib
+
+rm -rf $THIRD_PARTY/googletest
+git clone https://github.com/google/googletest.git || exit 1
+cd googletest
+
+# gtest is in process of changing of dir structure and it has broken build
+# files. So this is temporarily workaround to fix that.
+git reset --hard d945d8c000a0ade73585d143532266968339bbb3
+mv googletest googlemock/gtest
+
+for SUB_DIR in googlemock/gtest googlemock; do
+ cd $THIRD_PARTY/googletest/$SUB_DIR || exit 1
+ autoreconf -fvi || exit 1
+ ./configure --disable-shared || exit 1
+ make || exit 1
+ cp -rf include/* $THIRD_PARTY/include/ || exit 1
+ cp -rf lib/.libs/* $THIRD_PARTY/lib/ || exit 1
+done
+
+rm -rf $THIRD_PARTY/googletest
diff --git a/third_party/get_libevent.sh b/third_party/get_libevent.sh
new file mode 100755
index 0000000..9985bc0
--- /dev/null
+++ b/third_party/get_libevent.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+# Copyright 2015 The Weave Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Make libevent.
+# Example uses libevent to implement HTTPS server. This capability is
+# available only in version 2.1.x-alpha. Step could be replaced with apt-get
+# in future.
+cd $(dirname "$0")
+THIRD_PARTY=$(pwd)
+
+mkdir -p include lib
+
+rm -rf $THIRD_PARTY/libevent
+git clone https://github.com/libevent/libevent.git || exit 1
+cd libevent || exit 1
+
+./autogen.sh || exit 1
+./configure --disable-shared || exit 1
+make || exit 1
+if [ -z "$DISABLE_LIBEVENT_TEST" ]; then
+ echo -e "\n\nTesting libevent...\nCan take several minutes.\n"
+ make verify || exit 1
+fi
+cp -rf include/*.h include/event2 $THIRD_PARTY/include/ || exit 1
+cp -f .libs/lib* $THIRD_PARTY/lib/ || exit 1
+
+rm -rf $THIRD_PARTY/libevent
diff --git a/third_party/third_party.mk b/third_party/third_party.mk
new file mode 100644
index 0000000..91e4cf4
--- /dev/null
+++ b/third_party/third_party.mk
@@ -0,0 +1,79 @@
+# Copyright 2015 The Weave Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+###
+# third_party/chromium/
+
+third_party_chromium_base_obj_files := $(THIRD_PARTY_CHROMIUM_BASE_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o)
+
+# We don't need libgtest.a, but the headers files in third_party/include.
+$(third_party_chromium_base_obj_files) : out/$(BUILD_MODE)/%.o : %.cc third_party/lib/libgtest.a
+ mkdir -p $(dir $@)
+ $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $<
+
+third_party_chromium_base_unittest_obj_files := $(THIRD_PARTY_CHROMIUM_BASE_UNITTEST_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o)
+
+# We don't need libgtest.a, but the headers files in third_party/include.
+$(third_party_chromium_base_unittest_obj_files) : out/$(BUILD_MODE)/%.o : %.cc third_party/lib/libgtest.a
+ mkdir -p $(dir $@)
+ $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $<
+
+third_party_chromium_crypto_obj_files := $(THIRD_PARTY_CHROMIUM_CRYPTO_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o)
+
+# We don't need libgtest.a, but the headers files in third_party/include.
+$(third_party_chromium_crypto_obj_files) : out/$(BUILD_MODE)/%.o : %.cc third_party/lib/libgtest.a
+ mkdir -p $(dir $@)
+ $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $<
+
+third_party_chromium_crypto_unittest_obj_files := $(THIRD_PARTY_CHROMIUM_CRYPTO_UNITTEST_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o)
+
+# We don't need libgtest.a, but the headers files in third_party/include.
+$(third_party_chromium_crypto_unittest_obj_files) : out/$(BUILD_MODE)/%.o : %.cc third_party/lib/libgtest.a
+ mkdir -p $(dir $@)
+ $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $<
+
+###
+# third_party/modp_b64/
+
+third_party_modp_b64_obj_files := $(THIRD_PARTY_MODP_B64_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o)
+
+$(third_party_modp_b64_obj_files) : out/$(BUILD_MODE)/%.o : %.cc
+ mkdir -p $(dir $@)
+ $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $<
+
+###
+# third_party/libuweave/
+
+third_party_libuweave_obj_files := $(THIRD_PARTY_LIBUWEAVE_SRC_FILES:%.c=out/$(BUILD_MODE)/%.o)
+
+$(third_party_libuweave_obj_files) : out/$(BUILD_MODE)/%.o : %.c
+ mkdir -p $(dir $@)
+ $(CC) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_C) -c -o $@ $<
+
+###
+# libgtest and libgmock (third_party, downloaded on build)
+
+third_party/lib/libgtest.a :
+ @echo Downloading and building libgtest and libgmock...
+ third_party/get_gtest.sh
+ @echo Finished downloading and building libgtest and libgmock.
+
+clean-gtest :
+ rm -rf third_party/include/gtest third_party/include/gmock
+ rm -rf third_party/lib/libgmock* third_party/lib/libgtest*
+ rm -rf third_party/googletest
+
+###
+# libevent (third_party, downloaded on build)
+
+third_party/lib/libevent.a :
+ @echo Downloading and building libevent...
+ DISABLE_LIBEVENT_TEST=1 third_party/get_libevent.sh
+ @echo Finished downloading and building libevent.
+
+clean-libevent :
+ rm -rf third_party/include/ev* third_party/include/event2
+ rm -rf third_party/lib/libevent*
+ rm -rf third_party/libevent
+