Skip to content

Instantly share code, notes, and snippets.

@luqmana
Created November 21, 2013 23:49
Show Gist options
  • Save luqmana/86a6943fa7feab4c2a14 to your computer and use it in GitHub Desktop.
Save luqmana/86a6943fa7feab4c2a14 to your computer and use it in GitHub Desktop.
#!/bin/bash
VERS=`grep -R "CFG_RELEASE.*=" ../Makefile.in | awk '{ print $3; }'`
TARGET=$1
TOOLS_PREFIX=$2
mkdir -p contained/$TARGET/lib/rustc/$TARGET/lib
mkdir -p contained/$TARGET/bin
echo "Building rustllvm..."
mkdir -p $TARGET/rustllvm
echo "PassWrapper"
$TOOLS_PREFIX-g++ ../src/rustllvm/PassWrapper.cpp -c -o $TARGET/rustllvm/PassWrapper.o -I../src/llvm/include -I../src/rustllvm/ -I$TARGET/llvm/include/ -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
echo "RustWrapper"
$TOOLS_PREFIX-g++ ../src/rustllvm/RustWrapper.cpp -c -o $TARGET/rustllvm/RustWrapper.o -I../src/llvm/include -I../src/rustllvm/ -I$TARGET/llvm/include/ -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
echo "rustllvm.dll"
$TOOLS_PREFIX-g++ -o $TARGET/rustllvm.dll -shared -fPIC -g -m32 $TARGET/rustllvm/rustllvm.mingw32.def $TARGET/rustllvm/RustWrapper.o $TARGET/rustllvm/PassWrapper.o -lLLVMInstrumentation -lLLVMInterpreter -lLLVMMCJIT -lLLVMJIT -lLLVMRuntimeDyld -lLLVMExecutionEngine -lLLVMAsmParser -lLLVMLinker -lLLVMBitWriter -lLLVMBitReader -lLLVMipo -lLLVMVectorize -lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMMipsAsmPrinter -lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMObjCARCOpts -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMX86Desc -lLLVMX86Info -lLLVMTarget -lLLVMX86AsmPrinter -lLLVMMC -lLLVMObject -lLLVMX86Utils -lLLVMCore -lLLVMSupport -L$TARGET/llvm/Release+Asserts/lib -lpsapi -limagehlp -lm
cp $TARGET/rustllvm.dll x86_64-unknown-linux-gnu/stage2/lib/rustc/$TARGET/lib
echo "Building libsyntax..."
x86_64-unknown-linux-gnu/stage2/bin/rustc --cfg stage2 -O --cfg rtopt --cfg debug -Z no-debug-borrows --target=$TARGET --linker=$TOOLS_PREFIX-gcc -D warnings --out-dir x86_64-unknown-linux-gnu/stage2/lib/rustc/$TARGET/lib ../src/libsyntax/lib.rs
echo "Building librustc..."
CFG_COMPILER="$TARGET" CFG_LIBDIR="lib" CFG_PREFIX="/scratch/laden/local" CFG_VERSION="$VERS `git log -1 --pretty=format:'(%h %ci)'`" x86_64-unknown-linux-gnu/stage2/bin/rustc --cfg stage2 -O --cfg rtopt --cfg debug -Z no-debug-borrows --target=$TARGET --linker=$TOOLS_PREFIX-gcc -D warnings --out-dir x86_64-unknown-linux-gnu/stage2/lib/rustc/$TARGET/lib ../src/librustc/lib.rs
echo "Building rustc..."
x86_64-unknown-linux-gnu/stage2/bin/rustc --cfg stage2 -O --cfg rtopt --cfg debug --target=$TARGET --linker=$TOOLS_PREFIX-gcc --cfg rustc -o x86_64-unknown-linux-gnu/stage2/lib/rustc/$TARGET/bin/rustc.exe ../src/driver/driver.rs --link-args "-lstdc++ -lrustllvm"
echo "Copying files..."
cp x86_64-unknown-linux-gnu/stage2/lib/rustc/$TARGET/bin/rustc.exe contained/$TARGET/bin
cp $TARGET/rustllvm.dll contained/$TARGET/lib
cp $TARGET/rustllvm.dll contained/$TARGET/lib/rustc/$TARGET/lib
cp x86_64-unknown-linux-gnu/stage2/lib/rustc/$TARGET/lib/{rustuv-*,rustrt,std-*,extra-*,syntax-*,rustc-*}.dll contained/$TARGET/lib
cp x86_64-unknown-linux-gnu/stage2/lib/rustc/$TARGET/lib/{rustuv-*,rustrt,std-*,extra-*,syntax-*,rustc-*}.dll contained/$TARGET/bin
cp x86_64-unknown-linux-gnu/stage2/lib/rustc/$TARGET/lib/{rustuv-*,rustrt,std-*,extra-*,syntax-*,rustc-*}.dll contained/$TARGET/lib/rustc/$TARGET/lib
cp x86_64-unknown-linux-gnu/stage2/lib/rustc/$TARGET/lib/libmorestack.a contained/$TARGET/lib/rustc/$TARGET/lib
echo "Zipping..."
NAME="rust-$VERS-`git log -1 --pretty=format:'%h'`-$TARGET.zip"
pushd contained
rm -rf rust
cp -R $TARGET rust
zip -r $NAME rust
rm -rf rust
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment