[gnome-ostree] build: Delete static libraries



commit c3a6bf04461ce3a0a7e69d7fdc8dc8f6556ab8c4
Author: Colin Walters <walters verbum org>
Date:   Fri Mar 8 15:09:05 2013 -0500

    build: Delete static libraries
    
    We were installing libmozjs.a which was 118MB+!
    
    While we're here, change the walker to support traversing only to a
    certain depth - this is cleaner for just looking at /usr/lib.

 src/js/fileutil.js         |   23 ++++++++++++++++-------
 src/js/tasks/task-build.js |   13 +++++++++++--
 2 files changed, 27 insertions(+), 9 deletions(-)
---
diff --git a/src/js/fileutil.js b/src/js/fileutil.js
index fee9ecc..81510bd 100644
--- a/src/js/fileutil.js
+++ b/src/js/fileutil.js
@@ -20,19 +20,26 @@ const Gio = imports.gi.Gio;
 
 const Params = imports.params;
 
-function walkDirInternal(dir, matchParams, callback, cancellable, queryStr) {
+function walkDirInternal(dir, matchParams, callback, cancellable, queryStr, depth) {
     let denum = dir.enumerate_children(queryStr, Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
                                       cancellable);
     let info;
     let subdirs = [];
+
+    if (depth > 0) {
+       depth -= 1;
+    }
+
     while ((info = denum.next_file(cancellable)) != null) {
        let name = info.get_name();
        let child = dir.get_child(name);
        let ftype = info.get_file_type();
        
-       if (ftype == Gio.FileType.DIRECTORY) {
-           subdirs.push(child);
-           continue;
+       if (depth != 0) {
+           if (ftype == Gio.FileType.DIRECTORY) {
+               subdirs.push(child);
+               continue;
+           }
        }
 
        if (matchParams.nameRegex && matchParams.nameRegex.exec(name) === null)
@@ -47,16 +54,18 @@ function walkDirInternal(dir, matchParams, callback, cancellable, queryStr) {
     denum.close(cancellable);
 
     for (let i = 0; i < subdirs.length; i++) {
-       walkDirInternal(subdirs[i], matchParams, callback, cancellable, queryStr);
+       walkDirInternal(subdirs[i], matchParams, callback, cancellable, queryStr, depth);
     }
 }
 
 function walkDir(dir, matchParams, callback, cancellable) {
     matchParams = Params.parse(matchParams, { nameRegex: null,
                                              fileType: null,
-                                             contentType: null });
+                                             contentType: null,
+                                             depth: -1 });
     let queryStr = 'standard::name,standard::type,unix::mode';
     if (matchParams.contentType)
        queryStr += ',standard::fast-content-type';
-    walkDirInternal(dir, matchParams, callback, cancellable, queryStr);
+    let depth = matchParams.depth;
+    walkDirInternal(dir, matchParams, callback, cancellable, queryStr, depth);
 }
diff --git a/src/js/tasks/task-build.js b/src/js/tasks/task-build.js
index fd82fcb..cccc252 100644
--- a/src/js/tasks/task-build.js
+++ b/src/js/tasks/task-build.js
@@ -351,14 +351,23 @@ const TaskBuild = new Lang.Class({
                             }), cancellable);
        }
 
-       // Move symbolic links for shared libraries to devel
        let libdir = buildResultDir.resolve_relative_path('usr/lib');
+
        if (libdir.query_exists(null)) {
+           // Move symbolic links for shared libraries to devel
            FileUtil.walkDir(libdir, { nameRegex: /\.so$/,
-                                      fileType: Gio.FileType.SYMBOLIC_LINK },
+                                      fileType: Gio.FileType.SYMBOLIC_LINK,
+                                      depth: 1 },
                             Lang.bind(this, function(filePath, cancellable) {
                                 this._installAndUnlink(buildResultDir, filePath, develPath, cancellable);
                             }), cancellable);
+           // Just delete static libraries.  No one should use them.
+           FileUtil.walkDir(libdir, { nameRegex: /\.a$/,
+                                      fileType: Gio.FileType.REGULAR,
+                                      depth: 1 },
+                            Lang.bind(this, function(filePath, cancellable) {
+                                GSystem.file_unlink(filePath, cancellable);
+                            }), cancellable);
        }
 
        for (let i = 0; i < DEVEL_DIRS.length; i++) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]