Add MSVC/cmake build step.


git-svn-id: https://llvm.org/svn/llvm-project/zorg/trunk@76358 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/zorg/buildbot/builders/ClangBuilder.py b/zorg/buildbot/builders/ClangBuilder.py
index 4339d18..4dc95cf 100644
--- a/zorg/buildbot/builders/ClangBuilder.py
+++ b/zorg/buildbot/builders/ClangBuilder.py
@@ -1,7 +1,11 @@
+import os
+
 import buildbot
 import buildbot.process.factory
 from buildbot.steps.source import SVN
-from buildbot.steps.shell import Configure, WarningCountingShellCommand
+from buildbot.steps.shell import Configure, ShellCommand
+from buildbot.steps.shell import WarningCountingShellCommand
+from buildbot.steps.transfer import FileDownload
 from buildbot.process.properties import WithProperties
 
 from zorg.buildbot.commands.DejaGNUCommand import DejaGNUCommand
@@ -10,7 +14,9 @@
 
 def getClangBuildFactory(triple, 
                          CC='gcc', CXX='g++', 
-                         useCMake=False):
+                         CFLAGS='', CXXFLAGS='',
+                         useCMake=False,
+                         extraMakeArgs=''):
     f = buildbot.process.factory.BuildFactory()
     f.addStep(SVN(name='svn-llvm',
                   mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
@@ -23,8 +29,10 @@
     if useCMake:
         builddir = 'llvm/build'
         f.addStep(Configure(command=['cmake',
-                                     '-DCMAKE_C_COMPILER=%s' % (cc,),
-                                     '-DCMAKE_CXX_COMPILER=%s' % (cxx,),
+                                     '-DCMAKE_C_COMPILER=%s' % (CC,),
+                                     '-DCMAKE_CXX_COMPILER=%s' % (CXX,),
+                                     '-DCMAKE_C_FLAGS=%s' % (CFLAGS,),
+                                     '-DCMAKE_CXX_FLAGS=%s' % (CXXFLAGS,),
                                      '../'],
                             workdir=builddir,
                             description=['cmake','Debug'],
@@ -33,8 +41,8 @@
         builddir = 'llvm'
         f.addStep(Configure(command=['./configure',
                                      '--build', triple,
-                                     'CC=%s' % (CC,),
-                                     'CXX=%s' % (CXX,)],
+                                     'CC=%s %s' % (CC, CFLAGS),
+                                     'CXX=%s %s' % (CXX, CXXFLAGS)],
                             workdir=builddir,
                             description=['configuring','Debug'],
                             descriptionDone=['configure','Debug']))
@@ -53,12 +61,72 @@
     if not useCMake: # :(
         f.addStep(DejaGNUCommand(name='test-llvm',
                                  workdir=builddir))
-    f.addStep(ClangTestCommand(name='test-clang',
-                               command=WithProperties("nice -n 10 make -j%(jobs)d test VERBOSE=1"), 
-                               workdir="llvm/tools/clang"))
-    if not useCMake: # (
+    if not useCMake: # :(
+        f.addStep(ClangTestCommand(name='test-clang',
+                                   command=WithProperties("nice -n 10 make -j%(jobs)d test VERBOSE=1"), 
+                                   workdir="llvm/tools/clang"))
+    if not useCMake: # :(
         f.addStep(GTestCommand(name="unittest-llvm", 
                                command=["make", "unittests"],
                                description="unittests (llvm)", 
                                workdir="llvm"))
     return f
+
+
+def getClangMSVCBuildFactory():
+    f = buildbot.process.factory.BuildFactory()
+
+    if True:
+        f.addStep(SVN(name='svn-llvm',
+                      mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
+                      defaultBranch='trunk',
+                      workdir='llvm'))
+
+    if True:
+        f.addStep(SVN(name='svn-clang',
+                      mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/', 
+                      defaultBranch='trunk',
+                      workdir='llvm/tools/clang'))
+
+    # Full & fast clean.
+    if True:
+        f.addStep(ShellCommand(name='clean-1',
+                               command=['del','/s/q','build'],
+                               warnOnFailure=True, 
+                               description='cleaning',
+                               descriptionDone='clean',
+                               workdir='llvm'))
+        f.addStep(ShellCommand(name='clean-2',
+                               command=['rmdir','/s/q','build'],
+                               warnOnFailure=True, 
+                               description='cleaning',
+                               descriptionDone='clean',
+                               workdir='llvm'))
+
+    # Create the project files.
+    
+    # FIXME: Don't require local versions of these files. See buildbot ticket
+    # #595. We could always write the contents into a temp file, to avoid having
+    # them in SVN, and to allow parameterization.
+    f.addStep(FileDownload(mastersrc=os.path.join(os.path.dirname(__file__),
+                                                  'ClangMSVC_cmakegen.bat'),
+                           slavedest='cmakegen.bat',
+                           workdir='llvm\\build'))
+    f.addStep(ShellCommand(name='cmake',
+                           command=['cmakegen.bat'],
+                           haltOnFailure=True, 
+                           description='cmake gen',
+                           workdir='llvm\\build'))
+
+    # Build it.
+    f.addStep(FileDownload(mastersrc=os.path.join(os.path.dirname(__file__),
+                                                  'ClangMSVC_vcbuild.bat'),
+                           slavedest='vcbuild.bat',
+                           workdir='llvm\\build'))
+    f.addStep(WarningCountingShellCommand(name='vcbuild',
+                                          command=['vcbuild.bat'],
+                                          haltOnFailure=True, 
+                                          description='vcbuild',
+                                          workdir='llvm\\build',
+                                          warningPattern=" warning C.*:"))
+    return f