Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- export BUILD_FOLDER=$1
- export MYLOCALE="it"
- export INSTALL_TARGET="ubuntu-vmware.local"
- export PATH=$HOME/.local/bin:/opt/dev/bin:$PATH
- export CPUs=$(grep -w -c processor /proc/cpuinfo)
- export CONCURRENCY_LEVEL=$((CPUs+CPUs/4))
- export MAKEFLAGS="-j$CONCURRENCY_LEVEL"
- # export LC_ALL="C.UTF-8"
- builder=""
- if [ -z "$BUILD_FOLDER" ]; then
- echo "Impossible to build in this folder"
- exit 1
- fi
- schroot -c unstable -- jhbuild shell << "EOF"
- if [ -z "$JHBUILD_CHECKOUT_FOLDER" ]; then
- echo "Add checkout folder definition to your environment, edit your .jhbuildrc:"
- echo " os.environ['JHBUILD_CHECKOUT_FOLDER'] = checkoutroot"
- exit 1
- fi
- if [ -z "$JHBUILD_BUILD_FOLDER" ]; then
- echo "Add checkout folder definition to your environment, edit your .jhbuildrc:"
- echo " os.environ['JHBUILD_BUILD_FOLDER'] = buildroot"
- exit 1
- fi
- file_path=$(realpath --relative-to=$JHBUILD_CHECKOUT_FOLDER $BUILD_FOLDER)
- if [ "$file_path" == "." ] || [[ "$file_path" == "../"* ]]; then
- echo "File path is not buildable: '$file_path'"
- exit 1
- fi
- project_path=$(echo $file_path | cut -f1 -d/)
- if [ -z "$project_path" ]; then
- echo "Impossible to get a good project path from $file_path"
- exit 1
- fi
- source_path="$JHBUILD_CHECKOUT_FOLDER/$project_path"
- builder_path="$JHBUILD_BUILD_FOLDER/$project_path"
- builder="make"
- if ! [ -f "$builder_path/Makefile" ]; then
- builder_path="$JHBUILD_CHECKOUT_FOLDER/$project_path"
- if ! [ -f "$builder_path/Makefile" ]; then
- builder=""
- fi
- fi
- if [ "$builder" == "make" ]; then
- if [ ! -f "$builder_path/compile_commands.json" ] ||
- [ ! -f "$builder_path/compile_commands_headers.stamp" ] ||
- [ "$builder_path/config.status" -nt "$builder_path/compile_commands.json" ] ||
- [ "$source_path/configure.ac" -nt "$builder_path/config.status" ]; then
- echo "Using bear make to generate compile_commands.json"
- builder="bear -a -o $builder_path/compile_commands.json make"
- fi
- fi
- if [ -z "$builder" ]; then
- builder="ninja"
- builder_path="$JHBUILD_BUILD_FOLDER/$project_path"
- if ! [ -f "$builder_path/build.ninja" ]; then
- builder_path="$JHBUILD_CHECKOUT_FOLDER/$project_path"
- if ! [ -f "$builder_path/build.ninja" ]; then
- builder=""
- fi
- fi
- fi
- if [ -z "$builder" ]; then
- echo "Impossible to find a valid build path for $project_path"
- exit 1;
- fi
- echo "builder is $builder"
- $builder install -C "$builder_path"
- builder_exit=$?
- if [ -n "$MYLOCALE" ]; then
- find $JHBUILD_PREFIX/share/locale -mindepth 1 -maxdepth 1 \
- ! -name "$MYLOCALE" -type d -exec rm -fr {} \;
- fi
- if [ $builder_exit -eq 0 ] && [ -n "$INSTALL_TARGET" ]; then
- # if timeout 0.5 ping -q -c1 -W1 $INSTALL_TARGET &> /dev/null; then
- rsync -a --delete $JHBUILD_PREFIX $INSTALL_TARGET:$(dirname $JHBUILD_PREFIX) --stats
- # else
- # echo "BUILD DONE; BUT NOT SYCED WITH '$INSTALL_TARGET'"
- # fi
- fi
- # if [ $builder_exit -eq 0 ] &&
- # (([ -f "$builder_path/compile_commands.json" ] && [ ! -f "$builder_path/compile_commands_headers.stamp" ]) ||
- # [ "$builder_path/compile_commands.json" -nt "$JHBUILD_CHECKOUT_FOLDER/compile_commands.json" ]); then
- # $JHBUILD_CHECKOUT_FOLDER/generate-full-compile-commands.sh --update-root $project_path
- # fi
- if [ $builder_exit -eq 0 ] &&
- (([ -f "$builder_path/compile_commands.json" ] && [ ! -f "$builder_path/compile_commands_headers.stamp" ]) ||
- [ "$builder_path/compile_commands.json" -nt "$builder_path/compile_commands_headers.stamp" ]); then
- $JHBUILD_CHECKOUT_FOLDER/generate-full-compile-commands.sh $project_path
- fi
- if [ $builder_path != $source_path ] && [ -e $builder_path/compile_commands.json ]; then
- cp -uv $builder_path/compile_commands.json $source_path/compile_commands.json
- fi
- exit $builder_exit
- EOF
- jhbuild_ret=$?
- # if [ $jhbuild_ret -eq 0 ] && timeout 0.5 ping -q -c1 -W1 ubuntu-vmware.local &> /dev/null; then
- # echo rsync -a --delete $JHBUILD_PREFIX ubuntu-vmware.local:$(dirname $JHBUILD_PREFIX) --stats --info=progress2
- # fi
- exit $jhbuild_ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement