[gnome-ostree] make: Add --skip option



commit a6401a0775b41ee4480c0ccc2e5a7627148971e7
Author: Colin Walters <walters verbum org>
Date:   Wed Mar 13 22:31:52 2013 -0400

    make: Add --skip option
    
    Mainly so I can do:
    
    $ ostbuild make --skip builddisks resolve fetchAll=true

 src/js/argparse.js      |   13 ++++++++++---
 src/js/builtins/make.js |    5 ++++-
 src/js/task.js          |   11 +++++++++--
 3 files changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/src/js/argparse.js b/src/js/argparse.js
index 051ba95..f94418e 100644
--- a/src/js/argparse.js
+++ b/src/js/argparse.js
@@ -117,6 +117,8 @@ const ArgumentParser = new Lang.Class({
                result[opts._varName] = null;
            } else if (opts.action == 'storeTrue') {
                result[opts._varName] = false;
+           } else if (opts.action == 'append') {
+               result[opts._varName] = [];
            }
        }
        for (let name in this._argNames) {
@@ -141,14 +143,19 @@ const ArgumentParser = new Lang.Class({
                
                if (!opts) this._failed();
 
-               if (opts.action == 'store') {
+               if (opts.action == 'store' || opts.action == 'append') {
+                   let val;
                    if (equalsIdx == -1) {
                        if (i == argv.length - 1) this._failed();
-                       result[opts._varName] = argv[i+1];
+                       val = argv[i+1];
                        i++;
                    } else {
-                       result[opts._varName] = arg.substr(equalsIdx+1);
+                       val = arg.substr(equalsIdx+1);
                    }
+                   if (opts.action == 'store')
+                       result[opts._varName] = val;
+                   else
+                       result[opts._varName].push(val);
                } else if (opts.action == 'storeTrue') {
                    result[opts._varName] = true;
                }
diff --git a/src/js/builtins/make.js b/src/js/builtins/make.js
index 3f91b2f..df6999d 100644
--- a/src/js/builtins/make.js
+++ b/src/js/builtins/make.js
@@ -42,6 +42,8 @@ const Make = new Lang.Class({
        this.parent();
        this.parser.addArgument(['-n', '--only'], { action: 'storeTrue',
                                                    help: "Don't process tasks after this" });
+       this.parser.addArgument(['-x', '--skip'], { action: 'append',
+                                                   help: "Don't process tasks after this" });
        this.parser.addArgument('taskname');
        this.parser.addArgument('parameters', { nargs: '*' });
     },
@@ -53,7 +55,8 @@ const Make = new Lang.Class({
        this._oneOnly = args.only;
        let taskmaster = new Task.TaskMaster(this.workdir.get_child('tasks'),
                                             { onEmpty: Lang.bind(this, this._onTasksComplete),
-                                              processAfter: !args.only });
+                                              processAfter: !args.only,
+                                              skip: args.skip });
        this._taskmaster = taskmaster;
        taskmaster.connect('task-executing', Lang.bind(this, this._onTaskExecuting));
        taskmaster.connect('task-complete', Lang.bind(this, this._onTaskCompleted));
diff --git a/src/js/task.js b/src/js/task.js
index 2106203..54d1ad2 100644
--- a/src/js/task.js
+++ b/src/js/task.js
@@ -99,9 +99,13 @@ const TaskMaster = new Lang.Class({
 
     _init: function(path, params) {
         params = Params.parse(params, { onEmpty: null, 
-                                       processAfter: true });
+                                       processAfter: true,
+                                       skip: [] });
        this.path = path;
        this._processAfter = params.processAfter;
+       this._skipTasks = {};
+       for (let i = 0; i < params.skip.length; i++)
+           this._skipTasks[params.skip[i]] = true;
        this.maxConcurrent = GLib.get_num_processors();
        this._onEmpty = params.onEmpty;
        this.cancellable = null;
@@ -223,7 +227,10 @@ const TaskMaster = new Lang.Class({
            if (changed) {
                let tasksAfter = this._taskset.getTasksAfter(task.name);
                for (let i = 0; i < tasksAfter.length; i++) {
-                   this._pushTaskDef(tasksAfter[i], {});
+                   let after = tasksAfter[i];
+                   let name = after.prototype.TaskName;
+                   if (!this._skipTasks[name])
+                       this._pushTaskDef(tasksAfter[i], {});
                }
            }
        }


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