[zorg] r283844 - Re-factored to take the jobs property every time a build step gets created; added support for multiple jobs opt formats.
Galina Kistanova via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 10 18:57:41 PDT 2016
Author: gkistanova
Date: Mon Oct 10 20:57:41 2016
New Revision: 283844
URL: http://llvm.org/viewvc/llvm-project?rev=283844&view=rev
Log:
Re-factored to take the jobs property every time a build step gets created; added support for multiple jobs opt formats.
Modified:
zorg/trunk/zorg/buildbot/commands/NinjaCommand.py
Modified: zorg/trunk/zorg/buildbot/commands/NinjaCommand.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/zorg/buildbot/commands/NinjaCommand.py?rev=283844&r1=283843&r2=283844&view=diff
==============================================================================
--- zorg/trunk/zorg/buildbot/commands/NinjaCommand.py (original)
+++ zorg/trunk/zorg/buildbot/commands/NinjaCommand.py Mon Oct 10 20:57:41 2016
@@ -1,3 +1,5 @@
+import re
+
from buildbot.process.properties import WithProperties
from buildbot.steps.shell import WarningCountingShellCommand
@@ -26,32 +28,42 @@ class NinjaCommand(WarningCountingShellC
self.prefixCommand = prefixCommand
self.targets = targets
+ command = []
+ if prefixCommand:
+ command += prefixCommand
+
+ command += ["ninja"]
+
if options is None:
self.options = list()
else:
self.options = list(options)
- if kwargs.get('jobs', None):
- self.options += ["-j", kwargs['jobs']]
- else:
- self.options += [
- WithProperties("%(jobs:+-j)s"),
- WithProperties("%(jobs:-)s"),
- ]
+ j_opt = re.compile(r'^-j$|^-j\d+$')
+ l_opt = re.compile(r'^-l$|^-l\d+(\.(\d+)?)?$')
- if kwargs.get('loadaverage', None):
- self.options += ["-l", kwargs['loadaverage']]
- else:
- self.options += [
- WithProperties("%(loadaverage:+-l)s"),
- WithProperties("%(loadaverage:-)s"),
- ]
-
- command = []
- if prefixCommand:
- command += prefixCommand
-
- command += ["ninja"]
+ # We can get jobs in the options. If so, we would use that.
+ if not any(j_opt.search(opt) for opt in self.options if isinstance(opt, basestring)):
+ # Otherwise let's see if we got it in the kwargs.
+ if kwargs.get('jobs', None):
+ self.options += ["-j", kwargs['jobs']]
+ else:
+ # Use the property if option was not explicitly
+ # specified.
+ command += [
+ WithProperties("%(jobs:+-j)s"),
+ WithProperties("%(jobs:-)s"),
+ ]
+
+ # The same logic is for hanling the loadaverage option.
+ if not any(l_opt.search(opt) for opt in self.options if isinstance(opt, basestring)):
+ if kwargs.get('loadaverage', None):
+ self.options += ["-l", kwargs['loadaverage']]
+ else:
+ command += [
+ WithProperties("%(loadaverage:+-l)s"),
+ WithProperties("%(loadaverage:-)s"),
+ ]
if self.options:
command += self.options
More information about the llvm-commits
mailing list