Information Technology

CopperSpice Experiments – Pt. 19

My first real computer job was midnight computer operator for Airfone Inc. There I learned respect for automated update procedures and bare metal backups. I’m not talking about that hokey Microsoft stuff that reboots your computer in the middle of a critical process. I’m talking about batch scripts run in a controlled manner as part of a regular job stream.

When you are working with an OpenSource library and building from scratch you too need to learn respect for both things. The AGILE junkies haven’t figured out you can’t have push updates. They don’t care about quality software so they never develop scripts or procedures like these. Now that I’m started down the path of porting the Scintilla library to CopperSpice, and have a few days to work on this, I needed a script.

# -*- mode: sh -*-
#
# refresh-copperspice
#
# Leave the first comment line in place so Emacs can properly highlight a file without extension
#
# Command script to update your cloned repo and build fresh from scratch
# a new set of copperspice libraries
#
# Step 1: define our variables
#
#set -x
CLONE_DIR="$HOME/Projects/copperspice"
BUILD_DIR="$HOME/Projects/cs_build"
INSTALL_DIR="/usr/local"
NINJA_OPTION="-j2"


echo "***NOTE***   This build process does not support cross compilation."
echo "             If you wish to compile one one architecture for another you will need"
echo "             to modify the various cmake scripts."
echo " "
echo "***NOTE 2*** This build script limits ninja via NINJA_OPTION parameter to reduce resource"
echo "             consumption. Build can require more than 8Gig of RAM per processor."
echo "             If you only have 8Gig of RAM, adjust $NINJA_OPTION."
echo " "
echo " Script will git pull and rebase your CopperSpice code. "
echo " You must have already established your git directory/username/etc."
echo " "
echo " Using the following directory information "
echo " "
echo "CLONE_DIR:    $CLONE_DIR"
echo "BUILD_DIR:    $BUILD_DIR"
echo "INSTALL_DIR:  $INSTALL_DIR"
echo "NINJA_OPTION: $NINJA_OPTION"
echo " "

while true; do
    read -p "Is this correct (Y/n)?" RESP
#"${yn:-Y}"
    case "${RESP:-Y}" in
        [""]* ) ;;
        [Yy]* ) echo "Yes"; break;;
        [Nn]* ) exit;;
	* ) echo "Please answer Y or n";;
    esac
done

cd "$CLONE_DIR"
#
# We should have no local changes so force rebase because any change
# was accidental
#
git pull origin master --rebase

# Now create a fresh build directory
#

if [ -d "$BUILD_DIR" ]; then rm -Rf "$BUILD_DIR" ; fi

mkdir "$BUILD_DIR"
cd "$BUILD_DIR"

pwd
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -S "$CLONE_DIR" -B "$BUILD_DIR"

echo "**** Starting Build: $(date +%F-%T)"
pwd
sudo ninja $NINJA_OPTION install

echo "**** Completed: $(date +%F-%T)"

Here you go. It will prompt you to verify the directories then it will “just build” after first updating. This script assumes you did an initial clone and have your Git username/password/security information already set up in the clone.

Automated update procedures like this don’t run automatically (though you could certainly make a CRON job out of them). They automate the task so you can kick it off when you are ready.

You have the option to quit before it does anything
After you say things are correct you will eventually be prompted for sudo password

<Previous