Skip to content

Commit b02d59a

Browse files
committed
Add scripts to bootstrap cargo and package
1 parent 234e5d4 commit b02d59a

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

Diff for: cargo.sh

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/bin/sh
2+
3+
CARGO_VERSION=0.0.1-pre
4+
CARGO_BINS="cargo-build cargo-git-checkout cargo-test cargo-clean cargo-new cargo-run \
5+
cargo-verify-project cargo-doc cargo-read-manifest cargo-rustc cargo-version"
6+
7+
RUSTC=rustc
8+
BUILD_DIR=`pwd`/cargo-build
9+
10+
gmake -v && GMAKE=gmake
11+
if [ "x${GMAKE}" = "x" ]; then
12+
GMAKE=make
13+
fi
14+
15+
export RUST_PATH=""
16+
17+
download() {
18+
cd ${BUILD_DIR}
19+
if [ ! -e "cargo" ]; then
20+
git clone https://github.com/rust-lang/cargo.git
21+
fi
22+
23+
if [ ! -e "docopt.rs" ]; then
24+
git clone https://github.com/burntsushi/docopt.rs
25+
fi
26+
27+
if [ ! -e "toml-rs" ]; then
28+
git clone https://github.com/alexcrichton/toml-rs
29+
fi
30+
}
31+
32+
checkout_revs() {
33+
cd ${BUILD_DIR}/cargo
34+
git checkout 59689f0bc2680b5517eab484112ad3cf50702286
35+
cd ${BUILD_DIR}/docopt.rs
36+
git checkout 0babd54a
37+
cd ${BUILD_DIR}/toml-rs
38+
git checkout a3c7f2c3
39+
}
40+
41+
build_deps() {
42+
cd ${BUILD_DIR}/toml-rs
43+
${GMAKE}
44+
unset RUST_PATH
45+
cd ${BUILD_DIR}/docopt.rs
46+
${GMAKE}
47+
}
48+
49+
compile_cargo() {
50+
cd ${BUILD_DIR}/cargo
51+
mkdir -p target
52+
53+
export CFG_VERSION="$CARGO_VERSION"
54+
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${BUILD_DIR}/docopt.rs/target"
55+
56+
${RUSTC} -L ${BUILD_DIR}/docopt.rs/target -L ${BUILD_DIR}/toml-rs/build \
57+
./src/cargo/lib.rs --out-dir=./target
58+
59+
for bin in cargo $CARGO_BINS; do
60+
${RUSTC} -L ${BUILD_DIR}/docopt.rs/target -L ${BUILD_DIR}/toml-rs/build \
61+
-L ${BUILD_DIR}/cargo/target \
62+
./src/bin/${bin}.rs --out-dir=./target
63+
done
64+
}
65+
66+
mkdir -p ${BUILD_DIR}
67+
68+
if [ "$1" = "install" ]; then
69+
echo "install"
70+
prefix="$2"
71+
if [ "x${prefix}" = "x" ]; then
72+
prefix=/usr/local
73+
fi
74+
echo "prefix: ${prefix}"
75+
76+
77+
mkdir -p $prefix/bin $prefix/lib/cargo
78+
79+
echo $prefix/bin/cargo > $prefix/lib/cargo/manifest
80+
install -v ${BUILD_DIR}/cargo/target/cargo $prefix/bin/cargo
81+
82+
for bin in $CARGO_BINS; do
83+
install -v ${BUILD_DIR}/cargo/target/$bin $prefix/lib/cargo/$bin
84+
echo $prefix/lib/cargo/$bin >> $prefix/lib/cargo/manifest
85+
done
86+
elif [ "$1" = "compile" ]; then
87+
echo "compile"
88+
download
89+
checkout_revs
90+
build_deps
91+
compile_cargo
92+
else
93+
echo "USAGE: $0 compile | install [prefix=/usr/local]"
94+
fi

Diff for: package.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
RUST_MANIFEST=/usr/local/lib/rustlib/manifest
2+
CARGO_MANIFEST=/usr/local/lib/cargo/manifest
3+
FILE=rust-0.12.0-pre-dragonfly.tar
4+
tar cvf ${FILE} ${RUST_MANIFEST} `cat ${RUST_MANIFEST}` \
5+
${CARGO_MANIFEST} `cat ${CARGO_MANIFEST}`
6+
bzip2 -9 ${FILE}
7+
sha1 ${FILE}.bz2

0 commit comments

Comments
 (0)