Skip to content

Commit

Permalink
Move code around
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Sep 11, 2019
1 parent 2beeddd commit 64fa31f
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 6 deletions.
1 change: 0 additions & 1 deletion nix-rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ impl<T> CBox<T> {
unsafe {
let size = std::mem::size_of::<T>();
let ptr = libc::malloc(size);
eprintln!("PTR = {:?}, SIZE = {}", ptr, size);
*(ptr as *mut T) = t; // FIXME: probably UB
Self {
ptr,
Expand Down
4 changes: 2 additions & 2 deletions src/libstore/builtins/unpack-channel.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "rust.hh"
#include "builtins.hh"
#include "compression.hh"
#include "tarfile.hh"

namespace nix {

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/libutil/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/libutil/rust-ffi.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "logging.hh"
#include "rust.hh"
#include "rust-ffi.hh"

namespace nix {

Expand Down
10 changes: 9 additions & 1 deletion src/libstore/rust.hh → src/libutil/tarfile.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#include "serialise.hh"
#include "rust-ffi.hh"

extern "C" {
rust::CBox2<rust::Result<std::tuple<>>> unpack_tarfile(rust::Source source, rust::StringSlice dest_dir);
}

namespace nix {

void unpackTarfile(Source & source, Path destDir)
{
unpack_tarfile(source, destDir).use()->unwrap();
}

}
7 changes: 7 additions & 0 deletions src/libutil/tarfile.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "serialise.hh"

namespace nix {

void unpackTarfile(Source & source, Path destDir);

}

0 comments on commit 64fa31f

Please sign in to comment.