aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Rossignol <aarossig@google.com>2017-02-28 17:12:58 -0800
committerBrian Duddie <bduddie@google.com>2017-03-03 16:34:36 -0800
commit388d81b80425f66acb306c774e46d53221d36b33 (patch)
tree4935b15ebb440c9e1048a6388987208c4140a47d
parent3e7aa59e607be3b5bd0c710bc2f5762770eee395 (diff)
downloadchre-388d81b80425f66acb306c774e46d53221d36b33.tar.gz
Adds support for Makefile Linux and GoogleTest builds
- gtest runs, but no tests are registered yet - Linux runs successfully - The next step is to migrate tests to run with gtest and remove BUILD files Change-Id: I94606074f8aea1f3b1a164227efbe3184b02b2a7
-rw-r--r--Makefile8
-rw-r--r--build/variant/google_cm4_nanohub.mk1
-rw-r--r--build/variant/google_hexagonv60_slpi.mk1
-rw-r--r--build/variant/google_hexagonv62_slpi.mk1
-rw-r--r--build/variant/google_x86_googletest.mk28
-rw-r--r--build/variant/google_x86_linux.mk1
-rw-r--r--build/variant/qcom_hexagonv60_nanohub.mk1
-rw-r--r--external/external.mk27
-rw-r--r--platform/linux/event_loop.cc38
-rw-r--r--platform/linux/init.cc18
-rw-r--r--platform/platform.mk4
11 files changed, 109 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index c00d47f2..3e3dbcc8 100644
--- a/Makefile
+++ b/Makefile
@@ -15,13 +15,13 @@ CHRE_PREFIX = .
ifeq ($(HEXAGON_SDK_PREFIX),)
$(error "You must supply a HEXAGON_SDK_PREFIX environment variable \
containing a path to the hexagon SDK. Example: \
- $$HOME/Qualcomm/Hexagon_SDK/3.0")
+ export HEXAGON_SDK_PREFIX=$$HOME/Qualcomm/Hexagon_SDK/3.0")
endif
ifeq ($(SLPI_PREFIX),)
-$(error "You must supply an SLPI_PREFIX environemnt variable \
+$(error "You must supply an SLPI_PREFIX environment variable \
containing a path to the SLPI source tree. Example: \
- $$HOME/slpi_proc")
+ export SLPI_PREFIX=$$HOME/slpi_proc")
endif
# Build Configuration ##########################################################
@@ -56,6 +56,7 @@ include apps/sensor_world/sensor_world.mk
include apps/timer_world/timer_world.mk
include chre_api/chre_api.mk
include core/core.mk
+include external/external.mk
include pal/pal.mk
include platform/platform.mk
include util/util.mk
@@ -69,3 +70,4 @@ include build/common.mk
include $(CHRE_PREFIX)/build/variant/google_hexagonv60_slpi.mk
include $(CHRE_PREFIX)/build/variant/google_hexagonv62_slpi.mk
include $(CHRE_PREFIX)/build/variant/google_x86_linux.mk
+include $(CHRE_PREFIX)/build/variant/google_x86_googletest.mk
diff --git a/build/variant/google_cm4_nanohub.mk b/build/variant/google_cm4_nanohub.mk
index e761a47b..0203000a 100644
--- a/build/variant/google_cm4_nanohub.mk
+++ b/build/variant/google_cm4_nanohub.mk
@@ -6,6 +6,7 @@ include $(CHRE_PREFIX)/build/clean_build_template_args.mk
TARGET_NAME = google_cm4_nanohub
TARGET_CFLAGS = -DCHRE_MESSAGE_TO_HOST_MAX_SIZE=128
+TARGET_CFLAGS += $(GOOGLE_CM4_NANOHUB_CFLAGS)
TARGET_VARIANT_SRCS = $(GOOGLE_CM4_NANOHUB_SRCS)
CORTEXM_ARCH = m4
diff --git a/build/variant/google_hexagonv60_slpi.mk b/build/variant/google_hexagonv60_slpi.mk
index dcf166b3..410076c5 100644
--- a/build/variant/google_hexagonv60_slpi.mk
+++ b/build/variant/google_hexagonv60_slpi.mk
@@ -6,6 +6,7 @@ include $(CHRE_PREFIX)/build/clean_build_template_args.mk
TARGET_NAME = google_hexagonv60_slpi
TARGET_CFLAGS = -DCHRE_MESSAGE_TO_HOST_MAX_SIZE=2048
+TARGET_CFLAGS += $(GOOGLE_HEXAGONV60_SLPI_CFLAGS)
TARGET_VARIANT_SRCS = $(GOOGLE_HEXAGONV60_SLPI_SRCS)
HEXAGON_ARCH = v60
diff --git a/build/variant/google_hexagonv62_slpi.mk b/build/variant/google_hexagonv62_slpi.mk
index fc7d6078..c55b96d6 100644
--- a/build/variant/google_hexagonv62_slpi.mk
+++ b/build/variant/google_hexagonv62_slpi.mk
@@ -6,6 +6,7 @@ include $(CHRE_PREFIX)/build/clean_build_template_args.mk
TARGET_NAME = google_hexagonv62_slpi
TARGET_CFLAGS = -DCHRE_MESSAGE_TO_HOST_MAX_SIZE=2048
+TARGET_CFLAGS += $(GOOGLE_HEXAGONV62_SLPI_CFLAGS)
TARGET_VARIANT_SRCS = $(GOOGLE_HEXAGONV62_SLPI_SRCS)
HEXAGON_ARCH = v62
diff --git a/build/variant/google_x86_googletest.mk b/build/variant/google_x86_googletest.mk
new file mode 100644
index 00000000..9f98095e
--- /dev/null
+++ b/build/variant/google_x86_googletest.mk
@@ -0,0 +1,28 @@
+#
+# CHRE GoogleTest Build Variant
+#
+
+include $(CHRE_PREFIX)/build/clean_build_template_args.mk
+
+TARGET_NAME = google_x86_googletest
+TARGET_CFLAGS = -DCHRE_MESSAGE_TO_HOST_MAX_SIZE=2048
+TARGET_CFLAGS += $(GOOGLE_X86_GOOGLETEST_CFLAGS)
+TARGET_VARIANT_SRCS = $(GOOGLE_X86_GOOGLETEST_SRCS)
+
+ifneq ($(filter $(TARGET_NAME)% all, $(MAKECMDGOALS)),)
+ifeq ($(GOOGLETEST_PREFIX),)
+$(error "You must supply a GOOGLETEST_PREFIX environment variable \
+ containing a path to the Google Test project tree. Example \
+ export GOOGLETEST_PREFIX=$$HOME/android/master/external/googletest")
+endif
+
+# Instruct the build to link a final executable.
+TARGET_BUILD_BIN = true
+
+# Link in libraries for the final executable.
+TARGET_BIN_LDFLAGS += -lrt
+TARGET_BIN_LDFLAGS += -lpthread
+
+include $(CHRE_PREFIX)/build/arch/x86.mk
+include $(CHRE_PREFIX)/build/build_template.mk
+endif
diff --git a/build/variant/google_x86_linux.mk b/build/variant/google_x86_linux.mk
index c584d6ba..ea1ef242 100644
--- a/build/variant/google_x86_linux.mk
+++ b/build/variant/google_x86_linux.mk
@@ -6,6 +6,7 @@ include $(CHRE_PREFIX)/build/clean_build_template_args.mk
TARGET_NAME = google_x86_linux
TARGET_CFLAGS = -DCHRE_MESSAGE_TO_HOST_MAX_SIZE=2048
+TARGET_CFLAGS += $(GOOGLE_X86_LINUX_CFLAGS)
TARGET_VARIANT_SRCS = $(GOOGLE_X86_LINUX_SRCS)
ifneq ($(filter $(TARGET_NAME)% all, $(MAKECMDGOALS)),)
diff --git a/build/variant/qcom_hexagonv60_nanohub.mk b/build/variant/qcom_hexagonv60_nanohub.mk
index c0930f48..678f6fc6 100644
--- a/build/variant/qcom_hexagonv60_nanohub.mk
+++ b/build/variant/qcom_hexagonv60_nanohub.mk
@@ -6,6 +6,7 @@ include $(CHRE_PREFIX)/build/clean_build_template_args.mk
TARGET_NAME = qcom_hexagonv60_nanohub
TARGET_CFLAGS = -DCHRE_MESSAGE_TO_HOST_MAX_SIZE=4080
+TARGET_CFLAGS += $(QCOM_HEXAGONV60_NANOHUB_CFLAGS)
TARGET_VARIANT_SRCS = $(QCOM_HEXAGONV60_NANOHUB_SRCS)
HEXAGON_ARCH = v60
diff --git a/external/external.mk b/external/external.mk
new file mode 100644
index 00000000..3b95bb2d
--- /dev/null
+++ b/external/external.mk
@@ -0,0 +1,27 @@
+#
+# External Projects Makefile
+#
+
+#
+# GoogleTest/GoogleMock
+#
+
+GOOGLETEST_PATH = $(GOOGLETEST_PREFIX)/googletest
+GOOGLEMOCK_PATH = $(GOOGLETEST_PREFIX)/googlemock
+
+# Common Compiler Flags ########################################################
+
+# Include paths.
+GOOGLE_X86_GOOGLETEST_CFLAGS += -I$(GOOGLETEST_PATH)
+GOOGLE_X86_GOOGLETEST_CFLAGS += -I$(GOOGLETEST_PATH)/include
+GOOGLE_X86_GOOGLETEST_CFLAGS += -I$(GOOGLEMOCK_PATH)
+GOOGLE_X86_GOOGLETEST_CFLAGS += -I$(GOOGLEMOCK_PATH)/include
+
+# x86 GoogleTest Source Files ##################################################
+
+GOOGLE_X86_GOOGLETEST_SRCS += $(GOOGLETEST_PATH)/src/gtest-all.cc
+GOOGLE_X86_GOOGLETEST_SRCS += $(GOOGLETEST_PATH)/src/gtest_main.cc
+
+# x86 GoogleMock Source Files ##################################################
+
+GOOGLE_X86_GOOGLETEST_SRCS += $(GOOGLEMOCK_PATH)/src/gmock-all.cc
diff --git a/platform/linux/event_loop.cc b/platform/linux/event_loop.cc
new file mode 100644
index 00000000..1a0f6148
--- /dev/null
+++ b/platform/linux/event_loop.cc
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "chre/platform/context.h"
+#include "chre/core/event_loop_manager.h"
+
+namespace {
+
+chre::EventLoop *gEventLoop = nullptr;
+
+} // namespace
+
+namespace chre {
+
+EventLoop *getCurrentEventLoop() {
+ if (gEventLoop == nullptr) {
+ gEventLoop = chre::EventLoopManagerSingleton::get()->createEventLoop();
+ }
+
+ // note: on a multi-threaded implementation, we would likely use thread-local
+ // storage here if available, or a map from thread ID --> eventLoop
+ return gEventLoop;
+}
+
+} // namespace chre
diff --git a/platform/linux/init.cc b/platform/linux/init.cc
index 6c7dc7bf..d85153f1 100644
--- a/platform/linux/init.cc
+++ b/platform/linux/init.cc
@@ -22,6 +22,7 @@
#include "chre/core/event_loop_manager.h"
#include "chre/core/init.h"
#include "chre/core/nanoapp.h"
+#include "chre/platform/context.h"
#include "chre/platform/log.h"
#include "chre/platform/system_timer.h"
#include "chre/platform/platform_nanoapp.h"
@@ -33,8 +34,6 @@ using chre::Milliseconds;
namespace {
-chre::EventLoop *gEventLoop = nullptr;
-
void delayedEventCallback(void *data) {
LOGI("Got a delayed event callback");
auto *eventLoop = static_cast<chre::EventLoop *>(data);
@@ -50,21 +49,11 @@ void timerCallback(void *data) {
extern "C" void signalHandler(int sig) {
(void) sig;
LOGI("Stop request received");
- gEventLoop->stop();
+ chre::getCurrentEventLoop()->stop();
}
}
-namespace chre {
-
-EventLoop *getCurrentEventLoop() {
- // note: on a multi-threaded implementation, we would likely use thread-local
- // storage here if available, or a map from thread ID --> eventLoop
- return gEventLoop;
-}
-
-} // namespace chre
-
int main() {
chre::init();
@@ -84,8 +73,7 @@ int main() {
timerWorldPlatformNanoapp.mStop = chre::app::timerWorldStop;
// Construct the event loop.
- gEventLoop = chre::EventLoopManagerSingleton::get()->createEventLoop();
- chre::EventLoop& eventLoop = *gEventLoop;
+ chre::EventLoop& eventLoop = *chre::getCurrentEventLoop();
// Start the hello world nanoapp.
chre::Nanoapp helloWorldNanoapp(eventLoop.getNextInstanceId(),
diff --git a/platform/platform.mk b/platform/platform.mk
index a73b2d03..7471f5bf 100644
--- a/platform/platform.mk
+++ b/platform/platform.mk
@@ -51,8 +51,8 @@ X86_SRCS += platform/shared/chre_api_re.cc
X86_SRCS += platform/shared/chre_api_sensor.cc
X86_SRCS += platform/shared/chre_api_version.cc
X86_SRCS += platform/shared/chre_api_wifi.cc
+X86_SRCS += platform/linux/event_loop.cc
X86_SRCS += platform/linux/host_link.cc
-X86_SRCS += platform/linux/init.cc
X86_SRCS += platform/linux/system_time.cc
X86_SRCS += platform/linux/system_timer.cc
X86_SRCS += platform/linux/platform_sensor.cc
@@ -62,3 +62,5 @@ X86_SRCS += platform/shared/pal_system_api.cc
X86_SRCS += platform/shared/platform_nanoapp.cc
X86_SRCS += platform/shared/platform_wifi.cc
X86_SRCS += platform/shared/system_time.cc
+
+GOOGLE_X86_LINUX_SRCS += platform/linux/init.cc