Code

Add dll capabilities
authorishmal <ishmal@users.sourceforge.net>
Sat, 18 Nov 2006 13:05:09 +0000 (13:05 +0000)
committerishmal <ishmal@users.sourceforge.net>
Sat, 18 Nov 2006 13:05:09 +0000 (13:05 +0000)
build.xml
build28.xml
buildtool.cpp

index e393c994894bc18ec1e4ba5fe25ffafbacfe7950..c890c1a7de22ba04c7fed929136d18317cb090bb 100644 (file)
--- a/build.xml
+++ b/build.xml
     <cc cc="gcc" cxx="g++" destdir="${build}/obj">
            <fileset dir="${src}">
             <!-- THINGS TO EXCLUDE -->
-               <exclude name="ast"/>
-               <exclude name="bonobo"/>
+               <exclude name="ast/.*"/>
+               <exclude name="bonobo/.*"/>
                <exclude name="deptool.cpp"/>
                <exclude name="dialogs/filedialog-win32.cpp"/>
                <exclude name="display/testnr.cpp"/>
                <exclude name="display/bezier-utils-test.cpp"/>
                <exclude name="dom/jsdombind.cpp"/>
-               <exclude name="dom/work"/>
+               <exclude name="dom/work/.*"/>
                <exclude name="dom/odf/SvgOdg.cpp"/>
                <exclude name="extension/api.cpp"/>
-               <exclude name="extension/dxf2svg"/>
+               <exclude name="extension/dxf2svg/.*"/>
                <exclude name="extension/internal/gnome.cpp"/>
                <exclude name="extension/script/bindtest.cpp"/>
                <exclude name="extension/script/cpptest.cpp"/>
-               <exclude name="extension/plugin"/>
+               <exclude name="extension/plugin/.*"/>
                <exclude name="extract-uri-test.cpp"/>
                <exclude name="helper/units-test.cpp"/>
                <exclude name="inkview.cpp"/>
                <exclude name="round-test.cpp"/>
                <exclude name="sp-gradient-test.cpp"/>
                <exclude name="svg/ftos.cpp"/>
-               <exclude name="utest"/>
+               <exclude name="utest/.*"/>
                <exclude name="widgets/test-widgets.cpp"/>
                <exclude name="xml/quote-test.cpp"/>
                <exclude name="xml/repr-action-test.cpp"/>
             <!--JABBER-->
                <exclude name="pedro/pedrogui.cpp"/>
                <exclude name="pedro/pedrogui.h"/>
-               <exclude name="pedro/work"/>
+               <exclude name="pedro/work/.*"/>
             <!--WHITEBOARD-->
                <exclude name="ui/dialog/session-player.cpp"/>
                <exclude name="ui/dialog/whiteboard-connect.cpp"/>
   </target>
   
   <target name="lib" depends="compile">
-    <ar file="${build}/libinkscape.a">
+    <staticlib file="${build}/libinkscape.a">
           <fileset dir="${build}/obj">
               <exclude name="main,o"/>
               <exclude name="winmain,o"/>
           </fileset>
-       </ar>
+       </staticlib>
   </target>
 
   <target name="i18n" depends="compile">
index 8906be17b16dc913cf16505e731698723712f40a..5acbf67d722062e76b4f4d6bc3612b7c24116823 100644 (file)
     <cc cc="gcc" cxx="g++" destdir="${build}/obj">\r
            <fileset dir="${src}">\r
             <!-- THINGS TO EXCLUDE -->\r
-               <exclude name="ast"/>\r
-               <exclude name="bonobo"/>\r
+               <exclude name="ast/.*"/>\r
+               <exclude name="bonobo/.*"/>\r
                <exclude name="deptool.cpp"/>\r
                <exclude name="dialogs/filedialog-win32.cpp"/>\r
                <exclude name="display/testnr.cpp"/>\r
                <exclude name="display/bezier-utils-test.cpp"/>\r
                <exclude name="dom/jsdombind.cpp"/>\r
-               <exclude name="dom/work"/>\r
+               <exclude name="dom/work/.*"/>\r
                <exclude name="dom/odf/SvgOdg.cpp"/>\r
                <exclude name="extension/api.cpp"/>\r
-               <exclude name="extension/dxf2svg"/>\r
+               <exclude name="extension/dxf2svg/.*"/>\r
                <exclude name="extension/internal/gnome.cpp"/>\r
                <exclude name="extension/script/bindtest.cpp"/>\r
                <exclude name="extension/script/cpptest.cpp"/>\r
-               <exclude name="extension/plugin"/>\r
+               <exclude name="extension/plugin/.*"/>\r
                <exclude name="extract-uri-test.cpp"/>\r
                <exclude name="helper/units-test.cpp"/>\r
                <exclude name="inkview.cpp"/>\r
@@ -57,7 +57,7 @@
                <exclude name="round-test.cpp"/>\r
                <exclude name="sp-gradient-test.cpp"/>\r
                <exclude name="svg/ftos.cpp"/>\r
-               <exclude name="utest"/>\r
+               <exclude name="utest/.*"/>\r
                <exclude name="widgets/test-widgets.cpp"/>\r
                <exclude name="xml/quote-test.cpp"/>\r
                <exclude name="xml/repr-action-test.cpp"/>\r
@@ -65,7 +65,7 @@
             <!--JABBER-->\r
                <exclude name="pedro/pedrogui.cpp"/>\r
                <exclude name="pedro/pedrogui.h"/>\r
-               <exclude name="pedro/work"/>\r
+               <exclude name="pedro/work/.*"/>\r
             <!--WHITEBOARD-->\r
                <exclude name="ui/dialog/session-player.cpp"/>\r
                <exclude name="ui/dialog/whiteboard-connect.cpp"/>\r
   </target>\r
   \r
   <target name="lib" depends="compile">\r
-    <ar file="${build}/libinkscape.a">\r
+    <staticlib file="${build}/libinkscape.a">\r
           <fileset dir="${build}/obj">\r
               <exclude name="main,o"/>\r
               <exclude name="winmain,o"/>\r
           </fileset>\r
-       </ar>\r
+       </staticlib>\r
   </target>\r
 \r
   <target name="i18n" depends="compile">\r
index cb87693f37db07aa505b4f325b1af0a6d32c4654..90ccd69668671e6cbc2d9e5c1191f1a330bf10fd 100644 (file)
@@ -240,7 +240,7 @@ static int trex_newnode(TRex *exp, TRexNodeType type)
        if(type == OP_EXPR)
                n.right = exp->_nsubexpr++;
        if(exp->_nallocated < (exp->_nsize + 1)) {
-               int oldsize = exp->_nallocated;
+               //int oldsize = exp->_nallocated;
                exp->_nallocated *= 2;
                exp->_nodes = (TRexNode *)realloc(exp->_nodes, exp->_nallocated * sizeof(TRexNode));
        }
@@ -4882,7 +4882,8 @@ public:
     /**
      *  Load a dependency file, generating one if necessary
      */
-    std::vector<DepRec> getDepFile(const String &fileName);
+    std::vector<DepRec> getDepFile(const String &fileName,
+              bool forceRefresh);
 
     /**
      *  Save a dependency file
@@ -5449,7 +5450,7 @@ std::vector<DepRec> DepTool::loadDepFile(const String &depFile)
     Element *root = parser.parseFile(depFile.c_str());
     if (!root)
         {
-        error("Could not open %s for reading", depFile.c_str());
+        //error("Could not open %s for reading", depFile.c_str());
         return result;
         }
 
@@ -5521,14 +5522,26 @@ std::vector<DepRec> DepTool::loadDepFile(const String &depFile)
 /**
  *   This loads the dependency cache.
  */
-std::vector<DepRec> DepTool::getDepFile(const String &depFile)
+std::vector<DepRec> DepTool::getDepFile(const String &depFile,
+                   bool forceRefresh)
 {
-    std::vector<DepRec> result = loadDepFile(depFile);
-    if (result.size() == 0)
+    std::vector<DepRec> result;
+    if (forceRefresh)
         {
         generateDependencies(depFile);
         result = loadDepFile(depFile);
         }
+    else
+        {
+        //try once
+        result = loadDepFile(depFile);
+        if (result.size() == 0)
+            {
+            //fail? try again
+            generateDependencies(depFile);
+            result = loadDepFile(depFile);
+            }
+        }
     return result;
 }
 
@@ -5553,7 +5566,6 @@ public:
     typedef enum
         {
         TASK_NONE,
-        TASK_AR,
         TASK_CC,
         TASK_COPY,
         TASK_DELETE,
@@ -5565,6 +5577,8 @@ public:
         TASK_MSGFMT,
         TASK_RANLIB,
         TASK_RC,
+        TASK_SHAREDLIB,
+        TASK_STATICLIB,
         TASK_STRIP,
         TASK_TSTAMP
         } TaskType;
@@ -5666,111 +5680,6 @@ protected:
 
 
 
-
-/**
- * Run the "ar" command to archive .o's into a .a
- */
-class TaskAr : public Task
-{
-public:
-
-    TaskAr(MakeBase &par) : Task(par)
-        {
-               type = TASK_AR; name = "ar";
-               command = "ar crv";
-               }
-
-    virtual ~TaskAr()
-        {}
-
-    virtual bool execute()
-        {
-        //trace("###########HERE %d", fileSet.size());
-        bool doit = false;
-        
-        String fullOut = parent.resolve(fileName);
-        //trace("ar fullout: %s", fullOut.c_str());
-        
-        if (!listFiles(parent, fileSet))
-            return false;
-        String fileSetDir = fileSet.getDirectory();
-
-        for (unsigned int i=0 ; i<fileSet.size() ; i++)
-            {
-            String fname;
-                       if (fileSetDir.size()>0)
-                           {
-                           fname.append(fileSetDir);
-                fname.append("/");
-                }
-            fname.append(fileSet[i]);
-            String fullName = parent.resolve(fname);
-            //trace("ar : %s/%s", fullOut.c_str(), fullName.c_str());
-            if (isNewerThan(fullName, fullOut))
-                doit = true;
-            }
-        //trace("Needs it:%d", doit);
-        if (!doit)
-            {
-            return true;
-            }
-
-        String cmd = command;
-        cmd.append(" ");
-        cmd.append(fullOut);
-        for (unsigned int i=0 ; i<fileSet.size() ; i++)
-            {
-            String fname;
-                       if (fileSetDir.size()>0)
-                           {
-                           fname.append(fileSetDir);
-                fname.append("/");
-                }
-            fname.append(fileSet[i]);
-            String fullName = parent.resolve(fname);
-
-            cmd.append(" ");
-            cmd.append(fullName);
-            }
-
-        String outString, errString;
-        if (!executeCommand(cmd.c_str(), "", outString, errString))
-            {
-            error("AR problem: %s", errString.c_str());
-            return false;
-            }
-
-        return true;
-        }
-
-    virtual bool parse(Element *elem)
-        {
-        if (!parent.getAttribute(elem, "file", fileName))
-            return false;
-            
-        std::vector<Element *> children = elem->getChildren();
-        for (unsigned int i=0 ; i<children.size() ; i++)
-            {
-            Element *child = children[i];
-            String tagName = child->getName();
-            if (tagName == "fileset")
-                {
-                if (!parseFileSet(child, parent, fileSet))
-                    return false;
-                }
-            }
-        return true;
-        }
-
-private:
-
-    String command;
-    String fileName;
-    FileSet fileSet;
-
-};
-
-
 /**
  * This task runs the C/C++ compiler.  The compiler is invoked
  * for all .c or .cpp files which are newer than their correcsponding
@@ -5801,10 +5710,19 @@ public:
         if (!listFiles(parent, fileSet))
             return false;
 
+        bool refreshCache = false;
+        String fullName = parent.resolve("build.dep");
+        if (isNewerThan(parent.getURI().getPath(), fullName))
+            {
+            trace("regenerating cache");
+            refreshCache = true;
+            }
+
         DepTool depTool;
         depTool.setSourceDirectory(source);
         depTool.setFileList(fileSet.getFiles());
-        std::vector<DepRec> deps = depTool.getDepFile("build.dep");
+        std::vector<DepRec> deps =
+             depTool.getDepFile("build.dep", refreshCache);
         
         String incs;
         incs.append("-I");
@@ -6430,8 +6348,11 @@ public:
 
     virtual bool parse(Element *elem)
         {
-        if (!parent.getAttribute(elem, "command", command))
+        String s;
+        if (!parent.getAttribute(elem, "command", s))
             return false;
+        if (s.size()>0)
+            command = s;
         if (!parent.getAttribute(elem, "out", fileName))
             return false;
             
@@ -6505,6 +6426,7 @@ public:
             }
         for (unsigned int i=0 ; i<text.size() ; i++)
             fputc(text[i], f);
+        fputc('\n', f);
         fclose(f);
         return true;
         }
@@ -6803,6 +6725,241 @@ private:
 
 
 
+/**
+ *  Collect .o's into a .so or DLL
+ */
+class TaskSharedLib : public Task
+{
+public:
+
+    TaskSharedLib(MakeBase &par) : Task(par)
+        {
+               type = TASK_SHAREDLIB; name = "dll";
+               command = "ar crv";
+               }
+
+    virtual ~TaskSharedLib()
+        {}
+
+    virtual bool execute()
+        {
+        //trace("###########HERE %d", fileSet.size());
+        bool doit = false;
+        
+        String fullOut = parent.resolve(fileName);
+        //trace("ar fullout: %s", fullOut.c_str());
+        
+        if (!listFiles(parent, fileSet))
+            return false;
+        String fileSetDir = fileSet.getDirectory();
+
+        for (unsigned int i=0 ; i<fileSet.size() ; i++)
+            {
+            String fname;
+                       if (fileSetDir.size()>0)
+                           {
+                           fname.append(fileSetDir);
+                fname.append("/");
+                }
+            fname.append(fileSet[i]);
+            String fullName = parent.resolve(fname);
+            //trace("ar : %s/%s", fullOut.c_str(), fullName.c_str());
+            if (isNewerThan(fullName, fullOut))
+                doit = true;
+            }
+        //trace("Needs it:%d", doit);
+        if (!doit)
+            {
+            return true;
+            }
+
+        String cmd = "dllwrap";
+        cmd.append(" -o ");
+        cmd.append(fullOut);
+        if (defFileName.size()>0)
+            {
+            cmd.append(" --def ");
+            cmd.append(defFileName);
+            cmd.append(" ");
+            }
+        if (impFileName.size()>0)
+            {
+            cmd.append(" --implib ");
+            cmd.append(impFileName);
+            cmd.append(" ");
+            }
+        for (unsigned int i=0 ; i<fileSet.size() ; i++)
+            {
+            String fname;
+                       if (fileSetDir.size()>0)
+                           {
+                           fname.append(fileSetDir);
+                fname.append("/");
+                }
+            fname.append(fileSet[i]);
+            String fullName = parent.resolve(fname);
+
+            cmd.append(" ");
+            cmd.append(fullName);
+            }
+        cmd.append(" ");
+        cmd.append(libs);
+
+        String outString, errString;
+        if (!executeCommand(cmd.c_str(), "", outString, errString))
+            {
+            error("<sharedlib> problem: %s", errString.c_str());
+            return false;
+            }
+
+        return true;
+        }
+
+    virtual bool parse(Element *elem)
+        {
+        if (!parent.getAttribute(elem, "file", fileName))
+            return false;
+        if (!parent.getAttribute(elem, "import", impFileName))
+            return false;
+        if (!parent.getAttribute(elem, "def", defFileName))
+            return false;
+            
+        std::vector<Element *> children = elem->getChildren();
+        for (unsigned int i=0 ; i<children.size() ; i++)
+            {
+            Element *child = children[i];
+            String tagName = child->getName();
+            if (tagName == "fileset")
+                {
+                if (!parseFileSet(child, parent, fileSet))
+                    return false;
+                }
+            else if (tagName == "libs")
+                {
+                if (!parent.getValue(child, libs))
+                    return false;
+                libs = strip(libs);
+                }
+            }
+        return true;
+        }
+
+private:
+
+    String command;
+    String fileName;
+    String defFileName;
+    String impFileName;
+    FileSet fileSet;
+    String libs;
+
+};
+
+
+/**
+ * Run the "ar" command to archive .o's into a .a
+ */
+class TaskStaticLib : public Task
+{
+public:
+
+    TaskStaticLib(MakeBase &par) : Task(par)
+        {
+               type = TASK_STATICLIB; name = "staticlib";
+               command = "ar crv";
+               }
+
+    virtual ~TaskStaticLib()
+        {}
+
+    virtual bool execute()
+        {
+        //trace("###########HERE %d", fileSet.size());
+        bool doit = false;
+        
+        String fullOut = parent.resolve(fileName);
+        //trace("ar fullout: %s", fullOut.c_str());
+        
+        if (!listFiles(parent, fileSet))
+            return false;
+        String fileSetDir = fileSet.getDirectory();
+
+        for (unsigned int i=0 ; i<fileSet.size() ; i++)
+            {
+            String fname;
+                       if (fileSetDir.size()>0)
+                           {
+                           fname.append(fileSetDir);
+                fname.append("/");
+                }
+            fname.append(fileSet[i]);
+            String fullName = parent.resolve(fname);
+            //trace("ar : %s/%s", fullOut.c_str(), fullName.c_str());
+            if (isNewerThan(fullName, fullOut))
+                doit = true;
+            }
+        //trace("Needs it:%d", doit);
+        if (!doit)
+            {
+            return true;
+            }
+
+        String cmd = command;
+        cmd.append(" ");
+        cmd.append(fullOut);
+        for (unsigned int i=0 ; i<fileSet.size() ; i++)
+            {
+            String fname;
+                       if (fileSetDir.size()>0)
+                           {
+                           fname.append(fileSetDir);
+                fname.append("/");
+                }
+            fname.append(fileSet[i]);
+            String fullName = parent.resolve(fname);
+
+            cmd.append(" ");
+            cmd.append(fullName);
+            }
+
+        String outString, errString;
+        if (!executeCommand(cmd.c_str(), "", outString, errString))
+            {
+            error("<staticlib> problem: %s", errString.c_str());
+            return false;
+            }
+
+        return true;
+        }
+
+    virtual bool parse(Element *elem)
+        {
+        if (!parent.getAttribute(elem, "file", fileName))
+            return false;
+            
+        std::vector<Element *> children = elem->getChildren();
+        for (unsigned int i=0 ; i<children.size() ; i++)
+            {
+            Element *child = children[i];
+            String tagName = child->getName();
+            if (tagName == "fileset")
+                {
+                if (!parseFileSet(child, parent, fileSet))
+                    return false;
+                }
+            }
+        return true;
+        }
+
+private:
+
+    String command;
+    String fileName;
+    FileSet fileSet;
+
+};
+
+
 /**
  * Strip an executable
  */
@@ -6882,9 +7039,7 @@ Task *Task::createTask(Element *elem)
     String tagName = elem->getName();
     //trace("task:%s", tagName.c_str());
     Task *task = NULL;
-    if (tagName == "ar")
-        task = new TaskAr(parent);
-    else if (tagName == "cc")
+    if (tagName == "cc")
         task = new TaskCC(parent);
     else if (tagName == "copy")
         task = new TaskCopy(parent);
@@ -6906,6 +7061,10 @@ Task *Task::createTask(Element *elem)
         task = new TaskRanlib(parent);
     else if (tagName == "rc")
         task = new TaskRC(parent);
+    else if (tagName == "sharedlib")
+        task = new TaskSharedLib(parent);
+    else if (tagName == "staticlib")
+        task = new TaskStaticLib(parent);
     else if (tagName == "strip")
         task = new TaskStrip(parent);
     else if (tagName == "tstamp")
@@ -7820,8 +7979,8 @@ bool Make::run(const String &target)
 {
     status("##################################");
     status("#   BuildTool");
-    status("#   version 0.3");
-    status("#   16 Nov 06");
+    status("#   version 0.4");
+    status("#   17 Nov 06");
     status("##################################");
     specifiedTarget = target;
     if (!run())