Ubuntu Pastebin

Paste from asac at Wed, 27 Jan 2016 11:32:54 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
git diff 2483c3fa520a09c0f3071b2a1a4aadc47c1551cf snapcraft/commands/build.py snapcraft/common.py
diff --git a/snapcraft/commands/build.py b/snapcraft/commands/build.py
index fed5828..a82a7e6 100644
--- a/snapcraft/commands/build.py
+++ b/snapcraft/commands/build.py
@@ -23,6 +23,9 @@ Usage:
   build [options] [PART ...]
 
 Options:
+  -j [<threads>]        multi threaded build for plugins that support it;
+                        use 0 for cpu-count+1 [default: 0]
+  -V                    verbose built for plugins that support it.
   -h --help             show this help message and exit.
 
 """
@@ -30,10 +33,14 @@ Options:
 from docopt import docopt
 
 from snapcraft import lifecycle
+from snapcraft import common
 
 
 def main(argv=None):
     argv = argv if argv else []
     args = docopt(__doc__, argv=argv)
 
+    common.set_build_threads(int(args['-j']))
+    common.set_verbose(args['-V'])
+
     lifecycle.execute('build', args['PART'])
diff --git a/snapcraft/common.py b/snapcraft/common.py
index fcbeb9d..63a3ee4 100644
--- a/snapcraft/common.py
+++ b/snapcraft/common.py
@@ -20,6 +20,7 @@ import os
 import subprocess
 import tempfile
 import urllib
+import multiprocessing
 
 
 SNAPCRAFT_FILES = ['snapcraft.yaml', 'parts', 'stage', 'snap']
@@ -30,7 +31,8 @@ _DEFAULT_SCHEMADIR = '/usr/share/snapcraft/schema'
 _schemadir = _DEFAULT_SCHEMADIR
 _arch = None
 _arch_triplet = None
-
+j_count = 0
+verbose = False
 env = []
 
 
@@ -117,6 +130,26 @@ def reset_env():
     env = []
 
 
+def set_build_threads(j):
+    global j_count
+    j_count = j
+
+
+def get_build_threads():
+    if j_count <= 0:
+        return multiprocessing.cpu_count() + 1
+    return j_count
+
+
+def set_verbose(v):
+    global verbose
+    verbose = v
+
+
+def get_verbose():
+    return verbose
+
+
 def replace_in_file(directory, file_pattern, search_pattern, replacement):
     """Searches and replaces patterns that match a file pattern.
     :param str directory: The directory to look for files.
Download as text