diff mbox

[13/20] Fix strip for mingw and darwin

Message ID 1407352611-7652-13-git-send-email-diorcet.yann@gmail.com
State New
Delegated to: Esben Haabendal
Headers show

Commit Message

Yann Diorcet Aug. 6, 2014, 7:16 p.m. UTC
---
 classes/core.oeclass | 37 ++++++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 13 deletions(-)
diff mbox

Patch

diff --git a/classes/core.oeclass b/classes/core.oeclass
index 17d7d92..244182c 100644
--- a/classes/core.oeclass
+++ b/classes/core.oeclass
@@ -130,7 +130,8 @@  def do_install_strip(d):
                file = os.path.join(root, f)
                if os.path.islink(file) or os.path.isdir(file):
                    continue
-               if isexec(file) or ".so" in os.path.basename(file):
+               basename = os.path.basename(file)
+               if isexec(file) or (".so" in basename) or (".dll" in basename) or (".dylib" in basename):
                    runstrip(file, d)
 
 def runstrip(file, d):
@@ -152,7 +153,7 @@  def runstrip(file, d):
         bb.error("runstrip() unable to determine file type: %s"%(file))
         return
 
-    if "not stripped" not in filetype:
+    if "stripped" in filetype and not "not stripped" in filetype:
         print "runstrip() skip %s"%(file)
         return
     target_elf = d.getVar('TARGET_ELF', True)
@@ -197,10 +198,16 @@  def runstrip(file, d):
         os.chmod(file, newmode)
 
     extraflags = ""
-    if ".so" in file and "shared" in filetype:
-        extraflags = "--remove-section=.comment --remove-section=.note --strip-unneeded"
+    if (".so" in file) or (".dll" in file) or (".dylib" in file) and "shared" in filetype:
+        if d.getVar('TARGET_OS', True) == "darwin":
+            extraflags = "-S -x -X"
+        else:
+            extraflags = "--remove-section=.comment --remove-section=.note --strip-unneeded"
     elif "shared" in filetype or "executable" in filetype:
-        extraflags = "--remove-section=.comment --remove-section=.note"
+        if d.getVar('TARGET_OS', True) == "darwin":
+            extraflags = "-S -x -X"
+        else:
+            extraflags = "--remove-section=.comment --remove-section=.note"
 
     oelite.util.makedirs(os.path.join(os.path.dirname(file), ".debug"))
     debugfile=os.path.join(os.path.dirname(file), ".debug", os.path.basename(file))
@@ -209,21 +216,25 @@  def runstrip(file, d):
     objcpcmd = "'%s' --only-keep-debug '%s' '%s'"   % (objcopy, file, debugfile)
     objlncmd = "'%s' --add-gnu-debuglink='%s' '%s'" % (objcopy, debugfile, file)
 
-    print "runstrip() %s"%(objcpcmd)
+    if d.getVar('TARGET_OS', True) <> "darwin":
+        print "runstrip() %s"%(objcpcmd)
     print "runstrip() %s"%(stripcmd)
-    print "runstrip() %s"%(objlncmd)
+    if d.getVar('TARGET_OS', True) <> "darwin":
+        print "runstrip() %s"%(objlncmd)
 
-    ret, result = commands.getstatusoutput("%s%s" % (pathprefix, objcpcmd))
-    if ret:
-        bb.note("runstrip() '%s' %s" % (objcpcmd,result))
+    if d.getVar('TARGET_OS', True) <> "darwin":
+        ret, result = commands.getstatusoutput("%s%s" % (pathprefix, objcpcmd))
+        if ret:
+            bb.note("runstrip() '%s' %s" % (objcpcmd,result))
 
     ret, result = commands.getstatusoutput("%s%s" % (pathprefix, stripcmd))
     if ret:
         bb.note("runstrip() '%s' %s" % (stripcmd,result))
 
-    ret, result = commands.getstatusoutput("%s%s" % (pathprefix, objlncmd))
-    if ret:
-        bb.note("runstrip() '%s' %s" % (objlncmd,result))
+    if d.getVar('TARGET_OS', True) <> "darwin":
+        ret, result = commands.getstatusoutput("%s%s" % (pathprefix, objlncmd))
+        if ret:
+            bb.note("runstrip() '%s' %s" % (objlncmd,result))
 
     if newmode:
         os.chmod(file, origmode)