Code

Add "strip" to <link> so you can do it if linking is successful
authorishmal <ishmal@users.sourceforge.net>
Fri, 24 Nov 2006 19:28:16 +0000 (19:28 +0000)
committerishmal <ishmal@users.sourceforge.net>
Fri, 24 Nov 2006 19:28:16 +0000 (19:28 +0000)
build.xml
buildtool.cpp

index 66ac63b92318b750a68fdf81cdd283b024ce0a5a..f28a8f24f692920852c20c5cabe8815facbe9664 100644 (file)
--- a/build.xml
+++ b/build.xml
            -lgc -mwindows -lws2_32 -lintl -lm
           </libs>
        </link>
-       <!--<strip file="${build}/inkscape.exe"/>-->
   </target>
 
   <target name="dist" depends="link,i18n"
index 8d05b6bcdb26b30d980fbc2d67b17dace23f750d..bfeea1b7ae25301523b67adb995ccf2ecbd1c644 100644 (file)
@@ -3326,6 +3326,9 @@ bool MakeBase::executeCommand(const String &command,
     status("============ cmd ============\n%s\n=============================",
                    command.c_str());
 
+    outbuf.clear();
+    errbuf.clear();
+    
 #ifdef __WIN32__
 
     /*
@@ -6344,6 +6347,7 @@ public:
         {
                type = TASK_LINK; name = "link";
                command = "g++";
+               doStrip = false;
                }
 
     virtual ~TaskLink()
@@ -6389,12 +6393,38 @@ public:
         //trace("LINK cmd:%s", cmd.c_str());
 
 
-        String outString, errString;
-        if (!executeCommand(cmd.c_str(), "", outString, errString))
+        String outbuf, errbuf;
+        if (!executeCommand(cmd.c_str(), "", outbuf, errbuf))
             {
-            error("LINK problem: %s", errString.c_str());
+            error("LINK problem: %s", errbuf.c_str());
             return false;
             }
+
+        if (symFileName.size()>0)
+            {
+            String symFullName = parent.resolve(symFileName);
+            cmd = "objcopy --only-keep-debug ";
+            cmd.append(getNativePath(fullTarget));
+            cmd.append(" ");
+            cmd.append(getNativePath(symFullName));
+            if (!executeCommand(cmd, "", outbuf, errbuf))
+                {
+                error("<strip> symbol file failed : %s", errbuf.c_str());
+                return false;
+                }
+            }
+            
+        if (doStrip)
+            {
+            cmd = "strip ";
+            cmd.append(getNativePath(fullTarget));
+            if (!executeCommand(cmd, "", outbuf, errbuf))
+               {
+               error("<strip> failed : %s", errbuf.c_str());
+               return false;
+               }
+            }
+
         return true;
         }
 
@@ -6407,6 +6437,12 @@ public:
             command = s;
         if (!parent.getAttribute(elem, "out", fileName))
             return false;
+        if (!parent.getAttribute(elem, "strip", s))
+            return false;
+        if (!getBool(s, doStrip))
+            return false;
+        if (!parent.getAttribute(elem, "symfile", symFileName))
+            return false;
             
         std::vector<Element *> children = elem->getChildren();
         for (unsigned int i=0 ; i<children.size() ; i++)
@@ -6436,11 +6472,13 @@ public:
 
 private:
 
-    String command;
-    String fileName;
-    String flags;
-    String libs;
+    String  command;
+    String  fileName;
+    String  flags;
+    String  libs;
     FileSet fileSet;
+    bool    doStrip;
+    String  symFileName;
 
 };
 
@@ -7045,12 +7083,30 @@ public:
         {
         String fullName = parent.resolve(fileName);
         //trace("fullDir:%s", fullDir.c_str());
-        String cmd = "strip ";
-        cmd.append(fullName);
-
+        String cmd;
         String outbuf, errbuf;
+
+        if (symFileName.size()>0)
+            {
+            String symFullName = parent.resolve(symFileName);
+            cmd = "objcopy --only-keep-debug ";
+            cmd.append(getNativePath(fullName));
+            cmd.append(" ");
+            cmd.append(getNativePath(symFullName));
+            if (!executeCommand(cmd, "", outbuf, errbuf))
+                {
+                error("<strip> symbol file failed : %s", errbuf.c_str());
+                return false;
+                }
+            }
+            
+        cmd = "strip ";
+        cmd.append(getNativePath(fullName));
         if (!executeCommand(cmd, "", outbuf, errbuf))
+            {
+            error("<strip> failed : %s", errbuf.c_str());
             return false;
+            }
         return true;
         }
 
@@ -7058,9 +7114,11 @@ public:
         {
         if (!parent.getAttribute(elem, "file", fileName))
             return false;
+        if (!parent.getAttribute(elem, "symfile", symFileName))
+            return false;
         if (fileName.size() == 0)
             {
-            error("<strip> requires 'file=\"fileNname\"' attribute");
+            error("<strip> requires 'file=\"fileName\"' attribute");
             return false;
             }
         return true;
@@ -7069,6 +7127,7 @@ public:
 private:
 
     String fileName;
+    String symFileName;
 };