diff --git a/cook.sh b/cook.sh index 7a2dea296b6d59482f7d49224e5cd1a58badac7e..242688365bf18fa7f7f0a5f1a8cc2500f35c265c 100755 --- a/cook.sh +++ b/cook.sh @@ -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 + recipe_prepare + fi + if [ "$skip" -eq "0" ] then - pushd $ROOT - ./repo.sh "${BUILD_DEPENDS[@]}" - popd + rm -rf sysroot + mkdir sysroot + + if [ ${#BUILD_DEPENDS} -gt 0 ] + then + pushd $ROOT + ./repo.sh "${BUILD_DEPENDS[@]}" + popd - for i in "${BUILD_DEPENDS[@]}" + 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 diff --git a/recipes/rust/.gitignore b/recipes/rust/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..0a8fbe5e2f89a7aac9bc0d9d40c10c3471236838 --- /dev/null +++ b/recipes/rust/.gitignore @@ -0,0 +1,3 @@ +/llvm-build/ +/llvm-prefix/ +/llvm-source/ diff --git a/recipes/rust/llvm-config b/recipes/rust/llvm-config index a4737c864a21313a0976689e49e50d8b168b45eb..cccfac4229143d6d03eea2df3ebdb9dc3792ce6d 100755 --- a/recipes/rust/llvm-config +++ b/recipes/rust/llvm-config @@ -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. diff --git a/recipes/rust/recipe.sh b/recipes/rust/recipe.sh index cc3b2c7f5894e455ff808ac7989aefb303bde8c0..b7410e3a4daaf66150e7d13fa4d96bffb4acb080 100644 --- a/recipes/rust/recipe.sh +++ b/recipes/rust/recipe.sh @@ -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