<s> """<STR_LIT>""" <EOL> import os <EOL> import shutil <EOL> import subprocess <EOL> import sys <EOL> BUILDBOT_DIR = os . path . dirname ( os . path . abspath ( __file__ ) ) <EOL> TRUNK_DIR = os . path . dirname ( BUILDBOT_DIR ) <EOL> ROOT_DIR = os . path . dirname ( TRUNK_DIR ) <EOL> CMAKE_DIR = os . path . join ( ROOT_DIR , '<STR_LIT>' ) <EOL> CMAKE_BIN_DIR = os . path . join ( CMAKE_DIR , '<STR_LIT>' ) <EOL> OUT_DIR = os . path . join ( TRUNK_DIR , '<STR_LIT>' ) <EOL> def CallSubProcess ( * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> with open ( os . devnull ) as devnull_fd : <EOL> retcode = subprocess . call ( stdin = devnull_fd , * args , ** kwargs ) <EOL> if retcode != <NUM_LIT:0> : <EOL> print '<STR_LIT>' <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> def PrepareCmake ( ) : <EOL> """<STR_LIT>""" <EOL> if os . environ [ '<STR_LIT>' ] == '<STR_LIT:1>' : <EOL> print '<STR_LIT>' <EOL> shutil . rmtree ( CMAKE_DIR ) <EOL> if os . path . isdir ( CMAKE_DIR ) : <EOL> return <EOL> print '<STR_LIT>' <EOL> os . mkdir ( CMAKE_DIR ) <EOL> print '<STR_LIT>' <EOL> CallSubProcess ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:1>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> CMAKE_DIR ] , <EOL> cwd = CMAKE_DIR ) <EOL> print '<STR_LIT>' <EOL> CallSubProcess ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' % CMAKE_DIR ] , <EOL> cwd = CMAKE_DIR ) <EOL> CallSubProcess ( [ '<STR_LIT>' , '<STR_LIT>' ] , cwd = CMAKE_DIR ) <EOL> def GypTestFormat ( title , format = None , msvs_version = None , tests = [ ] ) : <EOL> """<STR_LIT>""" <EOL> if not format : <EOL> format = title <EOL> print '<STR_LIT>' + title + '<STR_LIT>' <EOL> sys . stdout . flush ( ) <EOL> env = os . environ . copy ( ) <EOL> if msvs_version : <EOL> env [ '<STR_LIT>' ] = msvs_version <EOL> command = '<STR_LIT:U+0020>' . join ( <EOL> [ sys . executable , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , format , <EOL> '<STR_LIT>' , CMAKE_BIN_DIR , <EOL> '<STR_LIT>' , '<STR_LIT>' ] + tests ) <EOL> retcode = subprocess . call ( command , cwd = ROOT_DIR , env = env , shell = True ) <EOL> if retcode : <EOL> print '<STR_LIT>' <EOL> return <NUM_LIT:1> <EOL> return <NUM_LIT:0> <EOL> def GypBuild ( ) : <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' % OUT_DIR <EOL> shutil . rmtree ( OUT_DIR , ignore_errors = True ) <EOL> print '<STR_LIT>' <EOL> retcode = <NUM_LIT:0> <EOL> if sys . platform . startswith ( '<STR_LIT>' ) : <EOL> retcode += GypTestFormat ( '<STR_LIT>' ) <EOL> retcode += GypTestFormat ( '<STR_LIT>' ) <EOL> PrepareCmake ( ) <EOL> retcode += GypTestFormat ( '<STR_LIT>' ) <EOL> elif sys . platform == '<STR_LIT>' : <EOL> retcode += GypTestFormat ( '<STR_LIT>' ) <EOL> retcode += GypTestFormat ( '<STR_LIT>' ) <EOL> retcode += GypTestFormat ( '<STR_LIT>' ) <EOL> elif sys . platform == '<STR_LIT:win32>' : <EOL> retcode += GypTestFormat ( '<STR_LIT>' ) <EOL> if os . environ [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> retcode += GypTestFormat ( '<STR_LIT>' , format = '<STR_LIT>' , <EOL> msvs_version = '<STR_LIT>' , <EOL> tests = [ <EOL> r'<STR_LIT>' , <EOL> r'<STR_LIT>' , <EOL> r'<STR_LIT>' ] ) <EOL> retcode += GypTestFormat ( '<STR_LIT>' , format = '<STR_LIT>' , msvs_version = '<STR_LIT>' ) <EOL> else : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> if retcode : <EOL> print '<STR_LIT>' <EOL> sys . exit ( retcode ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> GypBuild ( ) </s>
