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

By seasoned_geek

Roland Hughes started his IT career in the early 1980s. He quickly became a consultant and president of Logikal Solutions, a software consulting firm specializing in OpenVMS application and C++/Qt touchscreen/embedded Linux development. Early in his career he became involved in what is now called cross platform development. Given the dearth of useful books on the subject he ventured into the world of professional author in 1995 writing the first of the "Zinc It!" book series for John Gordon Burke Publisher, Inc. A decade later he released a massive (nearly 800 pages) tome "The Minimum You Need to Know to Be an OpenVMS Application Developer" which tried to encapsulate the essential skills gained over what was nearly a 20 year career at that point. From there "The Minimum You Need to Know" book series was born. Three years later he wrote his first novel "Infinite Exposure" which got much notice from people involved in the banking and financial security worlds. Some of the attacks predicted in that book have since come to pass. While it was not originally intended to be a trilogy, it became the first book of "The Earth That Was" trilogy: Infinite Exposure Lesedi - The Greatest Lie Ever Told John Smith - Last Known Survivor of the Microsoft Wars When he is not consulting Roland Hughes posts about technology and sometimes politics on his blog. He also has regularly scheduled Sunday posts appearing on the Interesting Authors blog.