NerfUS_cmake_add_library_from_mbed

Dependencies:   mbed-rtos mbed HardwareInterface

Fork of NerfUS_cmake_cleanup by Maxime Dupuis

Files at this revision

API Documentation at this revision

Comitter:
Maxime Dupuis
Date:
Thu Feb 16 12:34:00 2017 -0500
Parent:
11:55930acb6c96
Commit message:
Import HardwareInterface and mock it

Changed in this revision

BlinkLib.lib Show diff for this revision Revisions of this file
CMakeLists.txt Show annotated file Show diff for this revision Revisions of this file
CMakeLists.txt.in Show diff for this revision Revisions of this file
GoogleTest.txt.in Show annotated file Show diff for this revision Revisions of this file
HardwareInterface.cmake Show annotated file Show diff for this revision Revisions of this file
HardwareInterface.lib Show annotated file Show diff for this revision Revisions of this file
HardwareInterface.txt.in Show annotated file Show diff for this revision Revisions of this file
TESTS/HardwareInterfaceImportTest.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 55930acb6c96 -r 850be84c78dd BlinkLib.lib
--- a/BlinkLib.lib	Thu Feb 16 11:24:08 2017 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/users/dupm2216/code/BlinkLib/#77124b36cdd4
diff -r 55930acb6c96 -r 850be84c78dd CMakeLists.txt
--- a/CMakeLists.txt	Thu Feb 16 11:24:08 2017 -0500
+++ b/CMakeLists.txt	Thu Feb 16 12:34:00 2017 -0500
@@ -1,7 +1,7 @@
 cmake_minimum_required(VERSION 3.5)
 
 include("GoogleTest.cmake")
-include("BlinkLib.cmake")
+include("HardwareInterface.cmake")
 
 include_directories(include)
 
diff -r 55930acb6c96 -r 850be84c78dd CMakeLists.txt.in
--- a/CMakeLists.txt.in	Thu Feb 16 11:24:08 2017 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-cmake_minimum_required(VERSION 3.5)
- 
-project(googletest-download NONE)
- 
-include(ExternalProject)
-ExternalProject_Add(googletest
-  GIT_REPOSITORY    https://github.com/google/googletest.git
-  SOURCE_DIR        "${CMAKE_BINARY_DIR}/googletest-src"
-  BINARY_DIR        "${CMAKE_BINARY_DIR}/googletest-build"
-  CONFIGURE_COMMAND ""
-  BUILD_COMMAND     ""
-  INSTALL_COMMAND   ""
-  TEST_COMMAND      ""
-)
diff -r 55930acb6c96 -r 850be84c78dd GoogleTest.txt.in
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GoogleTest.txt.in	Thu Feb 16 12:34:00 2017 -0500
@@ -0,0 +1,15 @@
+cmake_minimum_required(VERSION 3.5)
+ 
+project(googletest-download NONE)
+ 
+include(ExternalProject)
+ExternalProject_Add(googletest
+  GIT_REPOSITORY    https://github.com/google/googletest.git
+  SOURCE_DIR        "${CMAKE_BINARY_DIR}/googletest-src"
+  BINARY_DIR        "${CMAKE_BINARY_DIR}/googletest-build"
+  CONFIGURE_COMMAND ""
+  BUILD_COMMAND     ""
+  INSTALL_COMMAND   ""
+  TEST_COMMAND      ""
+)
+
diff -r 55930acb6c96 -r 850be84c78dd HardwareInterface.cmake
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HardwareInterface.cmake	Thu Feb 16 12:34:00 2017 -0500
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.5)
+
+# Download and unpack hardwareInterface at configure time
+configure_file(HardwareInterface.txt.in
+               hardwareInterface-download/CMakeLists.txt)
+
+execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
+  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/hardwareInterface-download )
+execute_process(COMMAND ${CMAKE_COMMAND} --build .
+  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/hardwareInterface-download )
+ 
+# Add hardwareInterface directly to our build.
+add_subdirectory(${CMAKE_BINARY_DIR}/hardwareInterface-src
+                 ${CMAKE_BINARY_DIR}/hardwareInterface-build)
+ 
+include_directories("${hardwareInterface_SOURCE_DIR}/include")
+
diff -r 55930acb6c96 -r 850be84c78dd HardwareInterface.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HardwareInterface.lib	Thu Feb 16 12:34:00 2017 -0500
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/NerfUS/code/HardwareInterface/
diff -r 55930acb6c96 -r 850be84c78dd HardwareInterface.txt.in
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HardwareInterface.txt.in	Thu Feb 16 12:34:00 2017 -0500
@@ -0,0 +1,15 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(hardwareInterface-download NONE)
+ 
+include(ExternalProject)
+ExternalProject_Add(hardwareInterface
+  HG_REPOSITORY     https://developer.mbed.org/teams/NerfUS/code/HardwareInterface/
+  SOURCE_DIR        "${CMAKE_BINARY_DIR}/hardwareInterface-src"
+  BINARY_DIR        "${CMAKE_BINARY_DIR}/hardwareInterface-build"
+  CONFIGURE_COMMAND ""
+  BUILD_COMMAND     ""
+  INSTALL_COMMAND   ""
+  TEST_COMMAND      ""
+)
+
diff -r 55930acb6c96 -r 850be84c78dd TESTS/HardwareInterfaceImportTest.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TESTS/HardwareInterfaceImportTest.cpp	Thu Feb 16 12:34:00 2017 -0500
@@ -0,0 +1,19 @@
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include "HardwareInterface.hpp"
+
+class MockHardwareLPC1768 : public HardwareInterface
+{
+    public:
+        MOCK_METHOD0(blink, void());
+};
+
+TEST(ImportingLibraryFromMbedOrg, IsPossibleToMockInterface)
+{
+    MockHardwareLPC1768 hardwareLPC1768;
+
+    EXPECT_CALL(hardwareLPC1768, blink());
+
+    hardwareLPC1768.blink();
+}
+
diff -r 55930acb6c96 -r 850be84c78dd main.cpp
--- a/main.cpp	Thu Feb 16 11:24:08 2017 -0500
+++ b/main.cpp	Thu Feb 16 12:34:00 2017 -0500
@@ -1,14 +1,14 @@
 #include "rtos.h"
-#include "MbedBlinker.hpp"
+#include "HardwareLPC1768.hpp"
 
 DigitalOut led(LED1);
 
 int main()
 {
-    MbedBlinker blinker(led);
+    HardwareLPC1768 hardware_lpc1768(led);
     while(1)
     {
-        blinker.blink();
+        hardware_lpc1768.blink();
     }
 }