gtest/gmock: build checked out copy
Now that gtest/gmock are part of the manifest, build them directly
and store the results in out/.
BUG=b/27707648
TEST+`make` still works, as does the unittests
Change-Id: I8a8235b4bc0100731168a44c6553859a5d85bbe1
Reviewed-on: https://weave-review.googlesource.com/2952
Reviewed-by: Alex Vakulenko <avakulenko@google.com>
diff --git a/third_party/third_party.mk b/third_party/third_party.mk
index 7f651a2..e53529b 100644
--- a/third_party/third_party.mk
+++ b/third_party/third_party.mk
@@ -13,7 +13,7 @@
third_party_chromium_base_unittest_obj_files := $(THIRD_PARTY_CHROMIUM_BASE_UNITTEST_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o)
-$(third_party_chromium_base_unittest_obj_files) : out/$(BUILD_MODE)/%.o : %.cc third_party/include/gtest/gtest.h
+$(third_party_chromium_base_unittest_obj_files) : out/$(BUILD_MODE)/%.o : %.cc
mkdir -p $(dir $@)
$(CXX) $(DEFS_TEST) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $<
@@ -25,7 +25,7 @@
third_party_chromium_crypto_unittest_obj_files := $(THIRD_PARTY_CHROMIUM_CRYPTO_UNITTEST_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o)
-$(third_party_chromium_crypto_unittest_obj_files) : out/$(BUILD_MODE)/%.o : %.cc third_party/include/gtest/gtest.h
+$(third_party_chromium_crypto_unittest_obj_files) : out/$(BUILD_MODE)/%.o : %.cc
mkdir -p $(dir $@)
$(CXX) $(DEFS_TEST) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $<
@@ -48,20 +48,35 @@
$(CC) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_C) -c -o $@ $<
###
-# libgtest and libgmock (third_party, downloaded on build)
+# libgtest and libgmock (third_party)
-third_party/lib/gtest.a: third_party/include/gtest/gtest.h
-third_party/lib/gmock.a: third_party/include/gtest/gtest.h
+third_party_gtest_lib = out/$(BUILD_MODE)/third_party/googletest/libgtest.a
+third_party_gmock_lib = out/$(BUILD_MODE)/third_party/googletest/libgmock.a
-third_party/include/gtest/gtest.h:
- @echo Downloading and building libgtest and libgmock...
- third_party/get_gtest.sh
- @echo Finished downloading and building libgtest and libgmock.
+third_party_gtest_all = out/$(BUILD_MODE)/third_party/googletest/gtest-all.o
+third_party_gmock_all = out/$(BUILD_MODE)/third_party/googletest/gmock-all.o
+
+$(third_party_gtest_all) : third_party/googletest/googletest/src/gtest-all.cc
+ mkdir -p $(dir $@)
+ $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $< \
+ -I third_party/googletest/googletest/
+
+$(third_party_gmock_all) : third_party/googletest/googlemock/src/gmock-all.cc
+ mkdir -p $(dir $@)
+ $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $< \
+ -I third_party/googletest/googlemock/
+
+$(third_party_gtest_lib) : $(third_party_gtest_all)
+ mkdir -p $(dir $@)
+ $(AR) crs $@ $^
+
+$(third_party_gmock_lib) : $(third_party_gmock_all)
+ mkdir -p $(dir $@)
+ $(AR) crs $@ $^
clean-gtest :
- rm -rf third_party/include/gtest third_party/include/gmock
- rm -rf third_party/lib/libgmock* third_party/lib/libgtest*
- rm -rf third_party/googletest
+ rm -rf $(third_party_gtest_lib) $(third_party_gmock_lib) \
+ $(third_party_gtest_all) $(third_party_gmock_all)
###
# libevhtp (third_party, downloaded on build)