Subject: [PATCH v2] gnu: Add c2ffi-11.0.0.

From: muradm <[email-masked]>
Date: Fri, 27 Aug 2021 03:12:07 +0300

* gnu/packages/cpp.scm (c2ffi): New variable.
---
 gnu/packages/cpp.scm | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
index ba921fac11..239e87bf84 100644
--- a/gnu/packages/cpp.scm
+++ b/gnu/packages/cpp.scm
@@ -18,6 +18,7 @@
 ;;; Copyright © 2020 Brett Gilio <[email-masked]>
 ;;; Copyright © 2020 Milkey Mouse <[email-masked]>
 ;;; Copyright © 2021 Raghav Gururajan <[email-masked]>
+;;; Copyright © 2021 muradm <[email-masked]>
 
 ;;;
 ;;; This file is part of GNU Guix.
@@ -1250,3 +1251,42 @@ of reading and writing XML.")
     (description "Jsonnet is a templating language extending JSON
 syntax with variables, conditions, functions and more.")
     (license license:asl2.0)))
+
+(define-public c2ffi
+  (let ((commit "f50243926a0afb589de1078a073ac08910599582")
+        (revision "1")
+        (c2ffi-sha256 "17j73yb6v3lfvwwicl2f3yg141iz2dk1rf874qzqs5bkq64ldjsj"))
+    (package
+      (name "c2ffi")
+      (home-page "https://github.com/rpav/c2ffi")
+      (version (git-version "11.0.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference (url home-page) (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256 (base32 c2ffi-sha256))
+                (modules '((guix build utils)))
+                (snippet
+                 '(substitute* "CMakeLists.txt"
+                    ;; cmake-build-system default cmake version
+                    (("VERSION 3.17") "VERSION 3.16.5")
+                    ;; guix seems to be packaging LLVM libs separately
+                    ;; thus -lLLVM is not working, every used library should
+                    ;; be specified explicitly
+                    (("c2ffi PUBLIC clang-cpp LLVM")
+                     "c2ffi PUBLIC clang-cpp LLVMCore LLVMSupport LLVMMCParser LLVMOption LLVMBitReader LLVMProfileData")))))
+      (build-system cmake-build-system)
+      (arguments
+       '(;; llvm-11 at least seems to be built without RTTI
+         ;; llvm-12 on the other hand specifies -DLLVM_REQUIRES_RTTI=1
+         ;; may fail with this flag when c2ffi for llvm-12 released
+         ;; https://stackoverflow.com/q/11904519
+         #:configure-flags '("-DCMAKE_CXX_FLAGS=-fno-rtti")
+         #:tests? #f))
+      (inputs
+       `(("clang" ,clang-11)
+         ("llvm" ,llvm-11)))
+      (synopsis "Clang-based FFI wrapper generator")
+      (description "tool for extracting definitions from C, C++, and
+Objective C headers for use with foreign function call interfaces.")
+      (license license:gpl2))))
-- 
2.33.0