From e6244289ff31367d88c620c82bf378c53e79084e Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 27 Jul 2016 22:18:56 -0500 Subject: [PATCH] Create dummy wpiutil library. (#84) This will allow dependencies such as wpilibc to update to use wpiutil without breaking "normal" ntcore static library use in the meantime. This commit also restructures the gradle files by creating a new (placeholder) wpiutil project, and moving the ntcore project into a separate gradle file. Added toolchains/native.gradle (refactored from ntcore). Also fixes ntcore skipJava on Windows by providing an alternate .def file for this case. --- src/dummy.cpp | 3 +++ unittest/main.cpp | 15 +++++++++++++++ unittest/unittest.gradle | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 src/dummy.cpp create mode 100644 unittest/main.cpp create mode 100644 unittest/unittest.gradle diff --git a/src/dummy.cpp b/src/dummy.cpp new file mode 100644 index 0000000000..3d12903c98 --- /dev/null +++ b/src/dummy.cpp @@ -0,0 +1,3 @@ +namespace wpi { +void DummyFunction() {} +} diff --git a/unittest/main.cpp b/unittest/main.cpp new file mode 100644 index 0000000000..e380efdd59 --- /dev/null +++ b/unittest/main.cpp @@ -0,0 +1,15 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2015. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "gtest/gtest.h" + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + int ret = RUN_ALL_TESTS(); + return ret; +} diff --git a/unittest/unittest.gradle b/unittest/unittest.gradle new file mode 100644 index 0000000000..89fc2909d7 --- /dev/null +++ b/unittest/unittest.gradle @@ -0,0 +1,39 @@ +apply plugin: 'google-test' + +model { + testSuites { + wpiutilTest { + sources { + cpp { + source { + srcDirs = ["${rootDir}/wpiutil/unittest"] + includes = ['**/*.cpp'] + } + exportedHeaders { + srcDirs = ["${rootDir}/wpiutil/include", "${rootDir}/gmock/include", "${rootDir}/gmock/gtest/include"] + includes = ['**/*.h'] + } + } + } + binaries.all { + lib project: ':gmock', library: 'gmock', linkage: 'static' + lib library: 'wpiutil', linkage: 'static' + } + } + } +} + +model { + binaries { + withType(GoogleTestTestSuiteBinarySpec) { + lib project: ':gmock', library: "gmock", linkage: "static" + lib library: 'wpiutil', linkage: 'static' + if (targetPlatform.operatingSystem.windows) { + cppCompiler.args '/EHsc', '/DNOMINMAX', '/D_SCL_SECURE_NO_WARNINGS', '/D_WINSOCK_DEPRECATED_NO_WARNINGS' + } else { + cppCompiler.args '-pthread', '-std=c++1y' + linker.args '-pthread' + } + } + } +}