Permalink
Browse files

Include googletest as a submodule (#3993)

Add googletest as a submodule in third_party/googletest.
  • Loading branch information...
coryan authored and xfxyjwf committed Mar 26, 2018
1 parent 1156ee7 commit 3c5442a95d9608519a76a5db27d21d71dd1137a1
Showing with 83 additions and 120 deletions.
  1. +9 −1 .gitignore
  2. +4 −0 .gitmodules
  3. +7 −8 Makefile.am
  4. +6 −7 WORKSPACE
  5. +1 −9 appveyor.yml
  6. +0 −18 autogen.sh
  7. +4 −15 cmake/README.md
  8. +11 −9 cmake/tests.cmake
  9. +1 −1 configure.ac
  10. +0 −28 gmock.BUILD
  11. +3 −0 jenkins/pull_request_in_docker.sh
  12. +3 −0 kokoro/linux/pull_request_in_docker.sh
  13. +27 −23 src/Makefile.am
  14. +1 −1 src/README.md
  15. +5 −0 tests.sh
  16. +1 −0 third_party/googletest
View
@@ -19,7 +19,7 @@ m4/lt~obsolete.m4
autom4te.cache
# downloaded files
gmock
./gmock
# in-tree configure-generated files
Makefile
@@ -180,3 +180,11 @@ ruby/Gemfile.lock
ruby/compatibility_tests/v3.0.0/protoc
ruby/compatibility_tests/v3.0.0/tests/generated_code_pb.rb
ruby/compatibility_tests/v3.0.0/tests/test_import_pb.rb
# IntelliJ CLion Config files and build output
cmake/.idea
cmake/cmake-build-debug/
# Common build subdirectories.
./.build/
./_build/
View
@@ -1,3 +1,7 @@
[submodule "third_party/benchmark"]
path = third_party/benchmark
url = https://github.com/google/benchmark.git
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://github.com/google/googletest.git
ignore = dirty
View
@@ -8,8 +8,8 @@ AUTOMAKE_OPTIONS = foreign
# the right time.
SUBDIRS = . src
# Always include gmock in distributions.
DIST_SUBDIRS = $(subdirs) src conformance benchmarks
# Always include third_party directories in distributions.
DIST_SUBDIRS = src conformance benchmarks third_party/googletest
# Build gmock before we build protobuf tests. We don't add gmock to SUBDIRS
# because then "make check" would also build and run all of gmock's own tests,
@@ -18,8 +18,8 @@ DIST_SUBDIRS = $(subdirs) src conformance benchmarks
# the installed version of gmock if there is one.
check-local:
@echo "Making lib/libgmock.a lib/libgmock_main.a in gmock"
@cd gmock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la
@cd gmock/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
@cd third_party/googletest/googletest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
@cd third_party/googletest/googlemock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la
# We would like to clean gmock when "make clean" is invoked. But we have to
# be careful because clean-local is also invoked during "make distclean", but
@@ -28,9 +28,9 @@ check-local:
# cd to the directory again and "make clean" it will fail. So, check that the
# Makefile exists before recursing.
clean-local:
@if test -e gmock/Makefile; then \
echo "Making clean in gmock"; \
cd gmock && $(MAKE) $(AM_MAKEFLAGS) clean; \
@if test -e third_party/googletest/Makefile; then \
echo "Making clean in googletest"; \
cd third_party/googletest && $(MAKE) $(AM_MAKEFLAGS) clean; \
fi; \
if test -e conformance/Makefile; then \
echo "Making clean in conformance"; \
@@ -1008,7 +1008,6 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
CHANGES.txt \
update_file_lists.sh \
BUILD \
gmock.BUILD \
WORKSPACE \
cmake/CMakeLists.txt \
cmake/README.md \
View
@@ -1,10 +1,9 @@
workspace(name = "com_google_protobuf")
new_git_repository(
name = "googletest",
build_file = "gmock.BUILD",
remote = "https://github.com/google/googletest",
tag = "release-1.8.0",
new_local_repository(
name = "submodule_gmock",
path = "third_party/googletest",
build_file = "third_party/googletest/BUILD.bazel"
)
new_http_archive(
@@ -21,12 +20,12 @@ bind(
bind(
name = "gtest",
actual = "@googletest//:gtest",
actual = "@submodule_gmock//:gtest",
)
bind(
name = "gtest_main",
actual = "@googletest//:gtest_main",
actual = "@submodule_gmock//:gtest_main",
)
bind(
View
@@ -22,15 +22,7 @@ environment:
test: off
install:
- curl -L -o release-1.7.0.zip https://github.com/google/googlemock/archive/release-1.7.0.zip
- 7z x release-1.7.0.zip
- del /Q release-1.7.0.zip
- rename googlemock-release-1.7.0 gmock
- curl -L -o release-1.7.0.zip "https://github.com/google/googletest/archive/release-1.7.0.zip"
- 7z x release-1.7.0.zip
- del /Q release-1.7.0.zip
- rename googletest-release-1.7.0 gtest
- move gtest gmock
- git submodule update --init --recursive
before_build:
- if %platform%==Win32 set generator=Visual Studio 14
View
@@ -17,7 +17,6 @@ if [ ! -z "$@" ]; then
done
fi
# Check that we're being run from the right directory.
if test ! -f src/google/protobuf/stubs/common.h; then
cat >&2 << __EOF__
@@ -27,23 +26,6 @@ __EOF__
exit 1
fi
# Check that gmock is present. Usually it is already there since the
# directory is set up as an SVN external.
if test ! -e gmock; then
echo "Google Mock not present. Fetching gmock-1.7.0 from the web..."
curl $curlopts -L -O https://github.com/google/googlemock/archive/release-1.7.0.zip
unzip -q release-1.7.0.zip
rm release-1.7.0.zip
mv googlemock-release-1.7.0 gmock
fi
if test ! -e gmock/gtest; then
curl $curlopts -L -O https://github.com/google/googletest/archive/release-1.7.0.zip
unzip -q release-1.7.0.zip
rm release-1.7.0.zip
mv googletest-release-1.7.0 gmock/gtest
fi
set -ex
# TODO(kenton): Remove the ",no-obsolete" part and fix the resulting warnings.
View
@@ -55,22 +55,11 @@ Go to the project folder:
C:\Path\to>cd protobuf
C:\Path\to\protobuf>
Protobuf unit-tests require gmock to build. If you download protobuf source code
from the *releases* page, the *gmock* directory should already be there. If you checkout
the code via `git clone`, this *gmock* directory won't exist and you will have to
download it manually or skip building protobuf unit-tests.
Remember to update any submodules:
You can download gmock as follows:
C:\Path\to\protobuf>git clone -b release-1.7.0 https://github.com/google/googlemock.git gmock
Then go to *gmock* folder and download gtest:
C:\Path\to\protobuf>cd gmock
C:\Path\to\protobuf\gmock>git clone -b release-1.7.0 https://github.com/google/googletest.git gtest
If you absolutely don't want to build and run protobuf unit-tests, skip
this steps and use protobuf at your own risk.
```console
C:\Path\to> git submodule update --init --recursive
```
Now go to *cmake* folder in protobuf sources:
View
@@ -1,24 +1,26 @@
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/../gmock/CMakeLists.txt")
message(FATAL_ERROR "Cannot find gmock directory.")
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/../third_party/googletest/CMakeLists.txt")
message(FATAL_ERROR "Cannot find third_party/googletest directory.")
endif()
option(protobuf_ABSOLUTE_TEST_PLUGIN_PATH
"Using absolute test_plugin path in tests" ON)
mark_as_advanced(protobuf_ABSOLUTE_TEST_PLUGIN_PATH)
set(googlemock_source_dir "${protobuf_source_dir}/third_party/googletest/googlemock")
set(googletest_source_dir "${protobuf_source_dir}/third_party/googletest/googletest")
include_directories(
${protobuf_source_dir}/gmock
${protobuf_source_dir}/gmock/gtest
${protobuf_source_dir}/gmock/gtest/include
${protobuf_source_dir}/gmock/include
${googlemock_source_dir}
${googletest_source_dir}
${googletest_source_dir}/include
${googlemock_source_dir}/include
)
add_library(gmock STATIC
${protobuf_source_dir}/gmock/src/gmock-all.cc
${protobuf_source_dir}/gmock/gtest/src/gtest-all.cc
"${googlemock_source_dir}/src/gmock-all.cc"
"${googletest_source_dir}/src/gtest-all.cc"
)
target_link_libraries(gmock ${CMAKE_THREAD_LIBS_INIT})
add_library(gmock_main STATIC ${protobuf_source_dir}/gmock/src/gmock_main.cc)
add_library(gmock_main STATIC "${googlemock_source_dir}/src/gmock_main.cc")
target_link_libraries(gmock_main gmock)
set(lite_test_protos
View
@@ -214,7 +214,7 @@ AX_CXX_COMPILE_STDCXX([11], [noext], [optional])
# too.
export CFLAGS
export CXXFLAGS
AC_CONFIG_SUBDIRS([gmock])
AC_CONFIG_SUBDIRS([third_party/googletest])
AC_CONFIG_FILES([Makefile src/Makefile benchmarks/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc])
AC_OUTPUT
View

This file was deleted.

Oops, something went wrong.
@@ -19,6 +19,9 @@ cd $BUILD_DIR
git clone /var/local/jenkins/protobuf
cd protobuf
# Initialize any submodules:
git submodule update --init --recursive
# Set up the directory where our test output is going to go.
OUTPUT_DIR=`mktemp -d`
LOG_OUTPUT_DIR=$OUTPUT_DIR/logs
@@ -19,6 +19,9 @@ cd $BUILD_DIR
git clone /var/local/kokoro/protobuf
cd protobuf
# Initialize any submodules:
git submodule update --init --recursive
# Set up the directory where our test output is going to go.
OUTPUT_DIR=`mktemp -d`
LOG_OUTPUT_DIR=$OUTPUT_DIR/logs
View
@@ -711,15 +711,19 @@ COMMON_TEST_SOURCES = \
google/protobuf/testing/file.cc \
google/protobuf/testing/file.h
GOOGLETEST_BUILD_DIR=../third_party/googletest/googletest
GOOGLEMOCK_BUILD_DIR=../third_party/googletest/googlemock
GOOGLETEST_SRC_DIR=$(srcdir)/../third_party/googletest/googletest
GOOGLEMOCK_SRC_DIR=$(srcdir)/../third_party/googletest/googlemock
check_PROGRAMS = protoc protobuf-test protobuf-lazy-descriptor-test \
protobuf-lite-test test_plugin protobuf-lite-arena-test \
no-warning-test $(GZCHECKPROGRAMS)
protobuf_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \
../gmock/gtest/lib/libgtest.la \
../gmock/lib/libgmock.la \
../gmock/lib/libgmock_main.la
protobuf_test_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include \
-I$(srcdir)/../gmock/include
$(GOOGLETEST_BUILD_DIR)/lib/libgtest.la \
$(GOOGLEMOCK_BUILD_DIR)/lib/libgmock.la \
$(GOOGLEMOCK_BUILD_DIR)/lib/libgmock_main.la
protobuf_test_CPPFLAGS = -I$(GOOGLETEST_SRC_DIR)/include \
-I$(GOOGLEMOCK_SRC_DIR)/include
# Disable optimization for tests unless the user explicitly asked for it,
# since test_util.cc takes forever to compile with optimization (with GCC).
# See configure.ac for more info.
@@ -807,11 +811,11 @@ $(am_protobuf_test_OBJECTS): unittest_proto_middleman
# Run cpp_unittest again with PROTOBUF_TEST_NO_DESCRIPTORS defined.
protobuf_lazy_descriptor_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la \
libprotoc.la \
../gmock/gtest/lib/libgtest.la \
../gmock/lib/libgmock.la \
../gmock/lib/libgmock_main.la
protobuf_lazy_descriptor_test_CPPFLAGS = -I$(srcdir)/../gmock/include \
-I$(srcdir)/../gmock/gtest/include \
$(GOOGLETEST_BUILD_DIR)/lib/libgtest.la \
$(GOOGLEMOCK_BUILD_DIR)/lib/libgmock.la \
$(GOOGLEMOCK_BUILD_DIR)/lib/libgmock_main.la
protobuf_lazy_descriptor_test_CPPFLAGS = -I$(GOOGLEMOCK_SRC_DIR)/include \
-I$(GOOGLETEST_SRC_DIR)/include \
-DPROTOBUF_TEST_NO_DESCRIPTORS
protobuf_lazy_descriptor_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
protobuf_lazy_descriptor_test_SOURCES = \
@@ -832,12 +836,12 @@ COMMON_LITE_TEST_SOURCES = \
# depend on gtest because our internal version of gtest depend on proto
# full runtime and we want to make sure this test builds without full
# runtime.
protobuf_lite_test_LDADD = $(PTHREAD_LIBS) libprotobuf-lite.la \
../gmock/gtest/lib/libgtest.la \
../gmock/lib/libgmock.la \
../gmock/lib/libgmock_main.la
protobuf_lite_test_CPPFLAGS= -I$(srcdir)/../gmock/include \
-I$(srcdir)/../gmock/gtest/include
protobuf_lite_test_LDADD = $(PTHREAD_LIBS) libprotobuf-lite.la \
$(GOOGLETEST_BUILD_DIR)/lib/libgtest.la \
$(GOOGLEMOCK_BUILD_DIR)/lib/libgmock.la \
$(GOOGLEMOCK_BUILD_DIR)/lib/libgmock_main.la
protobuf_lite_test_CPPFLAGS= -I$(GOOGLEMOCK_SRC_DIR)/include \
-I$(GOOGLETEST_SRC_DIR)/include
protobuf_lite_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
protobuf_lite_test_SOURCES = \
google/protobuf/lite_unittest.cc \
@@ -849,11 +853,11 @@ $(am_protobuf_lite_test_OBJECTS): unittest_proto_middleman
# gtest when building the test internally our memory sanitizer doesn't detect
# memory leaks (don't know why).
protobuf_lite_arena_test_LDADD = $(PTHREAD_LIBS) libprotobuf-lite.la \
../gmock/gtest/lib/libgtest.la \
../gmock/lib/libgmock.la \
../gmock/lib/libgmock_main.la
protobuf_lite_arena_test_CPPFLAGS = -I$(srcdir)/../gmock/include \
-I$(srcdir)/../gmock/gtest/include
$(GOOGLETEST_BUILD_DIR)/lib/libgtest.la \
$(GOOGLEMOCK_BUILD_DIR)/lib/libgmock.la \
$(GOOGLEMOCK_BUILD_DIR)/lib/libgmock_main.la
protobuf_lite_arena_test_CPPFLAGS = -I$(GOOGLEMOCK_SRC_DIR)/include \
-I$(GOOGLETEST_SRC_DIR)/include
protobuf_lite_arena_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
protobuf_lite_arena_test_SOURCES = \
google/protobuf/lite_arena_unittest.cc \
@@ -863,8 +867,8 @@ $(am_protobuf_lite_arena_test_OBJECTS): unittest_proto_middleman
# Test plugin binary.
test_plugin_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \
../gmock/gtest/lib/libgtest.la
test_plugin_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include
$(GOOGLETEST_BUILD_DIR)/lib/libgtest.la
test_plugin_CPPFLAGS = -I$(GOOGLETEST_SRC_DIR)/include
test_plugin_SOURCES = \
google/protobuf/compiler/mock_code_generator.cc \
google/protobuf/testing/file.cc \
View
@@ -15,7 +15,6 @@ To build protobuf from source, the following tools are needed:
* autoconf
* automake
* libtool
* curl (used to download gmock)
* make
* g++
* unzip
@@ -30,6 +29,7 @@ install them before proceeding.
If you get the source from github, you need to generate the configure script
first:
$ git submodule update --init --recursive
$ ./autogen.sh
This will download gmock source (which is used for C++ Protocol Buffer
View
@@ -27,6 +27,9 @@ internal_build_cpp() {
export CXX="g++-4.8" CC="gcc-4.8"
fi
# Initialize any submodules.
git submodule update --init --recursive
./autogen.sh
./configure CXXFLAGS="-fPIC" # -fPIC is needed for python cpp test.
# See python/setup.py for more details
@@ -53,6 +56,8 @@ build_cpp() {
}
build_cpp_distcheck() {
# Initialize any submodules.
git submodule update --init --recursive
./autogen.sh
./configure
make dist
Submodule googletest added at c3bb0e

0 comments on commit 3c5442a

Please sign in to comment.