diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-02-01 15:03:41 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-02-06 13:12:59 +0000 |
commit | b34fd60d8fd6750663748c74fed82dd16a823ad4 (patch) | |
tree | b05d73f4dfe874d3f24419c104df8c85ded49d8f /meta/classes | |
parent | e45db24bbeacfe4754638eafa9682258b994307c (diff) | |
download | poky-b34fd60d8fd6750663748c74fed82dd16a823ad4.tar.gz |
package: Process package stripping in parallel
(From OE-Core rev: 981fed49ee80560fb067b3f47aeada1fdee792ca)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/package.bbclass | 58 |
1 files changed, 13 insertions, 45 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index d93783f83b..61d90cc12e 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass | |||
@@ -309,49 +309,6 @@ def copydebugsources(debugsrcdir, d): | |||
309 | if os.path.exists(p) and not os.listdir(p): | 309 | if os.path.exists(p) and not os.listdir(p): |
310 | os.rmdir(p) | 310 | os.rmdir(p) |
311 | 311 | ||
312 | def runstrip(file, elftype, d): | ||
313 | # Function to strip a single file, called from split_and_strip_files below | ||
314 | # A working 'file' (one which works on the target architecture) | ||
315 | # | ||
316 | # The elftype is a bit pattern (explained in split_and_strip_files) to tell | ||
317 | # us what type of file we're processing... | ||
318 | # 4 - executable | ||
319 | # 8 - shared library | ||
320 | |||
321 | import commands, stat, subprocess | ||
322 | |||
323 | strip = d.getVar("STRIP", True) | ||
324 | |||
325 | newmode = None | ||
326 | if not os.access(file, os.W_OK) or os.access(file, os.R_OK): | ||
327 | origmode = os.stat(file)[stat.ST_MODE] | ||
328 | newmode = origmode | stat.S_IWRITE | stat.S_IREAD | ||
329 | os.chmod(file, newmode) | ||
330 | |||
331 | extraflags = "" | ||
332 | |||
333 | # .so and shared library | ||
334 | if elftype & 16: | ||
335 | extraflags = "--strip-debug --remove-section=.comment --remove-section=.note --preserve-dates" | ||
336 | elif ".so" in file and elftype & 8: | ||
337 | extraflags = "--remove-section=.comment --remove-section=.note --strip-unneeded" | ||
338 | # shared or executable: | ||
339 | elif elftype & 8 or elftype & 4: | ||
340 | extraflags = "--remove-section=.comment --remove-section=.note" | ||
341 | |||
342 | stripcmd = "'%s' %s '%s'" % (strip, extraflags, file) | ||
343 | bb.debug(1, "runstrip: %s" % stripcmd) | ||
344 | |||
345 | ret = subprocess.call(stripcmd, shell=True) | ||
346 | |||
347 | if newmode: | ||
348 | os.chmod(file, origmode) | ||
349 | |||
350 | if ret: | ||
351 | bb.error("runstrip: '%s' strip command failed" % stripcmd) | ||
352 | |||
353 | return 0 | ||
354 | |||
355 | # | 312 | # |
356 | # Package data handling routines | 313 | # Package data handling routines |
357 | # | 314 | # |
@@ -902,13 +859,24 @@ python split_and_strip_files () { | |||
902 | # Now lets go back over things and strip them | 859 | # Now lets go back over things and strip them |
903 | # | 860 | # |
904 | if (d.getVar('INHIBIT_PACKAGE_STRIP', True) != '1'): | 861 | if (d.getVar('INHIBIT_PACKAGE_STRIP', True) != '1'): |
862 | strip = d.getVar("STRIP", True) | ||
863 | sfiles = [] | ||
905 | for file in file_list: | 864 | for file in file_list: |
906 | if file_list[file].startswith("ELF: "): | 865 | if file_list[file].startswith("ELF: "): |
907 | elf_file = int(file_list[file][5:]) | 866 | elf_file = int(file_list[file][5:]) |
908 | #bb.note("Strip %s" % file) | 867 | #bb.note("Strip %s" % file) |
909 | runstrip(file, elf_file, d) | 868 | sfiles.append((file, elf_file, strip)) |
910 | for f in kernmods: | 869 | for f in kernmods: |
911 | runstrip(f, 16, d) | 870 | sfiles.append((f, 16, strip)) |
871 | |||
872 | |||
873 | import multiprocessing | ||
874 | nproc = multiprocessing.cpu_count() | ||
875 | pool = multiprocessing.Pool(nproc) | ||
876 | processed = pool.imap(oe.package.runstrip, sfiles) | ||
877 | pool.close() | ||
878 | pool.join() | ||
879 | |||
912 | # | 880 | # |
913 | # End of strip | 881 | # End of strip |
914 | # | 882 | # |