[gnoduino] add cwd and sketch dir to search paths for includes/libs also add sketch's upperdirectory and Libnam



commit 53e18f6726abb37441d98d2ab47cebcfa21e6dc7
Author: Lucian Langa <lucilanga gnome org>
Date:   Mon May 26 15:11:53 2014 +0200

    add cwd and sketch dir to search paths for includes/libs
    also add sketch's upperdirectory and Libname dir combo

 src/compiler.py |    9 +++++++--
 src/misc.py     |    3 +++
 src/preproc.py  |   18 ++++++++++++++++++
 src/ui.py       |    5 +++++
 4 files changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/src/compiler.py b/src/compiler.py
index 834c797..3c8c4fd 100644
--- a/src/compiler.py
+++ b/src/compiler.py
@@ -208,6 +208,9 @@ def compile(tw, id, output, notify):
                compline.extend(flags)
                compline.extend(["-I" + os.path.join(i, "utility") for i in preproc.generateLibs(id, buf)])
                compline.extend(misc.getArduinoIncludes())
+               localDir = os.path.dirname(tw.get_data("file"))
+               compline.extend(["-I"+localDir])
+               compline.extend(["-I"+os.path.abspath(os.path.join(localDir, ".."))])
                compline.append(pre_file)
                compline.append("-o"+pre_file+".o")
                misc.printMessageLn(output, ' '.join(compline)+"\n")
@@ -327,14 +330,16 @@ def getLibraries():
        #               fl = os.path.join(q, library, d)
        #               if os.path.exists(fl):
 
-"""checks whether library exists (it has been compiled and tries to compile it otherwise"""
+"""checks whether library exists (if it has been compiled and tries to compile it otherwise"""
 """@returns a list of compiled objects"""
 def validateLib(library, tempobj, flags, output, notify):
        """compile library also try to compile every cpp under libdir"""
        """also try to compile utility dir if present"""
-       paths = ["", misc.getArduinoLibsPath()]
+       paths = ["", misc.getArduinoLibsPath(), misc.getLocalPath()]
        if config.user_library != None and config.user_library != -1:
                paths.extend(i.strip() for i in config.user_library.split(';'))
+       paths.append(os.path.dirname(config.sketchFile))
+       paths.append(os.path.abspath(os.path.join(os.path.dirname(config.sketchFile), "..")))
        dirs = ["", "utility"]
        b = board.Board()
        res = []
diff --git a/src/misc.py b/src/misc.py
index 862c626..2b701f5 100644
--- a/src/misc.py
+++ b/src/misc.py
@@ -158,6 +158,9 @@ def readGnoduinoConfFile(confFile):
                c = c + 1
        return conf
 
+def getLocalPath():
+       return os.getcwd()
+
 def makeWorkdir():
        return tempfile.mkdtemp("", os.path.join(tempfile.gettempdir(), "build"+str(time.time())))
 
diff --git a/src/preproc.py b/src/preproc.py
index 674ef54..148f683 100644
--- a/src/preproc.py
+++ b/src/preproc.py
@@ -94,6 +94,24 @@ def findIncludes(instr, local=False):
                                os.path.exists(z.strip(".h").lower()) or \
                                os.path.exists(z.strip(".h").upper())):
                        my.append(z.strip(".h"))
+
+               sketchPath = os.path.dirname(config.sketchFile)
+               "is this really required"
+               if local and os.path.exists(sketchPath):
+                       my.append(sketchPath)
+
+               sp = os.path.join(sketchPath, z.strip(".h"))
+               if local and os.path.exists(sp):
+                       my.append(sp)
+
+               sp = os.path.abspath(os.path.join(sketchPath, ".."))
+               if local and os.path.exists(sp):
+                       my.append(sp)
+
+               sp = os.path.abspath(os.path.join(sketchPath, "..", z.strip(".h")))
+               if local and os.path.exists(sp):
+                       my.append(sp)
+
        for z in l:
                for r, d, f in os.walk(misc.getArduinoLibsPath()):
                        if len(f)>0:
diff --git a/src/ui.py b/src/ui.py
index 7596f1c..cc9aef2 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -57,6 +57,7 @@ def setupPage(w, page, p):
        cl.add_accelerator("activate", accel, ord("w"), gtk.gdk.CONTROL_MASK, 0)
        mainwin.add_accel_group(accel)
        srcview.updatePos(pg.get_data("buffer"), sb2)
+       config.sketchFile = pg.get_data("file")
 
 def replacePage(page):
        nb.remove_page(nb.page_num(page))
@@ -279,6 +280,10 @@ def compile(widget, data=file):
        cserial(None, 0, sctw)
        page = getCurrentPage()
        startSpinner()
+       page = getCurrentPage()
+       f = page.get_data("file")
+       page.get_data("view").set_data("file", f)
+       config.sketchFile = f
        obj = compiler.compile(page.get_data("view"), id, tw, sb) #page.get_data("buffer")
        stopSpinner()
        return obj


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]