Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c30a40d
Remove local patch file
timburke Mar 26, 2015
5b1d20d
Add modified momo files
timburke Apr 2, 2015
5274809
Add gpsim_module changes
timburke Apr 2, 2015
3464b06
Merge branch 'master' of github.com:WellDone/gpsim
timburke Apr 2, 2015
ba49057
Move modified momo files over to new src directory
timburke Apr 2, 2015
249ddce
Refactor momo simulation modules to allow for masters as well
timburke Apr 6, 2015
229339b
Remove generated file
timburke Apr 6, 2015
1a866eb
Add master module and refactor all modules
timburke Apr 12, 2015
6839e2f
Update gitignore
timburke Apr 12, 2015
53f1aff
Remove generated yacc grammer
timburke Apr 12, 2015
d9fedbb
Fix master behavior and test that its working
timburke Apr 15, 2015
2dcfff6
Update gitignore to ignore yacc parser
timburke Apr 15, 2015
57e353f
Fix typo in code that prevents enabling debugging
timburke Apr 19, 2015
9ad24a3
Fix to allow for slave clock stretching
timburke Apr 19, 2015
0bf3e0f
Fix i2c implementation to allow for clock stretching as a slave
timburke Apr 19, 2015
ac3a42d
Create script for building gpsim on windows
timburke May 12, 2015
d2d2d91
Bugfix the build script for windows
timburke May 12, 2015
c408a4a
Allow changing momo master call during retransmission
timburke May 12, 2015
43c62aa
Fix reading data in master mode
timburke May 12, 2015
5afcaf5
Fix EEPROM to not have improper delay on enhanced midrange chips
timburke May 12, 2015
92e56a6
Bugfix for i2c, flash modules and 16f1847 implementation
timburke May 13, 2015
e889529
Fix bit number error
timburke May 14, 2015
492b454
Actually include portb latch register in sfr map
timburke May 18, 2015
0d45345
Update I2C with more clock stretching and logging
timburke May 20, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
build/**
.vagrant
out/**
.vagrant
config.status
src/cli/parse.cc
17 changes: 11 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set -e
#From http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
SRCDIR="$BASEDIR/src"
SRCNAME="src"
BUILDNAME="build"
GPSIMBUILDDIR="$BASEDIR/build"
OUTDIR="$BASEDIR/out"

Expand All @@ -21,10 +23,16 @@ function usage {

function link_gpsim {
mkdir -p $GPSIMBUILDDIR
cd "$GPSIMBUILDDIR"
cd "$SRCDIR"
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

#More cross platform way to do the symbolic linking
#(other way does not work on os x b/c bsd find does not support -printf
find . -type d -exec mkdir -p ../$BUILDNAME/{} \;
find . -type f -exec ln -sf "$SRCDIR/{}" ../$BUILDNAME/{} \;
#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
cd ..
}

function configure_gpsim {
Expand All @@ -50,10 +58,7 @@ function make_gpsim {

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

function package_gpsim {
Expand Down
205 changes: 205 additions & 0 deletions prepare_windows.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
# Script for partially automating the compilation process of gpsim on Windows.
# There are a lot of gotchas in this process, however, that still need to be ironed out.
# I will attempt to list them all out here.
# 1. You need to make sure you have python installed and it needs to have a valid .a file for the python*.dll
# Follow the instructions here to generate such a file:
# http://eli.thegreenplace.net/2008/06/28/compiling-python-extensions-with-distutils-and-mingw
# 2. The path to the python installation is currently hardcoded. You should update it to your location in
# plat/win32/makefile.mingw
# 3. You must use cygwin (not cygwin64 and you must build a 32 bit binary)
# build command is make -f makefile.mingw in gpsim base directory
#
# *** Build Instructions for gpsim on Windows ***
# 1. Read http://gpsim.sourceforge.net/gpsimWin32/gpsimWin32.html and make sure you have cygwin 32 bit installed with the correct packages
# 2. run `python prepare_windows prepare C:\gpsim_project` from patched_gpsim root directory
# 3. from a cygwin shell, navigate to C:\gpsim_project/gpsim and run make -f makefile.mingw
# 4. run `python prepare_windows package C:\gpsim_project` from patched_gpsim root directory
# 5. You can now execute gpsim from C:\gpsim_project\gpsim\gpsim\bin

import urllib
import os.path
import shutil
import os
import zipfile
import sys

cygwin = "C:/cygwin"

#All needed packages
reqs = []
reqs.append(['popt', 'http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/popt-dev-1.10.2-tml-20050828.zip'])
reqs.append(['glib', 'http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.28/glib-dev_2.28.8-1_win32.zip'])
reqs.append(['pango', 'http://ftp.gnome.org/pub/gnome/binaries/win32/pango/1.29/pango-dev_1.29.4-1_win32.zip'])
reqs.append(['gtk+', 'http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/gtk+-dev_2.24.10-1_win32.zip'])
reqs.append(['atk', 'http://ftp.gnome.org/pub/gnome/binaries/win32/atk/1.32/atk-dev_1.32.0-2_win32.zip'])
reqs.append(['cairo', 'http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo-dev_1.10.2-2_win32.zip'])
reqs.append(['gdk-pixbuf', 'http://ftp.gnome.org/pub/gnome/binaries/win32/gdk-pixbuf/2.24/gdk-pixbuf-dev_2.24.0-1_win32.zip'])
reqs.append(['fontconfig', 'http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/fontconfig-dev_2.8.0-2_win32.zip'])
reqs.append(['gtkextra-2', r'http://sourceforge.net/projects/gtkextra/files/2.1.2/gtk%2Bextra-2.1.2-dev.zip'])
reqs.append(['pthreads-src', 'ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip'])
reqs.append(['readline', 'http://gpsim.sourceforge.net/gpsimWin32/packages/readline-5.2-20061112-lib.zip'])

#All dlls and other files that need to be copied where gpsim.exe is so that is can find them and use them
#Imagine how painstaking it was to find all the right ones...
deps = []
deps.append([('bin/libpopt-0.dll',), 'http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/popt-1.10.2-tml-20050828.zip'])
deps.append([('bin/libgthread-2.0-0.dll', 'bin/libgio-2.0-0.dll', 'bin/libglib-2.0-0.dll', 'bin/libgobject-2.0-0.dll', 'bin/libgmodule-2.0-0.dll'), 'http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.28/glib_2.28.8-1_win32.zip'])
deps.append([(r'bin/*', r'etc/%', r'lib/%'),'http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/gtk+_2.24.10-1_win32.zip'])
deps.append([('bin/libpng14-14.dll',), 'http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/libpng_1.4.3-1_win32.zip'])
deps.append([(r'etc/%', r'lib/%', 'bin/libpangoft2-1.0-0.dll', 'bin/libpango-1.0-0.dll','bin/libpangowin32-1.0-0.dll', 'bin/libpangocairo-1.0-0.dll'), 'http://ftp.gnome.org/pub/gnome/binaries/win32/pango/1.29/pango_1.29.4-1_win32.zip'])
deps.append([('bin/libatk-1.0-0.dll',), 'http://ftp.gnome.org/pub/gnome/binaries/win32/atk/1.32/atk_1.32.0-2_win32.zip'])
deps.append([('bin/libcairo-2.dll',), 'http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo_1.10.2-2_win32.zip'])
deps.append([('bin/libatk-1.0-0.dll',), 'http://ftp.gnome.org/pub/gnome/binaries/win32/atk/1.32/atk_1.32.0-2_win32.zip'])
deps.append([('bin/libgdk_pixbuf-2.0-0.dll',), 'http://ftp.gnome.org/pub/gnome/binaries/win32/gdk-pixbuf/2.24/gdk-pixbuf_2.24.0-1_win32.zip'])
deps.append([('bin/libfontconfig-1.dll',), 'http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/fontconfig_2.8.0-2_win32.zip'])
#deps.append(['http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/expat_2.0.1-1_win32.zip'])
deps.append([('bin/iconv.dll',), 'http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/libiconv-1.9.1.bin.woe32.zip'])
deps.append([('bin/intl.dll',), 'http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime_0.18.1.1-2_win32.zip'])
deps.append([('bin/zlib1.dll',), 'http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/zlib_1.2.5-2_win32.zip'])
deps.append([('bin/freetype6.dll',), 'http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/freetype_2.4.2-1_win32.zip'])
deps.append([('Pre-built.2/dll/x86/pthreadGC2.dll',), 'ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip'])
deps.append([('bin/readline5.dll',), 'http://gpsim.sourceforge.net/gpsimWin32/packages/readline-5.2-20061112-bin.zip'])
deps.append([('bin/gtkextra-win32-2.1.dll',), r'http://sourceforge.net/projects/gtkextra/files/2.1.2/gtk%2Bextra-2.1.2-dev.zip'])
deps.append([('bin/popt1.dll',), 'http://downloads.sourceforge.net/project/gnuwin32/popt/1.8-1/popt-1.8-1-bin.zip'])
deps.append([('bin/libintl-2.dll', 'bin/libiconv-2.dll'), 'http://downloads.sourceforge.net/project/gnuwin32/popt/1.8-1/popt-1.8-1-dep.zip'])

def download_file(url, local):
print " Downloading %s" % local
urllib.urlretrieve(url, local)

def extract_package(url, parent, folder=None, extract_only=False):
if folder is not None:
print "Preparing %s" % folder
else:
print "Fetching %s" % url
cachedir = os.path.join(parent, "cache")

if not os.path.exists(cachedir):
os.mkdir(cachedir)

base,sep,filename = url.rpartition('/')

fpath = os.path.join(cachedir, filename)
if not os.path.exists(fpath):
download_file(url, fpath)
else:
print " Using cached version"

if extract_only:
return fpath

outdir = os.path.join(parent, folder)
if os.path.exists(outdir) and not os.path.isdir(outdir):
raise ValueError("Could not remove folder %s which was not a folder." % outdir)

if os.path.exists(outdir):
shutil.rmtree(outdir)

os.mkdir(outdir)

fzip = zipfile.ZipFile(fpath)

fzip.extractall(outdir)

def extract_file(fzip, outdir, f):
dstfile = os.path.basename(f)
dstpath = os.path.join(outdir, dstfile)

fzip.extract(f, outdir)

#This somehow corrupts the dll files, wtf?
#with fzip.open(f, 'r') as fileobj:
# with open(dstpath, 'w') as destobj:
# contents = fileobj.read()
# destobj.write(contents)

def copy_runtime(files, archive, parent):
fpath = extract_package(archive, parent, extract_only=True)
fzip = zipfile.ZipFile(fpath)

outdir = os.path.join(parent, 'gpsim', 'gpsim')

for f in files:
if '*' in f:
folder = os.path.dirname(f)
print ' Extracting everything in folder %s' % folder
for m in fzip.namelist():
if m.startswith(folder):
extract_file(fzip, outdir, m)
elif '%' in f:
folder = os.path.dirname(f)
print ' Extracting folder %s' % folder

for m in fzip.namelist():
if m.startswith(folder):
fzip.extract(m, outdir)
else:
try:
print " Extracting %s" % f
extract_file(fzip, outdir, f)
except KeyError:
print fzip.namelist()
print "Could not extract %s" % f
sys.exit(1)

#Start of script
if len(sys.argv) != 3:
print "usage: prepare_windows.py [prepare|package] <desired project directory>"
sys.exit(1)

cmd = sys.argv[1]
if cmd not in ['prepare', 'package']:
print "usage: prepare_windows.py [prepare|package] <desired project directory>"
sys.exit(1)

basedir = sys.argv[2]
if not os.path.exists(basedir):
os.mkdir(basedir)

if cmd == 'prepare':
for folder, url in reqs:
extract_package(url, basedir, folder)

#Copy over the source code
srcdir = os.path.join(os.path.dirname(__file__), 'src')
dstdir = os.path.join(basedir, 'gpsim')
if os.path.exists(dstdir):
shutil.rmtree(dstdir)

print "Copying source code"
shutil.copytree(srcdir, dstdir)

print "Unpacking pthreads"
if os.path.exists(os.path.join(basedir, 'pthreads')):
shutil.rmtree(os.path.join(basedir, 'pthreads'))

shutil.copytree(os.path.join(basedir, 'pthreads-src', 'Pre-built.2', 'lib', 'x86'), os.path.join(basedir, 'pthreads', 'lib'))
shutil.copytree(os.path.join(basedir, 'pthreads-src', 'Pre-built.2', 'dll', 'x86'), os.path.join(basedir, 'pthreads', 'dll'))
shutil.copytree(os.path.join(basedir, 'pthreads-src', 'Pre-built.2', 'include'), os.path.join(basedir, 'pthreads', 'include'))
elif cmd == 'package':
for files, archive in deps:
copy_runtime(files, archive, basedir)

print "Copying gpsim executable"
src = os.path.join(basedir, 'gpsim', 'gpsim', 'gpsim.exe')
dst = os.path.join(basedir, 'gpsim', 'gpsim', 'bin', 'gpsim.exe')
shutil.copyfile(src, dst)

print "Copying gpsim dll"
src = os.path.join(basedir, 'gpsim', 'src', 'libgpsim.dll')
dst = os.path.join(basedir, 'gpsim', 'gpsim', 'bin', 'libgpsim.dll')
shutil.copyfile(src, dst)

print "Copying gcc runtime"
src = os.path.join(cygwin, 'usr', 'i686-w64-mingw32', 'sys-root', 'mingw', 'bin', 'libgcc_s_sjlj-1.dll')
dst = os.path.join(basedir, 'gpsim', 'gpsim', 'bin', 'libgcc_s_sjlj-1.dll')
shutil.copyfile(src, dst)

src = os.path.join(cygwin, 'usr', 'i686-w64-mingw32', 'sys-root', 'mingw', 'bin', 'libstdc++-6.dll')
dst = os.path.join(basedir, 'gpsim', 'gpsim', 'bin', 'libstdc++-6.dll')
shutil.copyfile(src, dst)

print "Copying gpsim modules"
src = os.path.join(basedir, 'gpsim', 'modules', 'libgpsim_modules.dll')
dst = os.path.join(basedir, 'gpsim', 'gpsim', 'bin', 'libgpsim_modules.dll')
shutil.copyfile(src, dst)
Loading