Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: from dyn to master #6

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ rust:
- nightly

before_script:
- ./install_dependent_libraries.sh
- rustup component add clippy-preview

script:
- cargo test -- --test-threads=1
- cargo test
- cargo clippy

matrix:
Expand All @@ -19,4 +20,6 @@ matrix:

env:
global:
- RUSTFLAGS="-D warnings"
- FRUGALOS_DIR=$TRAVIS_BUILD_DIR/frugalos_working_dir
- LD_LIBRARY_PATH=$FRUGALOS_DIR/lib
- RUSTFLAGS="-D warnings"
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
name = "liberasurecode"
version = "1.0.2"
authors = ["The FrugalOS Developers"]
links = "erasurecode"
build = "build.rs"
description = "A Rust wrapper for `openstack/liberasurecode`"
homepage = "https://github.com/frugalos/liberasurecode"
repository = "https://github.com/frugalos/liberasurecode"
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ For example, on Ubuntu, you can install those by executing the following command
$ sudo apt install gcc git make automake autoconf libtool
```

Before do `cargo build`, please set the two environment variables `FRUGALOS_DIR` and `LD_LIBRARY_PATH`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

依存関係的には、liberasurecodeはfrugalosに依存しないより汎用的なライブラリとしても使えるものだと思うので、個人的には FRUGALOS_DIR もそれを反映した名前(e.g., LIBERASURECODE_DIR)の方が好みです。
ただ、今回の修正でlibfrugalos内の他の個所にも結構frugalosという用語が出てくるようになって、それらを全て置き換えるのも手間だと思うので、別にこのままでも大丈夫です。

```
FRUGALOS_DIR=/some/path/to/locate/generated/artifacts
LD_LIBRARY_PATH=$FRUGALOS_DIR/lib
```
and do the following shell script to install auxiliary files
```
./install_dependent_libraries.sh
```


Examples
--------
Expand Down
33 changes: 3 additions & 30 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,10 @@
use std::env;
use std::fs;
use std::path::PathBuf;
use std::process::{Command, Stdio};

fn main() {
println!("cargo:rerun-if-changed=build.rs");

let outdir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
let build_dir = outdir.join("build");
let _ = fs::remove_dir_all(&build_dir);
fs::create_dir(&build_dir).unwrap();
let frugalos_dir: std::ffi::OsString = env::var_os("FRUGALOS_DIR").unwrap();
let frugalos_dir: String = frugalos_dir.into_string().unwrap();

for file in &["install_deps.sh", "liberasurecode.patch"] {
fs::copy(file, build_dir.join(file)).unwrap();
}

match Command::new("./install_deps.sh")
.current_dir(&build_dir)
.stderr(Stdio::inherit())
.output()
{
Err(e) => {
panic!("{}: {}", build_dir.display(), e);
}
Ok(output) => {
if !output.status.success() {
panic!(
"./install_deps.sh failed: exit-code={:?}",
output.status.code()
);
}
}
}

println!("cargo:rustc-link-search={}/lib", build_dir.display());
println!("cargo:rustc-link-search={}/lib", frugalos_dir);
}
68 changes: 68 additions & 0 deletions install_dependent_libraries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#! /usr/bin/env bash

set -eux

INSTALL_DIR=""

if [ -z $FRUGALOS_DIR ]
then
echo "Please set the environment FRUGALOS_DIR to install auxiliary artifacts."
exit 1
fi

INSTALL_DIR=$FRUGALOS_DIR

case $INSTALL_DIR in
/*)
echo "We install dependent artifacts into FRUGALOS_DIR=$FRUGALOS_DIR"
;;
*)
echo "You passed a relative path. Please use an absolute path."
exit 1
;;
esac

MAKE_FLAGS=""

# Please try and add other distributions.
case "$(uname)" in
"Linux") MAKE_FLAGS="-j$(nproc)";;
"Darwin") MAKE_FLAGS="-j$(sysctl -n hw.ncpu)"
esac

BUILD_DIR="build_working_directory"
mkdir $BUILD_DIR

#
# gf-complete
#
git clone https://github.com/ceph/gf-complete.git $BUILD_DIR/gf-complete
cd $BUILD_DIR/gf-complete
git checkout a6862d1
./autogen.sh
./configure --with-pic --prefix $INSTALL_DIR
make $MAKE_FLAGS install
cd ../..

#
# jerasure
#
git clone -b frugalos_dyn https://github.com/frugalos/jerasure.git $BUILD_DIR/jerasure
cd $BUILD_DIR/jerasure
autoreconf --force --install
CFLAGS="-I${INSTALL_DIR}/include" LDFLAGS="-L${INSTALL_DIR}/lib" ./configure --with-pic --prefix $INSTALL_DIR
make $MAKE_FLAGS install
cd ../..

#
# liberasurecode
#
git clone -b frugalos_dyn https://github.com/frugalos/openstack_liberasurecode.git $BUILD_DIR/openstack_liberasurecode
cd $BUILD_DIR/openstack_liberasurecode
./autogen.sh
CFLAGS="-I${INSTALL_DIR}/include -I${INSTALL_DIR}/include/jerasure"
if [ "$(uname)" == "Darwin" ]; then
CFLAGS="$CFLAGS -Wno-error=address-of-packed-member"
fi
CFLAGS=$CFLAGS LDFLAGS="-L${INSTALL_DIR}/lib" ./configure --with-pic --prefix $INSTALL_DIR
make $MAKE_FLAGS install
15 changes: 6 additions & 9 deletions install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,29 @@ git clone https://github.com/ceph/gf-complete.git
cd gf-complete/
git checkout a6862d1
./autogen.sh
./configure --disable-shared --with-pic --prefix $BUILD_DIR
./configure --with-pic --prefix $BUILD_DIR
make $MAKE_FLAGS install
cd ../

#
# jerasure
#
git clone https://github.com/ceph/jerasure.git
git clone -b frugalos_dyn https://github.com/frugalos/jerasure.git
cd jerasure/
git checkout de1739c
autoreconf --force --install
CFLAGS="-I${BUILD_DIR}/include" LDFLAGS="-L${BUILD_DIR}/lib" ./configure --disable-shared --enable-static --with-pic --prefix $BUILD_DIR
CFLAGS="-I${BUILD_DIR}/include" LDFLAGS="-L${BUILD_DIR}/lib" ./configure --with-pic --prefix $BUILD_DIR
make $MAKE_FLAGS install
cd ../

#
# liberasurecode
#
git clone https://github.com/openstack/liberasurecode.git
cd liberasurecode/
git checkout 1.5.0
git clone -b frugalos_dyn https://github.com/frugalos/openstack_liberasurecode.git
cd openstack_liberasurecode/
./autogen.sh
CFLAGS="-I${BUILD_DIR}/jerasure/include -I${BUILD_DIR}/include"
if [ "$(uname)" == "Darwin" ]; then
CFLAGS="$CFLAGS -Wno-error=address-of-packed-member"
fi
CFLAGS=$CFLAGS LIBS="-lJerasure" LDFLAGS="-L${BUILD_DIR}/lib" ./configure --disable-shared --with-pic --prefix $BUILD_DIR
patch -p1 < ../liberasurecode.patch # Applies a patch for building static library
CFLAGS=$CFLAGS LDFLAGS="-L${BUILD_DIR}/lib" ./configure --with-pic --prefix $BUILD_DIR
make $MAKE_FLAGS install
Loading