aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJacob Marble <jacobmarble@google.com>2016-01-13 13:49:44 -0800
committerJacob Marble <jacobmarble@google.com>2016-01-14 05:15:01 +0000
commite785ec900282ba09ffc7279630e2f935cbb508af (patch)
tree3879ee0527c562faa5c9a8dd132373ea560ba6ea /examples
parentf1ac1d45ebc33a6d61bb5e3041d7d403bac56fb6 (diff)
downloadlibweave-e785ec900282ba09ffc7279630e2f935cbb508af.tar.gz
libweave: Remove gyp build files.
Also, added notes to examples/build.sh and examples/prerequisites.sh so that folks know where to turn to. BUG: 26508278 Change-Id: Ibc224916463383cd75089b9ef1c468bc12d150ca Reviewed-on: https://weave-review.googlesource.com/2189 Reviewed-by: Vitaly Buka <vitalybuka@google.com>
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/build.sh22
-rw-r--r--examples/daemon/README.md13
-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
12 files changed, 73 insertions, 251 deletions
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.md b/examples/daemon/README.md
index a447082..4585b5b 100644
--- a/examples/daemon/README.md
+++ b/examples/daemon/README.md
@@ -4,16 +4,19 @@ The wrapper implements OS dependent services for libweave
# Building
-### prepare environment
+### Build daemon examples
+
+The example binaries land in the out/Debug/ directory build all of them at once:
+
```
-examples/prerequisites.sh
+make all-examples
```
-### build daemon
+...or one at a time.
+
```
-examples/build.sh
+make out/Debug/weave_daemon_light
```
-Binaries for daemon are in the out/ directory.
# Prepare Host OS
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',
- ]
- }
- }
- ]
-}