diff mbox series

[bug#50217,v3] gnu: Add c2ffi.

Message ID 20220112171329.22695-1-attila@lendvai.name
State Accepted
Headers show
Series [bug#50217,v3] gnu: Add c2ffi. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Attila Lendvai Jan. 12, 2022, 5:13 p.m. UTC
Orignial work by muradm <mail@muradm.net>, fixes by Attila Lendvai.

* gnu/packages/cpp.scm (c2ffi): New variable.
---

v3 converts the input lists to the new format.

 gnu/packages/cpp.scm | 47 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
diff mbox series

Patch

diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
index 718fb20652..d7e2ff49e5 100644
--- a/gnu/packages/cpp.scm
+++ b/gnu/packages/cpp.scm
@@ -22,6 +22,8 @@ 
 ;;; Copyright © 2021 Nicolò Balzarotti <nicolo@nixo.xyz>
 ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
 ;;; Copyright © 2021 Nikolay Korotkiy <sikmir@disroot.org>
+;;; Copyright © 2021 muradm <mail@muradm.net>
+;;; Copyright © 2021 Attila Lendvai <attila@lendvai.name>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1452,3 +1454,48 @@  (define-public simdjson
 validation.")
     (home-page "https://github.com/simdjson/simdjson")
     (license license:asl2.0)))
+
+(define-public c2ffi
+  (let ((commit "f50243926a0afb589de1078a073ac08910599582")
+        (revision "1"))
+    (package
+      (name "c2ffi")
+      (home-page "https://github.com/rpav/c2ffi")
+      ;; Upstream has no releases, only one branch per LLVM release. Let's put
+      ;; the LLVM version into the version string, use a revision as a
+      ;; human-readable differentiation of the versions that gets imported
+      ;; into Guix, and also use the commit hash to be specific.
+      (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 "17j73yb6v3lfvwwicl2f3yg141iz2dk1rf874qzqs5bkq64ldjsj"))
+                (modules '((guix build utils)))
+                (snippet
+                 '(substitute* "CMakeLists.txt"
+                    ;; 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")
+         ;; Upstream has no tests.
+         #:tests? #f))
+      (native-inputs
+       (list clang-11 llvm-11))
+      (inputs
+       (list clang-11 llvm-11))
+      (synopsis "Clang-based FFI wrapper generator")
+      (description "@code{c2ffi} is a tool for extracting definitions from C, C++, and
+Objective C headers for use with foreign function call interfaces.  It uses the
+@code{Clang/LLVM} infrastructure to extract the data, and emits it in various formats,
+including @code{json}.")
+      (license license:gpl2+))))