diff options
author | Danny Milosavljevic <dannym@friendly-machines.com> | 2024-12-21 20:01:20 +0100 |
---|---|---|
committer | Danny Milosavljevic <dannym@friendly-machines.com> | 2024-12-21 20:22:52 +0100 |
commit | 63041aacbb3e557dc35a2a4181ddd510acace5ec (patch) | |
tree | 93f7bd10391e68ba40d478aa88adbee8b20985cd | |
parent | 91af94dc9d628a7b62bce62f8a0da6d3234a91dd (diff) | |
download | guix-63041aacbb3e557dc35a2a4181ddd510acace5ec.tar.gz guix-63041aacbb3e557dc35a2a4181ddd510acace5ec.zip |
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
-rw-r--r-- | gnu/local.mk | 1 | ||||
-rw-r--r-- | gnu/packages/c2rust.scm | 48 | ||||
-rw-r--r-- | gnu/packages/patches/c2rust-ast-exporter-local-search.patch | 24 |
3 files changed, 73 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index dce1586e66..9950c9f3b6 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -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 \ diff --git a/gnu/packages/c2rust.scm b/gnu/packages/c2rust.scm index 8e913414bb..a4ba8217de 100644 --- a/gnu/packages/c2rust.scm +++ b/gnu/packages/c2rust.scm @@ -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))) diff --git a/gnu/packages/patches/c2rust-ast-exporter-local-search.patch b/gnu/packages/patches/c2rust-ast-exporter-local-search.patch new file mode 100644 index 0000000000..959321a9f7 --- /dev/null +++ b/gnu/packages/patches/c2rust-ast-exporter-local-search.patch @@ -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 |