Skip to contentSkip to conversation

cmocka: new package

PATCH New Joel Carlson 3 participants 4 messages Jun 20, 2018 – Jun 26, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 cmocka: new package

---
v2 was by Nimai Mahajan, here: http://patchwork.ozlabs.org/patch/500181/

Changes v2 -> v3
- changed from v1.0.1 to v1.1.1
- added dependency on !BR2_STATIC_LIBS (suggested by Romain)
- added patch to fix build issue for toolchains without stack protection (issue found by Romain)
- added generation of static library for BR2_SHARED_STATIC_LIBS

---
 DEVELOPERS                                         |  1 +
 package/Config.in                                  |  1 +
 ...0001-cmocka-cmake-fix-stack-protect-check.patch | 34 ++++++++++++++++++++++
 package/cmocka/Config.in                           | 15 ++++++++++
 package/cmocka/cmocka.hash                         |  2 ++
 package/cmocka/cmocka.mk                           | 23 +++++++++++++++
 6 files changed, 76 insertions(+)
 create mode 100644 package/cmocka/0001-cmocka-cmake-fix-stack-protect-check.patch
 create mode 100644 package/cmocka/Config.in
 create mode 100644 package/cmocka/cmocka.hash
 create mode 100644 package/cmocka/cmocka.mk
DEVELOPERS +1 -0
index d22ac52..229a584 100644
@@ -966,6 +966,7 @@ N:	Jeremy Rosen <[email protected]>
 F:	package/fxload/
 
 N:	Joel Carlson <[email protected]>
+F:	package/cmocka/
 F:	package/flatcc/
 
 N:	Joel Stanley <[email protected]>
package/Config.in +1 -0
index a5ecfec..f60af1e 100644
@@ -1501,6 +1501,7 @@ menu "Other"
 	source "package/clang/Config.in"
 	source "package/clapack/Config.in"
 	source "package/classpath/Config.in"
+	source "package/cmocka/Config.in"
 	source "package/cppcms/Config.in"
 	source "package/cracklib/Config.in"
 	source "package/dawgdic/Config.in"
package/cmocka/0001-cmocka-cmake-fix-stack-protect-check.patch new file +34 -0
new file mode 100644
index 0000000..c7a2c27
@@ -0,0 +1,34 @@
+From f9a964edde4011adf88902018cbb87723d78d0a2 Mon Sep 17 00:00:00 2001
+From: Joel Carlson <[email protected]>
+Date: Wed, 20 Jun 2018 14:35:13 -0600
+Subject: [PATCH 1/1] cmocka cmake: fix stack protect check
+
+The cmake check for if -fstack-protect is supported needs to use
+CMAKE_REQUIRED_FLAGS and not CMAKE_REQUIRED_DEFINITIONS.
+
+Signed-off-by: Joel Carlson <[email protected]>
+---
+Upstream status: submitted to cmocka mailing list
+
+ cmake/Modules/CheckCCompilerFlagSSP.cmake | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/cmake/Modules/CheckCCompilerFlagSSP.cmake b/cmake/Modules/CheckCCompilerFlagSSP.cmake
+index 2fe4395..ed34eb3 100644
+--- a/cmake/Modules/CheckCCompilerFlagSSP.cmake
++++ b/cmake/Modules/CheckCCompilerFlagSSP.cmake
+@@ -19,8 +19,8 @@
+ include(CheckCSourceCompiles)
+ 
+ function(CHECK_C_COMPILER_FLAG_SSP _FLAG _RESULT)
+-   set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
+-   set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
++   set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
++   set(CMAKE_REQUIRED_FLAGS "${_FLAG}")
+    check_c_source_compiles("int main(int argc, char **argv) { char buffer[256]; return buffer[argc]=0;}" ${_RESULT})
+-   set(CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
++   set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
+ endfunction(CHECK_C_COMPILER_FLAG_SSP)
+-- 
+2.7.4
+
package/cmocka/Config.in new file +15 -0
new file mode 100644
index 0000000..cf49d0f
@@ -0,0 +1,15 @@
+config BR2_PACKAGE_CMOCKA
+	bool cmocka
+	depends on !BR2_STATIC_LIBS
+	help
+	  cmocka is an elegant unit testing framework for C with support
+	  for mock objects. It only requires the standard C library,
+	  works on a range of computing platforms (including embedded)
+	  and with different compilers. It is a fork of Google's very
+	  popular cmockery unit testing framework to fix bugs and
+	  support it in the future.
+
+	  https://cmocka.org
+
+comment "cmocka needs a toolchain w/ dynamic library"
+	depends on BR2_STATIC_LIBS
package/cmocka/cmocka.hash new file +2 -0
new file mode 100644
index 0000000..1de4a12
@@ -0,0 +1,2 @@
+# Locally computed:
+sha256 f02ef48a7039aa77191d525c5b1aee3f13286b77a13615d11bc1148753fc0389 cmocka-1.1.1.tar.xz
package/cmocka/cmocka.mk new file +23 -0
new file mode 100644
index 0000000..64f5a4a
@@ -0,0 +1,23 @@
+################################################################################
+#
+# cmocka
+#
+################################################################################
+
+CMOCKA_VERSION = 1.1.1
+CMOCKA_SOURCE = cmocka-$(CMOCKA_VERSION).tar.xz
+CMOCKA_SITE = https://cmocka.org/files/1.1
+CMOCKA_LICENSE = Apache-2.0
+CMOCKA_LICENSE_FILES = COPYING
+CMOCKA_INSTALL_STAGING = YES
+
+# cmocka only supports out of source builds
+CMOCKA_SUPPORTS_IN_SOURCE_BUILD = NO
+
+# cmocka always builds a shared library, but you can optionally build a static
+# library as well
+ifeq ($(BR2_SHARED_STATIC_LIBS),y)
+CMOCKA_CONF_OPTS += -DWITH_STATIC_LIB=ON
+endif
+
+$(eval $(cmake-package))
Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/1 cmocka: new package

Quoted 5 lines · Joel Carlson

---
v2 was by Nimai Mahajan, here: http://patchwork.ozlabs.org/patch/500181/

Quoted 8 lines

Changes v2 -> v3
- changed from v1.0.1 to v1.1.1
- added dependency on !BR2_STATIC_LIBS (suggested by Romain)
- added patch to fix build issue for toolchains without stack protection (issue found by Romain)
- added generation of static library for BR2_SHARED_STATIC_LIBS
---

Thank you for fixing this up Joel. It kind of fell off my radar.

 DEVELOPERS                                         |  1 +
Quoted 144 lines
 package/Config.in                                  |  1 +
 ...0001-cmocka-cmake-fix-stack-protect-check.patch | 34
++++++++++++++++++++++
 package/cmocka/Config.in                           | 15 ++++++++++
 package/cmocka/cmocka.hash                         |  2 ++
 package/cmocka/cmocka.mk                           | 23 +++++++++++++++
 6 files changed, 76 insertions(+)
 create mode 100644
package/cmocka/0001-cmocka-cmake-fix-stack-protect-check.patch
 create mode 100644 package/cmocka/Config.in
 create mode 100644 package/cmocka/cmocka.hash
 create mode 100644 package/cmocka/cmocka.mk
DEVELOPERS +1 -0
index d22ac52..229a584 100644
@@ -966,6 +966,7 @@ N:  Jeremy Rosen <[email protected]>
 F:     package/fxload/
 
 N:     Joel Carlson <[email protected]>
+F:     package/cmocka/
 F:     package/flatcc/
 
 N:     Joel Stanley <[email protected]>
package/Config.in +1 -0
index a5ecfec..f60af1e 100644
@@ -1501,6 +1501,7 @@ menu "Other"
        source "package/clang/Config.in"
        source "package/clapack/Config.in"
        source "package/classpath/Config.in"
+       source "package/cmocka/Config.in"
        source "package/cppcms/Config.in"
        source "package/cracklib/Config.in"
        source "package/dawgdic/Config.in"

diff --git a/package/cmocka/0001-cmocka-cmake-fix-stack-protect-check.patch b/package/cmocka/0001-cmocka-cmake-fix-stack-protect-check.patch new file mode 100644
index 0000000..c7a2c27

package/cmocka/0001-cmocka-cmake-fix-stack-protect-check.patch new file +16 -0
@@ -0,0 +1,34 @@
+From f9a964edde4011adf88902018cbb87723d78d0a2 Mon Sep 17 00:00:00 2001
+From: Joel Carlson <[email protected]>
+Date: Wed, 20 Jun 2018 14:35:13 -0600
+Subject: [PATCH 1/1] cmocka cmake: fix stack protect check
+
+The cmake check for if -fstack-protect is supported needs to use
+CMAKE_REQUIRED_FLAGS and not CMAKE_REQUIRED_DEFINITIONS.
+
+Signed-off-by: Joel Carlson <[email protected]>
+---
+Upstream status: submitted to cmocka mailing list
+
+ cmake/Modules/CheckCCompilerFlagSSP.cmake | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/cmake/Modules/CheckCCompilerFlagSSP.cmake

b/cmake/Modules/CheckCCompilerFlagSSP.cmake

package/cmocka/0001-cmocka-cmake-fix-stack-protect-check.patch new file +12 -0
+index 2fe4395..ed34eb3 100644
+--- a/cmake/Modules/CheckCCompilerFlagSSP.cmake
++++ b/cmake/Modules/CheckCCompilerFlagSSP.cmake
+@@ -19,8 +19,8 @@
+ include(CheckCSourceCompiles)
+
+ function(CHECK_C_COMPILER_FLAG_SSP _FLAG _RESULT)
+-   set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
+-   set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
++   set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
++   set(CMAKE_REQUIRED_FLAGS "${_FLAG}")
+    check_c_source_compiles("int main(int argc, char **argv) { char

buffer[256]; return buffer[argc]=0;}" ${_RESULT})

+-   set(CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
++   set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")

+ endfunction(CHECK_C_COMPILER_FLAG_SSP)
+--
+2.7.4

package/cmocka/0001-cmocka-cmake-fix-stack-protect-check.patch new file +1 -0
+
package/cmocka/Config.in new file +15 -0
new file mode 100644
index 0000000..cf49d0f
@@ -0,0 +1,15 @@
+config BR2_PACKAGE_CMOCKA
+       bool cmocka
+       depends on !BR2_STATIC_LIBS
+       help
+         cmocka is an elegant unit testing framework for C with support
+         for mock objects. It only requires the standard C library,
+         works on a range of computing platforms (including embedded)
+         and with different compilers. It is a fork of Google's very
+         popular cmockery unit testing framework to fix bugs and
+         support it in the future.
+
+         https://cmocka.org
+
+comment "cmocka needs a toolchain w/ dynamic library"
+       depends on BR2_STATIC_LIBS
package/cmocka/cmocka.hash new file +2 -0
new file mode 100644
index 0000000..1de4a12
@@ -0,0 +1,2 @@
+# Locally computed:
+sha256 f02ef48a7039aa77191d525c5b1aee3f13286b77a13615d11bc1148753fc0389

cmocka-1.1.1.tar.xz

package/cmocka/cmocka.mk new file +17 -0
new file mode 100644
index 0000000..64f5a4a
@@ -0,0 +1,23 @@
 
+################################################################################
+#
+# cmocka
+#
 
+################################################################################
+
+CMOCKA_VERSION = 1.1.1
+CMOCKA_SOURCE = cmocka-$(CMOCKA_VERSION).tar.xz
+CMOCKA_SITE = https://cmocka.org/files/1.1
+CMOCKA_LICENSE = Apache-2.0
+CMOCKA_LICENSE_FILES = COPYING
+CMOCKA_INSTALL_STAGING = YES
+
+# cmocka only supports out of source builds
+CMOCKA_SUPPORTS_IN_SOURCE_BUILD = NO
+
+# cmocka always builds a shared library, but you can optionally build a

static

package/cmocka/cmocka.mk new file +6 -1
+# library as well
+ifeq ($(BR2_SHARED_STATIC_LIBS),y)
+CMOCKA_CONF_OPTS += -DWITH_STATIC_LIB=ON
+endif
+
+$(eval $(cmake-package))
--
Quoted 3 lines

2.7.4

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180620/eb496d44/attachment.html>

#2 lore raw

PATCH v3 1/1 cmocka: new package

In reply to Joel Carlson
Quoted 55 lines · Joel Carlson

---
v2 was by Nimai Mahajan, here: http://patchwork.ozlabs.org/patch/500181/

Changes v2 -> v3
- changed from v1.0.1 to v1.1.1
- added dependency on !BR2_STATIC_LIBS (suggested by Romain)
- added patch to fix build issue for toolchains without stack protection (issue found by Romain)
- added generation of static library for BR2_SHARED_STATIC_LIBS

---
 DEVELOPERS                                         |  1 +
 package/Config.in                                  |  1 +
 ...0001-cmocka-cmake-fix-stack-protect-check.patch | 34 ++++++++++++++++++++++
 package/cmocka/Config.in                           | 15 ++++++++++
 package/cmocka/cmocka.hash                         |  2 ++
 package/cmocka/cmocka.mk                           | 23 +++++++++++++++
 6 files changed, 76 insertions(+)
 create mode 100644 package/cmocka/0001-cmocka-cmake-fix-stack-protect-check.patch
 create mode 100644 package/cmocka/Config.in
 create mode 100644 package/cmocka/cmocka.hash
 create mode 100644 package/cmocka/cmocka.mk
DEVELOPERS +1 -0
index d22ac52..229a584 100644
@@ -966,6 +966,7 @@ N:  Jeremy Rosen <[email protected]>
 F:     package/fxload/
 
 N:     Joel Carlson <[email protected]>
+F:     package/cmocka/
 F:     package/flatcc/
 
 N:     Joel Stanley <[email protected]>
package/Config.in +1 -0
index a5ecfec..f60af1e 100644
@@ -1501,6 +1501,7 @@ menu "Other"
        source "package/clang/Config.in"
        source "package/clapack/Config.in"
        source "package/classpath/Config.in"
+       source "package/cmocka/Config.in"
        source "package/cppcms/Config.in"
        source "package/cracklib/Config.in"
        source "package/dawgdic/Config.in"
package/cmocka/0001-cmocka-cmake-fix-stack-protect-check.patch new file +1 -0
new file mode 100644
index 0000000..c7a2c27
@@ -0,0 +1,34 @@
+From f9a964edde4011adf88902018cbb87723d78d0a2 Mon Sep 17 00:00:00 2001

package/cmocka/0001-cmocka-cmake-fix-stack-protect-check.patch line 11

Quoted 10 lines
package/cmocka/0001-cmocka-cmake-fix-stack-protect-check.patch new file +10 -0
+From: Joel Carlson <[email protected]>
+Date: Wed, 20 Jun 2018 14:35:13 -0600
+Subject: [PATCH 1/1] cmocka cmake: fix stack protect check
+
+The cmake check for if -fstack-protect is supported needs to use
+CMAKE_REQUIRED_FLAGS and not CMAKE_REQUIRED_DEFINITIONS.
+
+Signed-off-by: Joel Carlson <[email protected]>
+---
+Upstream status: submitted to cmocka mailing list

Note: this is now committed to the cmocka master branch as commit d677b564c2193a5cd381925c2eeaad6b23c6af2f

Quoted 23 lines
package/cmocka/0001-cmocka-cmake-fix-stack-protect-check.patch new file +23 -0
+
+ cmake/Modules/CheckCCompilerFlagSSP.cmake | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/cmake/Modules/CheckCCompilerFlagSSP.cmake b/cmake/Modules/CheckCCompilerFlagSSP.cmake
+index 2fe4395..ed34eb3 100644
+--- a/cmake/Modules/CheckCCompilerFlagSSP.cmake
++++ b/cmake/Modules/CheckCCompilerFlagSSP.cmake
+@@ -19,8 +19,8 @@
+ include(CheckCSourceCompiles)
+
+ function(CHECK_C_COMPILER_FLAG_SSP _FLAG _RESULT)
+-   set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
+-   set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
++   set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
++   set(CMAKE_REQUIRED_FLAGS "${_FLAG}")
+    check_c_source_compiles("int main(int argc, char **argv) { char buffer[256]; return buffer[argc]=0;}" ${_RESULT})
+-   set(CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
++   set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
+ endfunction(CHECK_C_COMPILER_FLAG_SSP)
+--
+2.7.4
+

[snip]