Skip to content

Commit

Permalink
Build gpsim on Travis and deploy it to github releases.
Browse files Browse the repository at this point in the history
  • Loading branch information
timburke authored and amcgee committed Apr 1, 2015
1 parent c5907ea commit ce85f56
Show file tree
Hide file tree
Showing 2,113 changed files with 84 additions and 38,830 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/**
.vagrant
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: c++
sudo: true
install: ./install.sh
script: ./build.sh configure && ./build.sh make && ./build.sh package
deploy:
provider: releases
api_key:
secure: gU/+CafZlqD1ZY63M3rlBeS9FyrVaeLadgAoBl6Lu0ZFZG+NOt8DkOlbz+BVK3WV/tk7zBC9PEfUJu7S3TWnMxAVaCH0dGExqUQEljseqsjv4Bo5kvFF9+Ma2l5LILXw6jHpD5W74klE6y4EdUfr58OU55LDLNhUyFPbdvLxkKo=
file: ./gpsim.tar.gz
on:
repo: WellDone/gpsim
tags: true
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Patched GPSIM
A locally patched version of the GNU PIC Simulator, GPSIM, to enable features needed for MoMo simulation until they are ready to be integrated upstream.

"gpsim is a full-featured software simulator for Microchip PIC microcontrollers distributed under the GNU General Public License, Version 2 or higher, and some of it's libraries under GNU Lesser General Public License, Version 2 or higher." [gpsim.sourceforge.net](http://gpsim.sourceforge.net/)
10 changes: 10 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "gpsim" do |gpsim|
gpsim.vm.box = "hashicorp/precise64"
gpsim.vm.box_url = "https://vagrantcloud.com/hashicorp/precise64/version/2/provider/virtualbox.box"

gpsim.vm.provision "shell", inline: "/vagrant/install.sh"
end
end
92 changes: 43 additions & 49 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,97 +1,87 @@
#!/bin/bash
set -e

#Get the directory this script is in
#From http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
BUILDDIR="$BASEDIR/build"

PATCHFILE="$BASEDIR/gpsim_momo_patch.diff"
SVN_URL="svn://svn.code.sf.net/p/gpsim/code/trunk"
GPSIMDIR="gpsim"
SRCDIR="$BASEDIR/src"
GPSIMBUILDDIR="$BASEDIR/build"
OUTDIR="$BASEDIR/out"

#SVN_URL="svn://svn.code.sf.net/p/gpsim/code/trunk"
OLDDIR=`pwd`

#Programs that we need
LIBTOOL="libtoolize"

#Return 0 if svn has not been checked out
#Return 1 if svn has been checked out
function svn_checkedout() {
svn status gpsim 2>&1 | grep W155007 > /dev/null
function usage {
echo "Usage: build.sh [link|configure|make|clean|package]"
exit 1
}

#Check if the svn repository is a clean checkout, indicating our patch has not been applied
#Return 0 if the patch has been applied
#Return 1 if the patch has not been applied
function patch_applied() {
svn status gpsim 2>&1 | grep ^M > /dev/null
function link_gpsim {
mkdir -p $GPSIMBUILDDIR
cd "$GPSIMBUILDDIR"
echo "Linking src directory to build directory."
find $SRCDIR -mindepth 1 -depth -type d -printf "%P\n" | while read dir; do mkdir -p "$dir"; done
find $SRCDIR -type f -printf "%P\n" | while read file; do ln -sf "$SRCDIR/$file" "$file"; done
}

function update_svn {
#Make sure gpsim code has been checked out
svn_checkedout
if (($?==0)); then
echo -n "Checking out GPSIM from SVN (this could take a few minutes)..."
svn checkout $SVN_URL > /dev/null gpsim
echo " DONE"
fi

patch_applied
if (($?==1)); then
echo "Patching GPSIM Code..."
patch -p0 < "$PATCHFILE" -d "$GPSIMDIR" > /dev/null
echo "DONE Patching."
fi
}
function configure_gpsim {
#rm -rf $GPSIMBUILDDIR
./build.sh link

function usage {
echo "Usage: build.sh [configure|make|clean]"
exit 1
}
rm -rf $GPSIMBUILDDIR/m4
cp -prf $SRCDIR/m4 $GPSIMBUILDDIR/

function configure_gpsim {
cd "$GPSIMDIR"
$LIBTOOL --force
aclocal
autoheader
automake --force-missing --add-missing
autoconf
./configure --prefix="$BUILDDIR" --disable-gui
cd "$GPSIMBUILDDIR"

autoreconf --install --force
./configure --prefix="$OUTDIR" --disable-gui
cd ..
}

function make_gpsim {
cd "$GPSIMDIR"
cd "$GPSIMBUILDDIR"
make "$@"
make install
cd ..
}

function clean_gpsim {
cd "$GPSIMDIR"
rm -rf "$GPSIMBUILDDIR"
cd "$GPSIMBUILDDIR"
make clean > /dev/null 2>&1
rm -rf "$BUILDDIR"
rm -rf "$OUTDIR"
cd ..
}

function package_gpsim {
cd $OUTDIR && tar czf $BASEDIR/gpsim.tar.gz ./*
}

#Process Options
if (($#==0)); then
usage
fi

cd "$BASEDIR"
if [ ! -d $GPSIMDIR ]; then
mkdir "$GPSIMDIR"
if [ ! -d $GPSIMBUILDDIR ]; then
mkdir "$GPSIMBUILDDIR"
fi

if [ ! -d $BUILDDIR ]; then
mkdir "$BUILDDIR"
if [ ! -d $OUTDIR ]; then
mkdir "$OUTDIR"
fi


task="$1"
shift
case $task in
link)
link_gpsim
;;

configure)
configure_gpsim
;;
Expand All @@ -104,6 +94,10 @@ case $task in
clean_gpsim
;;

package)
package_gpsim
;;

*)
usage
;;
Expand Down
Loading

0 comments on commit ce85f56

Please sign in to comment.