From: Owen Smith Date: Mon, 19 May 2014 08:35:46 +0000 (+0100) Subject: Add sdv build to build.py, include nosdv option to not run sdv X-Git-Tag: 8.1.0-rc1~60^2~1 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=46cb00f64a2e7337f33a8b1c8b3fb04a3c8a1f29;p=pvdrivers%2Fwin%2Fxenvbd.git Add sdv build to build.py, include nosdv option to not run sdv Signed-off-by: Owen Smith --- diff --git a/build.py b/build.py index 12c4b7f..fcaacc0 100644 --- a/build.py +++ b/build.py @@ -6,6 +6,8 @@ import re import glob import tarfile import subprocess +import shutil +import time def next_build_number(): try: @@ -111,8 +113,8 @@ def get_expired_symbols(name, age = 30): return expired -def get_configuration(debug): - configuration = 'Windows Vista' +def get_configuration(release, debug): + configuration = release if debug: configuration += ' Debug' @@ -121,36 +123,32 @@ def get_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): @@ -159,26 +157,124 @@ 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): @@ -199,12 +295,11 @@ 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': @@ -220,7 +315,6 @@ def symstore_add(name, arch, debug): os.environ['MICRO_VERSION'], os.environ['BUILD_NUMBER']]) - os.chdir(target_path) command=['"' + symstore + '"'] command.append('add') command.append('/s') @@ -233,13 +327,11 @@ def symstore_add(name, arch, debug): 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] @@ -250,6 +342,7 @@ def callfnout(cmd): return output.decode('utf-8') + def archive(filename, files, tgz=False): access='w' if tgz: @@ -265,6 +358,8 @@ def archive(filename, files, tgz=False): 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' @@ -282,16 +377,22 @@ if __name__ == '__main__': 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']) diff --git a/msbuild.bat b/msbuild.bat new file mode 100644 index 0000000..1b1fbc8 --- /dev/null +++ b/msbuild.bat @@ -0,0 +1,8 @@ +call "%VS%\VC\vcvarsall.bat" x86 +@echo on +msbuild.exe /m:1 /p:Configuration="%CONFIGURATION%" /p:Platform="%PLATFORM%" /t:"%TARGET%" %EXTRA% %FILE% +if errorlevel 1 goto error +exit 0 + +:error +exit 1 diff --git a/proj/msbuild.bat b/proj/msbuild.bat deleted file mode 100644 index 143feb1..0000000 --- a/proj/msbuild.bat +++ /dev/null @@ -1,7 +0,0 @@ -call "%VS%\VC\vcvarsall.bat" x86 -msbuild.exe /m:4 /p:Configuration="%CONFIGURATION%" /p:Platform="%PLATFORM%" /t:"%TARGET%" %BUILD_ARGS% %BUILD_FILE% -if errorlevel 1 goto error -exit 0 - -:error -exit 1