jljusten | 267865e | 2011-02-23 22:21:00 +0000 | [diff] [blame^] | 1 | #!/usr/bin/python
|
| 2 | #
|
| 3 | # Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
|
| 4 | #
|
| 5 | # This program and the accompanying materials
|
| 6 | # are licensed and made available under the terms and conditions of the BSD License
|
| 7 | # which accompanies this distribution. The full text of the license may be found at
|
| 8 | # http://opensource.org/licenses/bsd-license.php
|
| 9 | #
|
| 10 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
| 11 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
| 12 | #
|
| 13 |
|
| 14 | release_type = 'alpha'
|
| 15 |
|
| 16 | import os
|
| 17 | import re
|
| 18 | import StringIO
|
| 19 | import subprocess
|
| 20 | import sys
|
| 21 | import zipfile
|
| 22 |
|
| 23 | is_unix = not sys.platform.startswith('win')
|
| 24 |
|
| 25 | if not is_unix:
|
| 26 | print "This script currently only supports unix-like systems"
|
| 27 | sys.exit(-1)
|
| 28 |
|
| 29 | if os.path.exists('OvmfPkgX64.dsc'):
|
| 30 | os.chdir('..')
|
| 31 |
|
| 32 | if not os.path.exists(os.path.join('OvmfPkg', 'OvmfPkgX64.dsc')):
|
| 33 | print "OvmfPkg/OvmfPkgX64.dsc doesn't exist"
|
| 34 | sys.exit(-1)
|
| 35 |
|
| 36 | if 'TOOLCHAIN' in os.environ:
|
| 37 | TOOLCHAIN = os.environ['TOOLCHAIN']
|
| 38 | else:
|
| 39 | TOOLCHAIN = 'GCC44'
|
| 40 |
|
| 41 | def run_and_capture_output(args, checkExitCode = True):
|
| 42 | p = subprocess.Popen(args=args, stdout=subprocess.PIPE)
|
| 43 | stdout = p.stdout.read()
|
| 44 | ret_code = p.wait()
|
| 45 | if checkExitCode:
|
| 46 | assert ret_code == 0
|
| 47 | return stdout
|
| 48 |
|
| 49 | def git_svn_info():
|
| 50 | dir = os.getcwd()
|
| 51 | os.chdir('OvmfPkg')
|
| 52 | stdout = run_and_capture_output(args=('git', 'svn', 'info'))
|
| 53 | os.chdir(dir)
|
| 54 | return stdout
|
| 55 |
|
| 56 | def svn_info():
|
| 57 | dir = os.getcwd()
|
| 58 | os.chdir('OvmfPkg')
|
| 59 | stdout = run_and_capture_output(args=('svn', 'info'))
|
| 60 | os.chdir(dir)
|
| 61 | return stdout
|
| 62 |
|
| 63 | def get_svn_info_output():
|
| 64 | if os.path.exists(os.path.join('OvmfPkg', '.svn')):
|
| 65 | return svn_info()
|
| 66 | else:
|
| 67 | return git_svn_info()
|
| 68 |
|
| 69 | def get_revision():
|
| 70 | buf = get_svn_info_output()
|
| 71 | revision_re = re.compile('^Revision\:\s*(\d+)$', re.MULTILINE)
|
| 72 | mo = revision_re.search(buf)
|
| 73 | if mo is not None:
|
| 74 | return int(mo.group(1))
|
| 75 |
|
| 76 | revision = get_revision()
|
| 77 |
|
| 78 | newline_re = re.compile(r'(\n|\r\n|\r(?!\n))', re.MULTILINE)
|
| 79 | def to_dos_text(str):
|
| 80 | return newline_re.sub('\r\n', str)
|
| 81 |
|
| 82 | def gen_build_info():
|
| 83 | distro = run_and_capture_output(args=('lsb_release', '-sd')).strip()
|
| 84 |
|
| 85 | machine = run_and_capture_output(args=('uname', '-m')).strip()
|
| 86 |
|
| 87 | gcc_version = run_and_capture_output(args=('gcc', '--version'))
|
| 88 | gcc_version = gcc_version.split('\n')[0].split()[-1]
|
| 89 |
|
| 90 | ld_version = run_and_capture_output(args=('ld', '--version'))
|
| 91 | ld_version = ld_version.split('\n')[0].split()[-1]
|
| 92 |
|
| 93 | iasl_version = run_and_capture_output(args=('iasl'), checkExitCode=False)
|
| 94 | iasl_version = filter(lambda s: s.find(' version ') >= 0, iasl_version.split('\n'))[0]
|
| 95 | iasl_version = iasl_version.split(' version ')[1].strip()
|
| 96 |
|
| 97 | sb = StringIO.StringIO()
|
| 98 | print >> sb, 'edk2: ', 'r%d' % revision
|
| 99 | print >> sb, 'compiler: GCC', gcc_version
|
| 100 | print >> sb, 'binutils:', ld_version
|
| 101 | print >> sb, 'iasl: ', iasl_version
|
| 102 | print >> sb, 'system: ', distro, machine.replace('_', '-')
|
| 103 | return to_dos_text(sb.getvalue())
|
| 104 |
|
| 105 | LICENSE = to_dos_text(
|
| 106 | '''This OVMF binary release is built from source code licensed under
|
| 107 | the BSD open source license. The BSD license is documented at
|
| 108 | http://opensource.org/licenses/bsd-license.php, and a copy is
|
| 109 | shown below.
|
| 110 |
|
| 111 | One sub-component of the OVMF project is a FAT filesystem driver. The FAT
|
| 112 | filesystem driver code is also BSD licensed, but the code license contains
|
| 113 | one additional term. This license can be found at
|
| 114 | http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=Edk2-fat-driver,
|
| 115 | and a copy is shown below (following the normal BSD license).
|
| 116 |
|
| 117 | === BSD license: START ===
|
| 118 |
|
| 119 | Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
|
| 120 |
|
| 121 | Redistribution and use in source and binary forms, with or without
|
| 122 | modification, are permitted provided that the following conditions
|
| 123 | are met:
|
| 124 |
|
| 125 | * Redistributions of source code must retain the above copyright
|
| 126 | notice, this list of conditions and the following disclaimer.
|
| 127 | * Redistributions in binary form must reproduce the above copyright
|
| 128 | notice, this list of conditions and the following disclaimer in
|
| 129 | the documentation and/or other materials provided with the
|
| 130 | distribution.
|
| 131 | * Neither the name of the Intel Corporation nor the names of its
|
| 132 | contributors may be used to endorse or promote products derived
|
| 133 | from this software without specific prior written permission.
|
| 134 |
|
| 135 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 136 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 137 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
| 138 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
| 139 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 140 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 141 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
| 142 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 143 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
| 144 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
| 145 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
| 146 | POSSIBILITY OF SUCH DAMAGE.
|
| 147 |
|
| 148 | === BSD license: END ===
|
| 149 |
|
| 150 | === FAT filesystem driver license: START ===
|
| 151 |
|
| 152 | Copyright (c) 2004, Intel Corporation. All rights reserved.
|
| 153 |
|
| 154 | Redistribution and use in source and binary forms, with or without
|
| 155 | modification, are permitted provided that the following conditions
|
| 156 | are met:
|
| 157 |
|
| 158 | * Redistributions of source code must retain the above copyright
|
| 159 | notice, this list of conditions and the following disclaimer.
|
| 160 | * Redistributions in binary form must reproduce the above copyright
|
| 161 | notice, this list of conditions and the following disclaimer in
|
| 162 | the documentation and/or other materials provided with the
|
| 163 | distribution.
|
| 164 | * Neither the name of Intel nor the names of its
|
| 165 | contributors may be used to endorse or promote products derived
|
| 166 | from this software without specific prior written permission.
|
| 167 |
|
| 168 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 169 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 170 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
| 171 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
| 172 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 173 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 174 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
| 175 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 176 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
| 177 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
| 178 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
| 179 | POSSIBILITY OF SUCH DAMAGE.
|
| 180 |
|
| 181 | Additional terms:
|
| 182 | In addition to the forgoing, redistribution and use of the code is
|
| 183 | conditioned upon the FAT 32 File System Driver and all derivative
|
| 184 | works thereof being used for and designed only to read and/or write
|
| 185 | to a file system that is directly managed by an Extensible Firmware
|
| 186 | Interface (EFI) implementation or by an emulator of an EFI
|
| 187 | implementation.
|
| 188 |
|
| 189 | === FAT filesystem driver license: END ===
|
| 190 | ''')
|
| 191 |
|
| 192 | def build(arch):
|
| 193 | args = (
|
| 194 | 'OvmfPkg/build.sh',
|
| 195 | '-t', TOOLCHAIN,
|
| 196 | '-a', arch,
|
| 197 | '-b', 'RELEASE'
|
| 198 | )
|
| 199 | logname = 'build-%s.log' % arch
|
| 200 | build_log = open(logname, 'w')
|
| 201 | print 'Building OVMF for', arch, '(%s)' % logname, '...',
|
| 202 | sys.stdout.flush()
|
| 203 | p = subprocess.Popen(args=args, stdout=build_log, stderr=build_log)
|
| 204 | ret_code = p.wait()
|
| 205 | if ret_code == 0:
|
| 206 | print '[done]'
|
| 207 | else:
|
| 208 | print '[error 0x%x]' % ret_code
|
| 209 | return ret_code
|
| 210 |
|
| 211 | def create_zip(arch):
|
| 212 | global build_info
|
| 213 | filename = 'OVMF-%s-r%d-%s.zip' % (arch, revision, release_type)
|
| 214 | print 'Creating', filename, '...',
|
| 215 | sys.stdout.flush()
|
| 216 | if os.path.exists(filename):
|
| 217 | os.remove(filename)
|
| 218 | zipf = zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED)
|
| 219 |
|
| 220 | zipf.writestr('BUILD_INFO', build_info)
|
| 221 | zipf.writestr('LICENSE', LICENSE)
|
| 222 | zipf.write(os.path.join('OvmfPkg', 'README'), 'README')
|
| 223 | FV_DIR = os.path.join(
|
| 224 | 'Build',
|
| 225 | 'Ovmf' + arch.title(),
|
| 226 | 'RELEASE_' + TOOLCHAIN,
|
| 227 | 'FV'
|
| 228 | )
|
| 229 | zipf.write(os.path.join(FV_DIR, 'OVMF.fd'), 'OVMF.fd')
|
| 230 | zipf.write(os.path.join(FV_DIR, 'CirrusLogic5446.rom'), 'CirrusLogic5446.rom')
|
| 231 | zipf.close()
|
| 232 | print '[done]'
|
| 233 |
|
| 234 | build_info = gen_build_info()
|
| 235 | build('IA32')
|
| 236 | build('X64')
|
| 237 | create_zip('IA32')
|
| 238 | create_zip('X64')
|
| 239 |
|
| 240 |
|