From a890ec3f14ffe728610ccdce7ba0fd9befd83b10 Mon Sep 17 00:00:00 2001 From: Volker Mische Date: Thu, 16 Feb 2017 16:32:10 +0100 Subject: [PATCH] Fail if RocksDB or Snappy source is missing --- README.md | 4 ++++ librocksdb-sys/build.rs | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index cd598e2..f224fa5 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,7 @@ Feedback and pull requests welcome! If a particular feature of RocksDB is impor [dependencies] rocksdb = "0.6.0" ``` + +This binding is statically linked with a specific version of RocksDB. If you want to build it yourself, make sure you've also cloned the RocksDB and Snappy submodules: + + git submodule update --init --recursive diff --git a/librocksdb-sys/build.rs b/librocksdb-sys/build.rs index dd75c77..9b00556 100644 --- a/librocksdb-sys/build.rs +++ b/librocksdb-sys/build.rs @@ -1,5 +1,7 @@ extern crate gcc; +use std::fs; + fn link(name: &str, bundled: bool) { use std::env::var; let target = var("TARGET").unwrap(); @@ -13,6 +15,14 @@ fn link(name: &str, bundled: bool) { } } +fn fail_on_empty_directory(name: &str) { + if fs::read_dir(name).unwrap().count() == 0 { + println!("The `{}` directory is empty, did you forget to pull the submodules?", name); + println!("Try `git submodule update --init --recursive`"); + panic!(); + } +} + fn build_rocksdb() { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=rocksdb/"); @@ -118,6 +128,8 @@ fn build_snappy() { } fn main() { + fail_on_empty_directory("rocksdb"); + fail_on_empty_directory("snappy"); build_rocksdb(); build_snappy(); }