From d33dd6e6c09d87a59989057ad622a6265ddec2e0 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 11 Sep 2019 13:10:46 +0200 Subject: [PATCH] Move code around --- nix-rust/src/lib.rs | 1 - src/libstore/builtins/unpack-channel.cc | 4 ++-- src/libstore/local.mk | 2 +- src/libutil/local.mk | 2 ++ src/libutil/rust-ffi.cc | 2 +- src/{libstore/rust.hh => libutil/tarfile.cc} | 10 +++++++++- src/libutil/tarfile.hh | 7 +++++++ 7 files changed, 22 insertions(+), 6 deletions(-) rename src/{libstore/rust.hh => libutil/tarfile.cc} (53%) create mode 100644 src/libutil/tarfile.hh diff --git a/nix-rust/src/lib.rs b/nix-rust/src/lib.rs index 48952d8b9..1b88ac8af 100644 --- a/nix-rust/src/lib.rs +++ b/nix-rust/src/lib.rs @@ -14,7 +14,6 @@ impl CBox { unsafe { let size = std::mem::size_of::(); let ptr = libc::malloc(size); - eprintln!("PTR = {:?}, SIZE = {}", ptr, size); *(ptr as *mut T) = t; // FIXME: probably UB Self { ptr, diff --git a/src/libstore/builtins/unpack-channel.cc b/src/libstore/builtins/unpack-channel.cc index 2da26d98e..5fc68cd66 100644 --- a/src/libstore/builtins/unpack-channel.cc +++ b/src/libstore/builtins/unpack-channel.cc @@ -1,6 +1,6 @@ -#include "rust.hh" #include "builtins.hh" #include "compression.hh" +#include "tarfile.hh" namespace nix { @@ -27,7 +27,7 @@ void builtinUnpackChannel(const BasicDerivation & drv) decompressor->finish(); }); - unpack_tarfile(*source, out).use()->unwrap(); + unpackTarfile(*source, out); auto entries = readDirectory(out); if (entries.size() != 1) diff --git a/src/libstore/local.mk b/src/libstore/local.mk index d3254554d..d690fea28 100644 --- a/src/libstore/local.mk +++ b/src/libstore/local.mk @@ -6,7 +6,7 @@ libstore_DIR := $(d) libstore_SOURCES := $(wildcard $(d)/*.cc $(d)/builtins/*.cc) -libstore_LIBS = libutil libnixrust +libstore_LIBS = libutil libstore_LDFLAGS = $(SQLITE3_LIBS) -lbz2 $(LIBCURL_LIBS) $(SODIUM_LIBS) -pthread ifneq ($(OS), FreeBSD) diff --git a/src/libutil/local.mk b/src/libutil/local.mk index e41a67d1f..35c1f6c13 100644 --- a/src/libutil/local.mk +++ b/src/libutil/local.mk @@ -7,3 +7,5 @@ libutil_DIR := $(d) libutil_SOURCES := $(wildcard $(d)/*.cc) libutil_LDFLAGS = $(LIBLZMA_LIBS) -lbz2 -pthread $(OPENSSL_LIBS) $(LIBBROTLI_LIBS) $(BOOST_LDFLAGS) -lboost_context + +libutil_LIBS = libnixrust diff --git a/src/libutil/rust-ffi.cc b/src/libutil/rust-ffi.cc index a616d83a6..931d29542 100644 --- a/src/libutil/rust-ffi.cc +++ b/src/libutil/rust-ffi.cc @@ -1,5 +1,5 @@ #include "logging.hh" -#include "rust.hh" +#include "rust-ffi.hh" namespace nix { diff --git a/src/libstore/rust.hh b/src/libutil/tarfile.cc similarity index 53% rename from src/libstore/rust.hh rename to src/libutil/tarfile.cc index dccc98b4b..ae6d512bd 100644 --- a/src/libstore/rust.hh +++ b/src/libutil/tarfile.cc @@ -1,6 +1,14 @@ -#include "serialise.hh" #include "rust-ffi.hh" extern "C" { rust::CBox2>> unpack_tarfile(rust::Source source, rust::StringSlice dest_dir); } + +namespace nix { + +void unpackTarfile(Source & source, Path destDir) +{ + unpack_tarfile(source, destDir).use()->unwrap(); +} + +} diff --git a/src/libutil/tarfile.hh b/src/libutil/tarfile.hh new file mode 100644 index 000000000..c3e95fb0c --- /dev/null +++ b/src/libutil/tarfile.hh @@ -0,0 +1,7 @@ +#include "serialise.hh" + +namespace nix { + +void unpackTarfile(Source & source, Path destDir); + +}