Code

get it to work on linux
authorishmal <ishmal@users.sourceforge.net>
Tue, 28 Nov 2006 20:49:37 +0000 (20:49 +0000)
committerishmal <ishmal@users.sourceforge.net>
Tue, 28 Nov 2006 20:49:37 +0000 (20:49 +0000)
build.xml
buildtool.cpp

index 5d2ac8ba0aeea15d1d18f2a0caf4dcebd961df4d..11fe01e2239e16d532c7f2c626d4ea2640a88d54 100644 (file)
--- a/build.xml
+++ b/build.xml
     <!-- Create the build directory structure used by compile -->
     <mkdir dir="${build}"/>
     <mkdir dir="${dist}"/>
+    <copy file="${src}/helper/sp-marshal.h.mingw"
+          tofile="${src}/helper/sp-marshal.h"/>
+    <copy file="${src}/helper/sp-marshal.cpp.mingw"
+          tofile="${src}/helper/sp-marshal.cpp"/>
+    <makefile file="inkscape_version.h">
+    #define INKSCAPE_VERSION "${version}+devel"
+    </makefile>
     <makefile file="config.h">
         #ifndef _CONFIG_H_
         #define _CONFIG_H_
@@ -80,7 +87,8 @@
   <target name="compile" depends="init"
         description="compile the source " >
     <!-- Compile from source to build -->
-    <cc cc="gcc" cxx="g++" destdir="${build}/obj">
+    <cc cc="i686-pc-mingw32-gcc" cxx="i686-pc-mingw32-g++"
+             destdir="${build}/obj">
            <fileset dir="${src}">
             <!-- THINGS TO EXCLUDE -->
                <exclude name="ast/.*"/>
                <exclude name="removeoverlap/remove_rectangle_overlap-test.h"/>
            </fileset>
         <flags>
-            -Wall -g -O3
-                       -mms-bitfields
+            -Wall -O3
+            -mms-bitfields
         </flags>
         <defines>
             -DVERSION=\"${version}\"
   </target>
   
   <target name="lib" depends="compile">
-    <staticlib file="${build}/libinkscape.a">
+    <staticlib command="i686-pc-mingw32-ar crsv"
+           file="${build}/libinkscape.a">
           <fileset dir="${build}/obj">
               <exclude name="main,o"/>
               <exclude name="winmain,o"/>
   </target>
 
   <target name="link" depends="lib">
-    <rc command="windres -o
+    <rc command="i686-pc-mingw32-windres
            file="${src}/inkscape.rc"
            out="${build}/inkres.o">
                <flags>
                --include-dir=${src}
                </flags>
        </rc>
-    <link command="g++" out="${build}/inkscape.exe"
+    <link command="i686-pc-mingw32-g++" out="${build}/inkscape.exe"
               strip="true" symfile="${build}/inkscape.dbg"
+              stripcommand="i686-pc-mingw32-strip"
+              objcopycommand="i686-pc-mingw32-objcopy"
               >
        <flags>
        </flags>
     <copy todir="${dist}/lib"> <fileset dir="${gtk}/lib/gtk-2.0"/> </copy>
     <copy todir="${dist}/lib"> <fileset dir="${gtk}/lib/glib-2.0"/> </copy>
     <copy todir="${dist}/lib"> <fileset dir="${gtk}/lib/locale"/> </copy>
-    <copy todir="${dist}/lib"> <fileset dir="${gtk}/lib/pango"/> </copy>
     <copy todir="${dist}">
            <fileset dir="share">
                  <exclude name=".*\.am"/>
index bfeea1b7ae25301523b67adb995ccf2ecbd1c644..ef80f872aaed951b61d18fd8621350a4832eafdf 100644 (file)
 /**
  * To use this file, compile with:
  * <pre>
- * g++ -O3 buildtool.cpp -o build.exe
+ * g++ -O3 buildtool.cpp -o btool.exe
  * (or whatever your compiler might be) 
  * Then
- * build
+ * btool
  * or 
- * build {target}
+ * btool {target}
  */  
 
 
 #endif
 
 
+#include <errno.h>
+
+
+
 
 namespace buildtool
 {
@@ -3505,15 +3509,15 @@ bool MakeBase::executeCommand(const String &command,
             }
         errnum = pclose(f);
         }
-       outbuf = s;
-       if (errnum < 0)
-           {
-           error("exec of command '%s' failed : %s",
+    outbuf = s;
+    if (errnum != 0)
+        {
+        error("exec of command '%s' failed : %s",
                     command.c_str(), strerror(errno));
-           return false;
-           }
-       else
-           return true;
+        return false;
+        }
+    else
+        return true;
 
 #endif
 } 
@@ -3583,6 +3587,12 @@ bool MakeBase::listFiles(const String &baseDir,
 
     std::vector<String> subdirs;
     DIR *dir = opendir(dirNative.c_str());
+    if (!dir)
+        {
+        error("Could not open directory %s : %s",
+              dirNative.c_str(), strerror(errno));
+        return false;
+        }
     while (true)
         {
         struct dirent *de = readdir(dir);
@@ -3937,9 +3947,14 @@ bool MakeBase::createDirectory(const String &dirname)
         }
         
     //## 3: now make
+#ifdef __WIN32__
     if (mkdir(cnative)<0)
+#else
+    if (mkdir(cnative, S_IRWXU | S_IRWXG | S_IRWXO)<0)
+#endif
         {
-        error("cannot make directory '%s'", cnative);
+        error("cannot make directory '%s' : %s",
+                 cnative, strerror(errno));
         return false;
         }
         
@@ -6348,6 +6363,8 @@ public:
                type = TASK_LINK; name = "link";
                command = "g++";
                doStrip = false;
+                stripCommand = "strip";
+                objcopyCommand = "objcopy";
                }
 
     virtual ~TaskLink()
@@ -6403,7 +6420,8 @@ public:
         if (symFileName.size()>0)
             {
             String symFullName = parent.resolve(symFileName);
-            cmd = "objcopy --only-keep-debug ";
+            cmd = objcopyCommand;
+            cmd.append(" --only-keep-debug ");
             cmd.append(getNativePath(fullTarget));
             cmd.append(" ");
             cmd.append(getNativePath(symFullName));
@@ -6416,7 +6434,8 @@ public:
             
         if (doStrip)
             {
-            cmd = "strip ";
+            cmd = stripCommand;
+            cmd.append(" ");
             cmd.append(getNativePath(fullTarget));
             if (!executeCommand(cmd, "", outbuf, errbuf))
                {
@@ -6435,6 +6454,14 @@ public:
             return false;
         if (s.size()>0)
             command = s;
+        if (!parent.getAttribute(elem, "objcopycommand", s))
+            return false;
+        if (s.size()>0)
+            objcopyCommand = s;
+        if (!parent.getAttribute(elem, "stripcommand", s))
+            return false;
+        if (s.size()>0)
+            stripCommand = s;
         if (!parent.getAttribute(elem, "out", fileName))
             return false;
         if (!parent.getAttribute(elem, "strip", s))
@@ -6479,6 +6506,8 @@ private:
     FileSet fileSet;
     bool    doStrip;
     String  symFileName;
+    String  stripCommand;
+    String  objcopyCommand;
 
 };
 
@@ -6680,9 +6709,13 @@ public:
 
     virtual bool parse(Element *elem)
         {
+        String s;
+        if (!parent.getAttribute(elem, "command", s))
+            return false;
+        if (s.size()>0)
+            command = s;
         if (!parent.getAttribute(elem, "todir", toDirName))
             return false;
-        String s;
         if (!parent.getAttribute(elem, "owndir", s))
             return false;
         if (!getBool(s, owndir))
@@ -6723,7 +6756,10 @@ class TaskRanlib : public Task
 public:
 
     TaskRanlib(MakeBase &par) : Task(par)
-        { type = TASK_RANLIB; name = "ranlib"; }
+        {
+        type = TASK_RANLIB; name = "ranlib";
+        command = "ranlib";
+        }
 
     virtual ~TaskRanlib()
         {}
@@ -6732,7 +6768,8 @@ public:
         {
         String fullName = parent.resolve(fileName);
         //trace("fullDir:%s", fullDir.c_str());
-        String cmd = "ranlib ";
+        String cmd = command;
+        cmd.append(" ");
         cmd.append(fullName);
         String outbuf, errbuf;
         if (!executeCommand(cmd, "", outbuf, errbuf))
@@ -6742,6 +6779,11 @@ public:
 
     virtual bool parse(Element *elem)
         {
+        String s;
+        if (!parent.getAttribute(elem, "command", s))
+            return false;
+        if (s.size()>0)
+           command = s;
         if (!parent.getAttribute(elem, "file", fileName))
             return false;
         if (fileName.size() == 0)
@@ -6755,6 +6797,7 @@ public:
 private:
 
     String fileName;
+    String command;
 };
 
 
@@ -6769,7 +6812,7 @@ public:
     TaskRC(MakeBase &par) : Task(par)
         {
                type = TASK_RC; name = "rc";
-               command = "windres -o";
+               command = "windres";
                }
 
     virtual ~TaskRC()
@@ -6782,7 +6825,7 @@ public:
         if (!isNewerThan(fullFile, fullOut))
             return true;
         String cmd = command;
-        cmd.append(" ");
+        cmd.append(" -o ");
         cmd.append(fullOut);
         cmd.append(" ");
         cmd.append(flags);
@@ -7040,6 +7083,11 @@ public:
 
     virtual bool parse(Element *elem)
         {
+        String s;
+        if (!parent.getAttribute(elem, "command", s))
+            return false;
+        if (s.size()>0)
+            command = s;
         if (!parent.getAttribute(elem, "file", fileName))
             return false;
             
@@ -7426,7 +7474,7 @@ public:
      *
      */
     virtual String version()
-        { return "BuildTool v0.3, 2006 Bob Jamison"; }
+        { return "BuildTool v0.6, 2006 Bob Jamison"; }
 
     /**
      * Overload a <property>
@@ -8109,17 +8157,15 @@ bool Make::run()
  */
 bool Make::run(const String &target)
 {
-    status("##################################");
-    status("#   BuildTool");
-    status("#   version 0.5");
-    status("#   21 Nov 06");
-    status("##################################");
+    status("####################################################");
+    status("#   %s", version().c_str());
+    status("####################################################");
     specifiedTarget = target;
     if (!run())
         return false;
-    status("##################################");
-    status("#   BuildTool Completed");
-    status("##################################");
+    status("####################################################");
+    status("#   BuildTool Completed ");
+    status("####################################################");
     return true;
 }