Cleanup LLVM build in Rust recipe

This commit is contained in:
Jeremy Soller 2017-11-10 09:46:31 -07:00
parent 59bbdc3314
commit ceb3eb73df
4 changed files with 59 additions and 34 deletions

44
cook.sh
View File

@ -226,29 +226,37 @@ function op {
fi
popd > /dev/null
;;
prepare)
rm -rf sysroot
mkdir sysroot
if [ ${#BUILD_DEPENDS} -gt 0 ]
prepare)
skip=0
if [ "$(type -t recipe_prepare)" = "function" ]
then
pushd $ROOT
./repo.sh "${BUILD_DEPENDS[@]}"
popd
recipe_prepare
fi
if [ "$skip" -eq "0" ]
then
rm -rf sysroot
mkdir sysroot
for i in "${BUILD_DEPENDS[@]}"
if [ ${#BUILD_DEPENDS} -gt 0 ]
then
pushd $ROOT
./repo.sh "${BUILD_DEPENDS[@]}"
popd
for i in "${BUILD_DEPENDS[@]}"
do
pkg --target=$TARGET install --root sysroot "$REPO/$i.tar.gz"
done
fi
rm -rf build
cp -rp source build
for patch in *.patch
do
pkg --target=$TARGET install --root sysroot "$REPO/$i.tar.gz"
patch -p1 -d build < "$patch"
done
fi
rm -rf build
cp -rp source build
for patch in *.patch
do
patch -p1 -d build < "$patch"
done
;;
unprepare)
rm -rf build

3
recipes/rust/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/llvm-build/
/llvm-prefix/
/llvm-source/

View File

@ -4,7 +4,7 @@ import sys
import os
args = sys.argv[1:]
prefix = os.path.realpath(os.path.dirname(os.path.abspath(sys.argv[0])) + "/llvm-root")
prefix = os.path.realpath(os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0]))) + "/llvm-prefix")
# The values here are copied from the output of llvm-config running under Redox.
# This is a hack, and should be replaced if possible.

View File

@ -2,7 +2,10 @@ GIT=https://github.com/redox-os/rust.git
BRANCH=compile-redox-stage-0
DEPENDS="gcc cargo"
LLVM_PREFIX="$PWD/build/llvm-root"
LLVM_GIT="https://github.com/redox-os/llvm.git"
LLVM_SOURCE="$(realpath llvm-source)"
LLVM_BUILD="$(realpath llvm-build)"
LLVM_PREFIX="$(realpath llvm-prefix)"
SYSROOT="/usr/$HOST"
unset AR AS CC CXX LD NM OBJCOPY OBJDUMP RANLIB READELF STRIP
@ -14,27 +17,38 @@ function recipe_version {
skip=1
}
function recipe_fetch {
if [ ! -d "$LLVM_SOURCE" ]
then
git clone "$LLVM_GIT" -b redox --depth 1 "$LLVM_SOURCE"
fi
pushd "$LLVM_SOURCE" > /dev/null
git remote set-url origin "$LLVM_GIT"
git fetch origin
git pull
git submodule sync --recursive
git submodule update --init --recursive
popd > /dev/null
}
function recipe_prepare {
rm -rf "$LLVM_PREFIX"
mkdir -p "$LLVM_PREFIX"
rm -rf "$LLVM_BUILD"
mkdir "$LLVM_BUILD"
}
function recipe_update {
echo "skipping update"
skip=1
}
function recipe_build {
# Download patched LLVM
if [ -d llvm-redox ]
then
git -C llvm-redox pull
else
git clone https://github.com/redox-os/llvm.git -b redox --depth 1 llvm-redox
fi
# Build LLVM
rm -rf "$LLVM_PREFIX"
mkdir -p "$LLVM_PREFIX"
rm -rf llvm-redox/build
mkdir -p llvm-redox/build
pushd llvm-redox/build
CC=$HOST-gcc CXX=$HOST-g++ cmake "${LLVM_CMAKE_ARGS[@]}" ..
pushd "$LLVM_BUILD"
CC=$HOST-gcc CXX=$HOST-g++ cmake "${LLVM_CMAKE_ARGS[@]}" "${LLVM_SOURCE}"
make -j$(nproc)
make install
popd