[zorg] r278055 - Re-factored CmakeCommand.applyRequiredOptions.

Galina Kistanova via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 8 14:57:05 PDT 2016


Author: gkistanova
Date: Mon Aug  8 16:57:05 2016
New Revision: 278055

URL: http://llvm.org/viewvc/llvm-project?rev=278055&view=rev
Log:
Re-factored CmakeCommand.applyRequiredOptions.

Modified:
    zorg/trunk/zorg/buildbot/commands/CmakeCommand.py

Modified: zorg/trunk/zorg/buildbot/commands/CmakeCommand.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/zorg/buildbot/commands/CmakeCommand.py?rev=278055&r1=278054&r2=278055&view=diff
==============================================================================
--- zorg/trunk/zorg/buildbot/commands/CmakeCommand.py (original)
+++ zorg/trunk/zorg/buildbot/commands/CmakeCommand.py Mon Aug  8 16:57:05 2016
@@ -11,12 +11,21 @@ class CmakeCommand(WarningCountingShellC
         # where all the values are properly formatted to terminate
         # control symbols.
         # TODO: Support cmake params with types, like -DCMAKE_CXX_FLAGS:STRING='-stdlib=libc++'.
-        options = [
-            a
-            for a in options
-            if not any(stripQuotationMarks(a).startswith(r) for r,_ in required)
-        ]
-        + [k + v for k,v in required]
+        for k,v in required:
+
+            o = None
+            for i,a in enumerate(options):
+                # Strip surraunding quotation marks if any.
+                a = stripQuotationMarks(a)
+                if a.startswith(k):
+                    # Replace the existing one by the one from required.
+                    o = options[i] = k + v
+
+            if o is None:
+                # We do not have the option to replace,
+                # so, let's just add a new one.
+                options.append(k + v)
+
 
     @staticmethod
     def applyDefaultOptions(options, defaults):
@@ -30,6 +39,7 @@ class CmakeCommand(WarningCountingShellC
             if not any(stripQuotationMarks(a).startswith(k) for a in options):
                 options.append(k + v)
 
+
     @staticmethod
     def appendFlags(options, append):
         # append is a list of tuples in form of (<opt name>, [<flag values>]).
@@ -69,6 +79,7 @@ class CmakeCommand(WarningCountingShellC
                 append_this[1] = flags
                 options.append('='.join(append_this))
 
+
     def __init__(self, prefixCommand=None, options=None, path=None, **kwargs):
         self.prefixCommand = prefixCommand
         self.path = [path]
@@ -107,6 +118,7 @@ class CmakeCommand(WarningCountingShellC
                                  options=self.options,
                                  path=path)
 
+
     def start(self):
         # Don't forget to remove all the empty items from the command,
         # which we could get because of WithProperties rendered as empty strings.




More information about the llvm-commits mailing list