mirror of
https://codeberg.org/guix/guix.git
synced 2026-01-28 03:45:07 -06:00
gnu: Add c2rust.
* gnu/packages/c2rust.scm (c2rust): New variable. * gnu/packages/patches/c2rust-ast-exporter-local-search.patch: New file. * gnu/local.mk (dist_patch_DATA): Add reference to it. Change-Id: I9a80c6071a48ab5baed0a83e1c2463f83a6c6b9b
This commit is contained in:
parent
91af94dc9d
commit
63041aacbb
3 changed files with 73 additions and 0 deletions
|
|
@ -1046,6 +1046,7 @@ dist_patch_DATA = \
|
|||
%D%/packages/patches/byobu-writable-status.patch \
|
||||
%D%/packages/patches/bubblewrap-fix-locale-in-tests.patch \
|
||||
%D%/packages/patches/busybox-add-missing-sha-NI-guard.patch \
|
||||
%D%/packages/patches/c2rust-ast-exporter-local-search.patch \
|
||||
%D%/packages/patches/cadical-add-shared-library.patch \
|
||||
%D%/packages/patches/calibre-no-updates-dialog.patch \
|
||||
%D%/packages/patches/calibre-remove-test-sqlite.patch \
|
||||
|
|
|
|||
|
|
@ -249,3 +249,51 @@
|
|||
(synopsis "C2Rust transpiler implementation")
|
||||
(description "This package provides C2Rust transpiler implementation.")
|
||||
(license license:bsd-3)))
|
||||
|
||||
(define-public c2rust
|
||||
(package
|
||||
(name "c2rust")
|
||||
(version "0.18.0")
|
||||
(source
|
||||
(origin
|
||||
(method url-fetch)
|
||||
(uri (crate-uri "c2rust" version))
|
||||
(file-name (string-append name "-" version ".tar.gz"))
|
||||
(sha256
|
||||
(base32 "1rg9cvvmh9zw89mz2bpyvqlwbfhzl5dw2hab9z6d5rasr8mir7nh"))))
|
||||
(build-system cargo-build-system)
|
||||
(native-inputs
|
||||
`(("tinycbor-src" ,%tinycbor-source)
|
||||
("cmake" ,cmake)
|
||||
("clang" ,clang)))
|
||||
(inputs (list llvm))
|
||||
(arguments
|
||||
`(#:cargo-inputs (("rust-anyhow" ,rust-anyhow-1)
|
||||
("rust-c2rust-build-paths" ,rust-c2rust-build-paths-0.18)
|
||||
("rust-c2rust-transpile" ,rust-c2rust-transpile-0.18)
|
||||
("rust-clap" ,rust-clap-3)
|
||||
("rust-env-logger" ,rust-env-logger-0.10)
|
||||
("rust-git-testament" ,rust-git-testament-0.2)
|
||||
("rust-is-executable" ,rust-is-executable-1)
|
||||
("rust-log" ,rust-log-0.4)
|
||||
("rust-regex" ,rust-regex-1)
|
||||
("rust-shlex" ,rust-shlex-1)
|
||||
("rust-time-macros" ,rust-time-macros-0.2))
|
||||
#:phases
|
||||
(modify-phases %standard-phases
|
||||
(add-after 'unpack 'patch-deps
|
||||
(lambda _
|
||||
;; This is incorrect in the release to begin with.
|
||||
(substitute* "Cargo.toml"
|
||||
(("=0.2.6") "=0.2.18"))))
|
||||
(add-before 'build 'patch
|
||||
(lambda* (#:key inputs #:allow-other-keys)
|
||||
;; The build process will slightly patch the sources.
|
||||
(copy-recursively (assoc-ref inputs "tinycbor-src")
|
||||
"/tmp/tinycbor")
|
||||
(setenv "CMAKE_TINYCBOR_SOURCE_DIR" "/tmp/tinycbor"))))))
|
||||
(home-page "https://c2rust.com/")
|
||||
(synopsis "C to Rust translation, refactoring, and cross-checking")
|
||||
(description
|
||||
"This package provides C to Rust translation, refactoring, and cross-checking.")
|
||||
(license license:bsd-3)))
|
||||
|
|
|
|||
24
gnu/packages/patches/c2rust-ast-exporter-local-search.patch
Normal file
24
gnu/packages/patches/c2rust-ast-exporter-local-search.patch
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
diff -ru orig/c2rust-ast-exporter-0.18.0/src/CMakeLists.txt c2rust-ast-exporter-0.18.0/src/CMakeLists.txt
|
||||
--- orig/c2rust-ast-exporter-0.18.0/src/CMakeLists.txt 2006-07-24 03:21:28.000000000 +0200
|
||||
+++ c2rust-ast-exporter-0.18.0/src/CMakeLists.txt 2024-12-21 12:06:27.056455735 +0100
|
||||
@@ -24,8 +24,7 @@
|
||||
ExternalProject_Add(tinycbor_build
|
||||
PREFIX ${TINYCBOR_PREFIX}
|
||||
INSTALL_DIR ${CMAKE_BINARY_DIR}
|
||||
- GIT_REPOSITORY ${TINYCBOR_REPO}
|
||||
- GIT_TAG ${TINYCBOR_TAG}
|
||||
+ SOURCE_DIR ${TINYCBOR_SOURCE_DIR}
|
||||
# the fd redirection here fails when the build run inside Cargo.
|
||||
# patch from upstream:
|
||||
# https://github.com/intel/tinycbor/commit/6176e0a28d7c5ef3a5e9cbd02521999c412de72c
|
||||
diff -ru orig/c2rust-ast-exporter-0.18.0/build.rs c2rust-ast-exporter-0.18.0/build.rs
|
||||
--- orig/c2rust-ast-exporter-0.18.0/build.rs 2024-12-21 19:37:50.004786236 +0100
|
||||
+++ c2rust-ast-exporter-0.18.0/build.rs 2024-12-21 19:39:20.188478196 +0100
|
||||
@@ -127,6 +127,7 @@
|
||||
// Build libclangAstExporter.a with cmake
|
||||
let dst = Config::new("src")
|
||||
// Where to find LLVM/Clang CMake files
|
||||
+ .define("TINYCBOR_SOURCE_DIR", &env!("CMAKE_TINYCBOR_SOURCE_DIR"))
|
||||
.define("LLVM_DIR", &format!("{}/cmake/llvm", llvm_lib_dir))
|
||||
.define("Clang_DIR", &format!("{}/cmake/clang", llvm_lib_dir))
|
||||
// What to build
|
||||
Loading…
Add table
Reference in a new issue