import glob
import tarfile
import subprocess
+import shutil
+import time
def next_build_number():
try:
return expired
-def get_configuration(debug):
- configuration = 'Windows Vista'
+def get_configuration(release, debug):
+ configuration = release
if debug:
configuration += ' Debug'
return configuration
-def get_configuration_name(debug):
- configuration = 'WindowsVista'
- if debug:
- configuration += 'Debug'
- else:
- configuration += 'Release'
-
- return configuration
-
-
-def get_target_path(arch, debug):
- configuration = get_configuration_name(debug)
-
- target = { 'x86': os.sep.join([configuration, 'Win32']), 'x64': os.sep.join([configuration, 'x64']) }
+def get_target_path(release, arch, debug):
+ configuration = get_configuration(release, debug)
+ name = ''.join(configuration.split(' '))
+ target = { 'x86': os.sep.join([name, 'Win32']), 'x64': os.sep.join([name, 'x64']) }
target_path = os.sep.join(['proj', target[arch]])
return target_path
-def shell(command):
+def shell(command, dir):
+ print(dir)
print(command)
sys.stdout.flush()
+
+ sub = subprocess.Popen(' '.join(command), cwd=dir,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ universal_newlines=True)
- pipe = os.popen(command, 'r', 1)
-
- for line in pipe:
+ for line in sub.stdout:
print(line.rstrip())
- return pipe.close()
+ sub.wait()
+
+ return sub.returncode
class msbuild_failure(Exception):
def __str__(self):
return repr(self.value)
-def msbuild(name, arch, debug):
- cwd = os.getcwd()
- configuration = get_configuration(debug)
+def msbuild(platform, configuration, target, file, args, dir):
+ os.environ['PLATFORM'] = platform
+ os.environ['CONFIGURATION'] = configuration
+ os.environ['TARGET'] = target
+ os.environ['FILE'] = file
+ os.environ['EXTRA'] = args
+
+ bin = os.path.join(os.getcwd(), 'msbuild.bat')
+
+ status = shell([bin], dir)
+
+ if (status != 0):
+ raise msbuild_failure(configuration)
+
+
+def build_sln(name, release, arch, debug):
+ configuration = get_configuration(release, debug)
if arch == 'x86':
- os.environ['PLATFORM'] = 'Win32'
+ platform = 'Win32'
elif arch == 'x64':
- os.environ['PLATFORM'] = 'x64'
+ platform = 'x64'
- os.environ['CONFIGURATION'] = configuration
- os.environ['TARGET'] = 'Build'
- os.environ['BUILD_FILE'] = name + '.sln'
- os.environ['BUILD_ARGS'] = ''
+ cwd = os.getcwd()
- os.chdir('proj')
- status = shell('msbuild.bat')
- os.chdir(cwd)
+ msbuild(platform, configuration, 'Build', name + '.sln', '', 'proj')
- if (status != None):
- raise msbuild_failure(configuration)
+
+def remove_timestamps(path):
+ try:
+ os.unlink(path + '.orig')
+ except OSError:
+ pass
+
+ os.rename(path, path + '.orig')
+
+ src = open(path + '.orig', 'r')
+ dst = open(path, 'w')
+
+ for line in src:
+ if line.find('TimeStamp') == -1:
+ dst.write(line)
+
+ dst.close()
+ src.close()
+
+def sdv_clean(name):
+ path = ['proj', name, 'sdv']
+ print(path)
+
+ shutil.rmtree(os.path.join(*path), True)
+
+ path = ['proj', name, 'sdv.temp']
+ print(path)
+
+ shutil.rmtree(os.path.join(*path), True)
+
+ path = ['proj', name, 'staticdv.job']
+ print(path)
+
+ try:
+ os.unlink(os.path.join(*path))
+ except OSError:
+ pass
+
+ path = ['proj', name, 'refine.sdv']
+ print(path)
+
+ try:
+ os.unlink(os.path.join(*path))
+ except OSError:
+ pass
+
+ path = ['proj', name, 'sdv-map.h']
+ print(path)
+
+ try:
+ os.unlink(os.path.join(*path))
+ except OSError:
+ pass
+
+
+def run_sdv(name, dir):
+ configuration = get_configuration('Windows 8', False)
+ platform = 'x64'
+
+ msbuild(platform, configuration, 'Build', name + '.vcxproj',
+ '', os.path.join('proj', name))
+
+ sdv_clean(name)
+
+ msbuild(platform, configuration, 'sdv', name + '.vcxproj',
+ '/p:Inputs="/scan"', os.path.join('proj', name))
+
+ path = ['proj', name, 'sdv-map.h']
+ file = open(os.path.join(*path), 'r')
+
+ for line in file:
+ print(line)
+
+ file.close()
+
+ msbuild(platform, configuration, 'sdv', name + '.vcxproj',
+ '/p:Inputs="/check:default.sdv"', os.path.join('proj', name))
+
+ path = ['proj', name, 'sdv', 'SDV.DVL.xml']
+ remove_timestamps(os.path.join(*path))
+
+ msbuild(platform, configuration, 'dvl', name + '.vcxproj',
+ '', os.path.join('proj', name))
+
+ path = ['proj', name, name + '.DVL.XML']
+ shutil.copy(os.path.join(*path), dir)
+
+ path = ['proj', name, 'refine.sdv']
+ if os.path.isfile(os.path.join(*path)):
+ msbuild(platform, configuration, 'sdv', name + '.vcxproj',
+ '/p:Inputs=/refine', os.path.join('proj', name))
def symstore_del(name, age):
command.append('/s')
command.append(os.environ['SYMBOL_SERVER'])
- shell(' '.join(command))
+ shell(command, None)
-def symstore_add(name, arch, debug):
- cwd = os.getcwd()
- configuration = get_configuration_name(debug)
- target_path = get_target_path(arch, debug)
+
+def symstore_add(name, release, arch, debug):
+ target_path = get_target_path(release, arch, debug)
symstore_path = [os.environ['KIT'], 'Debuggers']
if os.environ['PROCESSOR_ARCHITECTURE'] == 'x86':
os.environ['MICRO_VERSION'],
os.environ['BUILD_NUMBER']])
- os.chdir(target_path)
command=['"' + symstore + '"']
command.append('add')
command.append('/s')
command.append('/v')
command.append(version)
- shell(' '.join(command))
-
- os.chdir(cwd)
+ shell(command, target_path)
-def callfnout(cmd):
- print(cmd)
+def manifest():
+ cmd = ['git', 'ls-tree', '-r', '--name-only', 'HEAD']
sub = subprocess.Popen(cmd, stdout=subprocess.PIPE)
output = sub.communicate()[0]
return output.decode('utf-8')
+
def archive(filename, files, tgz=False):
access='w'
if tgz:
if __name__ == '__main__':
debug = { 'checked': True, 'free': False }
+ sdv = { 'nosdv': False, None: True }
+ driver = 'xenvbd'
os.environ['MAJOR_VERSION'] = '7'
os.environ['MINOR_VERSION'] = '2'
make_header()
- copy_inf('xenvbd')
+ copy_inf(driver)
+
+ symstore_del(driver, 30)
+
+ release = 'Windows Vista'
+
+ build_sln(driver, release, 'x86', debug[sys.argv[1]])
+ build_sln(driver, release, 'x64', debug[sys.argv[1]])
- symstore_del('xenvbd', 30)
+ symstore_add(driver, release, 'x86', debug[sys.argv[1]])
+ symstore_add(driver, release, 'x64', debug[sys.argv[1]])
- msbuild('xenvbd', 'x86', debug[sys.argv[1]])
- msbuild('xenvbd', 'x64', debug[sys.argv[1]])
+ if len(sys.argv) <= 2 or sdv[sys.argv[2]]:
+ run_sdv('xencrsh', driver)
+ run_sdv('xenvbd', driver)
- symstore_add('xenvbd', 'x86', debug[sys.argv[1]])
- symstore_add('xenvbd', 'x64', debug[sys.argv[1]])
+ archive(driver + '\\source.tgz', manifest().splitlines(), tgz=True)
+ archive(driver + '.tar', [driver,'revision'])
- listfile = callfnout(['git','ls-files'])
- archive('xenvbd\\source.tgz', listfile.splitlines(), tgz=True)
- archive('xenvbd.tar', ['xenvbd','revision'])