Skip to content

Commit

Permalink
feat: Add initial support for PlatformIO and Arduino
Browse files Browse the repository at this point in the history
  • Loading branch information
ciband authored Dec 5, 2018
1 parent fe14e30 commit 2c8ab3f
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ language: cpp
# It is more tedious, but grants us far more flexibility.
matrix:
include:
- os: linux
dist: trusty
sudo: required
group: deprecated-2017Q3
install: ./ci/install-platformio.sh
script: ./ci/build-platformio.sh
- os: linux
compiler: gcc
sudo : true
Expand Down Expand Up @@ -44,6 +50,9 @@ matrix:
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11
if: type != pull_request

before_install:
- chmod -R +x ./ci/*.sh

# These are the install and build (script) phases for the most common entries in the matrix. They could be included
# in each entry in the matrix, but that is just repetitive.
install:
Expand Down
2 changes: 2 additions & 0 deletions ci/build-platformio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# run PlatformIO builds
platformio run
5 changes: 5 additions & 0 deletions ci/install-platformio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# install PlatformIO
sudo pip install -U platformio

# update PlatformIO
platformio update
16 changes: 16 additions & 0 deletions googlemock/src/gmock_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"

#ifdef ARDUINO
void setup() {
int argc = 0;
char** argv = nullptr;
// Since Google Mock depends on Google Test, InitGoogleMock() is
// also responsible for initializing Google Test. Therefore there's
// no need for calling testing::InitGoogleTest() separately.
testing::InitGoogleMock(&argc, argv);
}
void loop() {
RUN_ALL_TESTS();
}
#else

// MS C++ compiler/linker has a bug on Windows (not on Windows CE), which
// causes a link error when _tmain is defined in a static library and UNICODE
// is enabled. For this reason instead of _tmain, main function is used on
Expand All @@ -52,3 +66,5 @@ GTEST_API_ int main(int argc, char** argv) {
testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS();
}
#endif

14 changes: 14 additions & 0 deletions googletest/src/gtest_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,22 @@
#include <stdio.h>
#include "gtest/gtest.h"

#ifdef ARDUINO
void setup() {
int argc = 0;
char** argv = nullptr;
testing::InitGoogleTest(&argc, argv);
}

void loop() {
RUN_ALL_TESTS();
}

#else

GTEST_API_ int main(int argc, char **argv) {
printf("Running main() from %s\n", __FILE__);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
#endif
31 changes: 31 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html


[platformio]
#src_dir = ./googlemock
#src_dir = ./googletest
src_dir = .

[env:googletest_esp32]
platform = espressif32
board = esp32dev
framework = arduino
build_flags = -I./googletest/include -I./googletest
src_filter = +<*> -<.git/> -<googlemock> -<googletest/codegear/> -<googletest/samples> -<googletest/test/> -<googletest/xcode> -<googletest/src> +<googletest/src/gtest-all.cc> +<googletest/src/gtest_main.cc>
upload_speed = 921600

[env:googlemock_esp32]
platform = espressif32
board = esp32dev
framework = arduino
build_flags = -I./googlemock/include -I./googletest/include -I./googletest -I./googlemock
src_filter = +<*> -<.git/> -<googletest> -<googlemock/test/> -<googlemock/src> +<googlemock/src/gmock-all.cc> +<googlemock/src/gmock_main.cc> +<googletest/src/gtest-all.cc>
upload_speed = 921600

0 comments on commit 2c8ab3f

Please sign in to comment.