diff mbox

[v2,1/1] gtest: update recipe to use autotools

Message ID 1429734568-20489-1-git-send-email-casantos@datacom.ind.br
State Rejected
Headers show

Commit Message

Carlos Santos April 22, 2015, 8:29 p.m. UTC
The previous recipe build gtest using cmake, which prevented compiling
gmock (to be submitted in a following patch).

Gmock requires the gtest-config script, which is installed only if gtest
is built with autotools.

Change-Id: I71e52d2ccc19160ca936d80b41c127e79f1a7d6a
Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
---
 package/gtest/gtest.mk | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

Comments

Thomas Petazzoni April 22, 2015, 8:46 p.m. UTC | #1
Dear Carlos Santos,

On Wed, 22 Apr 2015 17:29:28 -0300, Carlos Santos wrote:

> -$(eval $(cmake-package))
> +$(eval $(autotools-package))

I still don't understand. Fabio quoted the README of gtest, which says:

"""
The Autotools build script (configure + make) is no longer officially
supportted.  You are encouraged to migrate to your own build system or
use CMake.
"""

So why moving from using the supported CMake to the no-longer supported
autotools build system would be an improvement?

This really needs more explanations.

Thomas
Carlos Santos April 23, 2015, 11:23 a.m. UTC | #2
> From: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
> To: "Carlos Santos" <casantos@datacom.ind.br>
> Cc: buildroot@buildroot.org
> Sent: Wednesday, April 22, 2015 5:46:20 PM
> Subject: Re: [Buildroot] [PATCH v2 1/1] gtest: update recipe to use autotools

> Dear Carlos Santos,
> 
> On Wed, 22 Apr 2015 17:29:28 -0300, Carlos Santos wrote:
> 
>> -$(eval $(cmake-package))
>> +$(eval $(autotools-package))
> 
> I still don't understand. Fabio quoted the README of gtest, which says:
> 
> """
> The Autotools build script (configure + make) is no longer officially
> supportted.  You are encouraged to migrate to your own build system or
> use CMake.
> """
> 
> So why moving from using the supported CMake to the no-longer supported
> autotools build system would be an improvement?
> 
> This really needs more explanations.

I agree that using autotools is not the ideal approach but so I don't have a solution to generate the gtest-config script using CMake. I will spend some additional time on this today and submit and alternate patch if possible.

> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com

Carlos Santos (Casantos)
DATACOM, P&D
Arnout Vandecappelle April 23, 2015, 8:14 p.m. UTC | #3
On 04/23/15 13:23, Carlos Santos wrote:
>> From: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
>> To: "Carlos Santos" <casantos@datacom.ind.br>
>> Cc: buildroot@buildroot.org
>> Sent: Wednesday, April 22, 2015 5:46:20 PM
>> Subject: Re: [Buildroot] [PATCH v2 1/1] gtest: update recipe to use autotools
> 
>> Dear Carlos Santos,
>>
>> On Wed, 22 Apr 2015 17:29:28 -0300, Carlos Santos wrote:
>>
>>> -$(eval $(cmake-package))
>>> +$(eval $(autotools-package))
>>
>> I still don't understand. Fabio quoted the README of gtest, which says:
>>
>> """
>> The Autotools build script (configure + make) is no longer officially
>> supportted.  You are encouraged to migrate to your own build system or
>> use CMake.
>> """
>>
>> So why moving from using the supported CMake to the no-longer supported
>> autotools build system would be an improvement?
>>
>> This really needs more explanations.
> 
> I agree that using autotools is not the ideal approach but so I don't have a solution to generate the gtest-config script using CMake. I will spend some additional time on this today and submit and alternate patch if possible.

 I think it's fairly simple:

# gtest-config is only generated when gtest is built with autotools,
# so generate it manually here.
define GTEST_INSTALL_CONFIG
	sed 's/@PACKAGE_TARNAME@/gtest/;\
		s/@PACKAGE_VERSION@/$(GTEST_VERSION)/;\
		s/..../' \
		$(@D)/scripts/gtest-config.in \
		> $(STAGING_DIR)/usr/bin/gtest-config
endef
GTEST_POST_STAGING_INSTALL_HOOKS += GTEST_INSTALL_CONFIG

 Not tested, of course :-)

 In particular, I'm not sure if gtest-config gives the correct feedback when
gtest has been installed with cmake.


 Regards,
 Arnout
Thomas Petazzoni April 25, 2015, 9:25 a.m. UTC | #4
Arnout, Carlos,

On Thu, 23 Apr 2015 22:14:55 +0200, Arnout Vandecappelle wrote:

> # gtest-config is only generated when gtest is built with autotools,
> # so generate it manually here.
> define GTEST_INSTALL_CONFIG
> 	sed 's/@PACKAGE_TARNAME@/gtest/;\
> 		s/@PACKAGE_VERSION@/$(GTEST_VERSION)/;\
> 		s/..../' \
> 		$(@D)/scripts/gtest-config.in \
> 		> $(STAGING_DIR)/usr/bin/gtest-config
> endef
> GTEST_POST_STAGING_INSTALL_HOOKS += GTEST_INSTALL_CONFIG

I've implemented this solution, see commit:

  http://git.buildroot.net/buildroot/commit/?id=39186b5f5ac61c72d4b3d3088b7facbfd739abfa

I test that the generated gtest-config returns sane values, but I
didn't test with a real program using gtest obviously.

Carlos, can you let us know if that works for your use case?

Thanks a lot,

Thomas Petazzoni
diff mbox

Patch

diff --git a/package/gtest/gtest.mk b/package/gtest/gtest.mk
index 7129c93..1176030 100644
--- a/package/gtest/gtest.mk
+++ b/package/gtest/gtest.mk
@@ -11,25 +11,20 @@  GTEST_INSTALL_STAGING = YES
 GTEST_INSTALL_TARGET = NO
 GTEST_LICENSE = BSD-3c
 GTEST_LICENSE_FILES = LICENSE
-
-# While it is possible to build gtest as shared library, using this gtest shared
-# library requires to set some special configure option in the project using
-# gtest.
-# So, force to build gtest as a static library.
-#
-# For further details, refer to the explaination given in the README file from
-# the gtest sources.
-GTEST_CONF_OPTS = -DBUILD_SHARED_LIBS=OFF
+GTEST_CONF_OPTS = --enable-static --disable-shared
 
 define GTEST_EXTRACT_CMDS
 	$(UNZIP) $(DL_DIR)/$(GTEST_SOURCE) -d $(BUILD_DIR)
 endef
 
 define GTEST_INSTALL_STAGING_CMDS
-	$(INSTALL) -D -m 0755 $(@D)/libgtest.a $(STAGING_DIR)/usr/lib/libgtest.a
-	$(INSTALL) -D -m 0755 $(@D)/libgtest_main.a $(STAGING_DIR)/usr/lib/libgtest_main.a
+	$(INSTALL) -D -m 0644 $(@D)/lib/.libs/libgtest.a $(STAGING_DIR)/usr/lib/libgtest.a
+	$(INSTALL) -D -m 0644 $(@D)/lib/.libs/libgtest_main.a $(STAGING_DIR)/usr/lib/libgtest_main.a
+	$(INSTALL) -D -m 0644 $(@D)/scripts/gtest-config $(STAGING_DIR)/usr/lib/scripts/gtest-config
 	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include/gtest/
-	cp -rp $(@D)/include/gtest/* $(STAGING_DIR)/usr/include/gtest/
+	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include/gtest/internal/
+	$(INSTALL) -D -m 0644 $(@D)/include/gtest/*.h* $(STAGING_DIR)/usr/include/gtest/
+	$(INSTALL) -D -m 0644 $(@D)/include/gtest/internal/*.h* $(STAGING_DIR)/usr/include/gtest/internal/
 endef
 
-$(eval $(cmake-package))
+$(eval $(autotools-package))