Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Entry point for both build and try bots. | 6 """Entry point for both build and try bots. |
| 7 | 7 |
| 8 This script is invoked from XXX, usually without arguments | 8 This script is invoked from XXX, usually without arguments |
| 9 to package an SDK. It automatically determines whether | 9 to package an SDK. It automatically determines whether |
| 10 this SDK is for mac, win, linux. | 10 this SDK is for mac, win, linux. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 from build_paths import SCRIPT_DIR, SDK_SRC_DIR, SRC_DIR, NACL_DIR, OUT_DIR | 43 from build_paths import SCRIPT_DIR, SDK_SRC_DIR, SRC_DIR, NACL_DIR, OUT_DIR |
| 44 from build_paths import NACLPORTS_DIR, GSTORE, GONACL_APPENGINE_SRC_DIR | 44 from build_paths import NACLPORTS_DIR, GSTORE, GONACL_APPENGINE_SRC_DIR |
| 45 | 45 |
| 46 # Add SDK make tools scripts to the python path. | 46 # Add SDK make tools scripts to the python path. |
| 47 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) | 47 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) |
| 48 sys.path.append(os.path.join(NACL_DIR, 'build')) | 48 sys.path.append(os.path.join(NACL_DIR, 'build')) |
| 49 | 49 |
| 50 import getos | 50 import getos |
| 51 import oshelpers | 51 import oshelpers |
| 52 | 52 |
| 53 CYGTAR = os.path.join(NACL_DIR, 'build', 'cygtar.py') | 53 BUILD_DIR = os.path.join(NACL_DIR, 'build') |
| 54 NACL_TOOLCHAIN_DIR = os.path.join(NACL_DIR, 'toolchain') | |
| 55 NACL_TOOLCHAINTARS_DIR = os.path.join(NACL_TOOLCHAIN_DIR, '.tars') | |
| 56 | |
| 57 CYGTAR = os.path.join(BUILD_DIR, 'cygtar.py') | |
|
noelallen1
2014/04/12 22:52:16
Is CYGTAR still used?
David Yen
2014/04/14 16:09:59
It looks like it is used for tarring up the pepper
| |
| 58 PKGVER = os.path.join(BUILD_DIR, 'package_version', 'package_version.py') | |
| 54 | 59 |
| 55 NACLPORTS_URL = 'https://naclports.googlecode.com/svn/trunk/src' | 60 NACLPORTS_URL = 'https://naclports.googlecode.com/svn/trunk/src' |
| 56 NACLPORTS_REV = 1152 | 61 NACLPORTS_REV = 1152 |
| 57 | 62 |
| 58 GYPBUILD_DIR = 'gypbuild' | 63 GYPBUILD_DIR = 'gypbuild' |
| 59 | 64 |
| 60 options = None | 65 options = None |
| 61 | 66 |
| 62 | 67 # Map of: ToolchainName: (PackageName, SDKDir). |
| 63 def GetGlibcToolchain(): | 68 TOOLCHAIN_PACKAGE_MAP = { |
| 64 tcdir = os.path.join(NACL_DIR, 'toolchain', '.tars') | 69 'newlib': ('nacl_x86_newlib', '%(platform)s_x86_newlib'), |
| 65 tcname = 'toolchain_%s_x86.tar.bz2' % getos.GetPlatform() | 70 'bionic': ('nacl_arm_bionic', '%(platform)s_arm_bionic'), |
| 66 return os.path.join(tcdir, tcname) | 71 'arm': ('nacl_arm_newlib', '%(platform)s_arm_newlib'), |
| 67 | 72 'glibc': ('nacl_x86_glibc', '%(platform)s_x86_glibc'), |
| 68 | 73 'pnacl': ('pnacl_newlib', '%(platform)s_pnacl') |
| 69 def GetNewlibToolchain(): | 74 } |
| 70 tcdir = os.path.join(NACL_DIR, 'toolchain', '.tars') | |
| 71 tcname = 'naclsdk_%s_x86.tgz' % getos.GetPlatform() | |
| 72 return os.path.join(tcdir, tcname) | |
| 73 | |
| 74 | |
| 75 def GetBionicToolchain(): | |
| 76 tcdir = os.path.join(NACL_DIR, 'toolchain', '.tars') | |
| 77 tcname = 'naclsdk_%s_arm_bionic.tgz' % getos.GetPlatform() | |
| 78 return os.path.join(tcdir, tcname) | |
| 79 | |
| 80 | |
| 81 def GetPNaClToolchain(): | |
| 82 tcdir = os.path.join(NACL_DIR, 'toolchain', '.tars') | |
| 83 tcname = 'naclsdk_pnacl_%s_x86.tgz' % getos.GetPlatform() | |
| 84 return os.path.join(tcdir, tcname) | |
| 85 | 75 |
| 86 | 76 |
| 87 def GetToolchainNaClInclude(tcname, tcpath, arch): | 77 def GetToolchainNaClInclude(tcname, tcpath, arch): |
| 88 if arch == 'x86': | 78 if arch == 'x86': |
| 89 if tcname == 'pnacl': | 79 if tcname == 'pnacl': |
| 90 return os.path.join(tcpath, 'sdk', 'include') | 80 return os.path.join(tcpath, 'sdk', 'include') |
| 91 return os.path.join(tcpath, 'x86_64-nacl', 'include') | 81 return os.path.join(tcpath, 'x86_64-nacl', 'include') |
| 92 elif arch == 'arm': | 82 elif arch == 'arm': |
| 93 return os.path.join(tcpath, 'arm-nacl', 'include') | 83 return os.path.join(tcpath, 'arm-nacl', 'include') |
| 94 else: | 84 else: |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 return GetToolchainNaClLib(tcname, tcpath, xarch) | 133 return GetToolchainNaClLib(tcname, tcpath, xarch) |
| 144 | 134 |
| 145 | 135 |
| 146 def GetPNaClNativeLib(tcpath, arch): | 136 def GetPNaClNativeLib(tcpath, arch): |
| 147 if arch not in ['arm', 'x86-32', 'x86-64']: | 137 if arch not in ['arm', 'x86-32', 'x86-64']: |
| 148 buildbot_common.ErrorExit('Unknown architecture %s.' % arch) | 138 buildbot_common.ErrorExit('Unknown architecture %s.' % arch) |
| 149 return os.path.join(tcpath, 'lib-' + arch) | 139 return os.path.join(tcpath, 'lib-' + arch) |
| 150 | 140 |
| 151 | 141 |
| 152 def BuildStepDownloadToolchains(toolchains): | 142 def BuildStepDownloadToolchains(toolchains): |
| 153 buildbot_common.BuildStep('Running download_toolchains.py') | 143 buildbot_common.BuildStep('Running package_version.py') |
| 154 download_script = os.path.join('build', 'download_toolchains.py') | 144 args = [sys.executable, PKGVER, '--exclude', 'arm_trusted'] |
| 155 args = [sys.executable, download_script, '--no-arm-trusted', | |
| 156 '--arm-untrusted', '--keep'] | |
| 157 if 'bionic' in toolchains: | 145 if 'bionic' in toolchains: |
| 158 args.append('--allow-bionic') | 146 build_platform = '%s_x86' % getos.GetPlatform() |
| 147 args.extend(['--append', os.path.join(build_platform, 'nacl_arm_bionic')]) | |
| 159 buildbot_common.Run(args, cwd=NACL_DIR) | 148 buildbot_common.Run(args, cwd=NACL_DIR) |
| 160 | 149 |
| 161 | 150 |
| 162 def BuildStepCleanPepperDirs(pepperdir, pepperdir_old): | 151 def BuildStepCleanPepperDirs(pepperdir, pepperdir_old): |
| 163 buildbot_common.BuildStep('Clean Pepper Dirs') | 152 buildbot_common.BuildStep('Clean Pepper Dirs') |
| 164 buildbot_common.RemoveDir(pepperdir_old) | 153 buildbot_common.RemoveDir(pepperdir_old) |
| 165 buildbot_common.RemoveDir(pepperdir) | 154 buildbot_common.RemoveDir(pepperdir) |
| 166 buildbot_common.MakeDir(pepperdir) | 155 buildbot_common.MakeDir(pepperdir) |
| 167 | 156 |
| 168 | 157 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 193 time_format = '%Y/%m/%d %H:%M:%S' | 182 time_format = '%Y/%m/%d %H:%M:%S' |
| 194 readme_text = readme_text.replace('${DATE}', | 183 readme_text = readme_text.replace('${DATE}', |
| 195 datetime.datetime.now().strftime(time_format)) | 184 datetime.datetime.now().strftime(time_format)) |
| 196 | 185 |
| 197 open(os.path.join(pepperdir, 'README'), 'w').write(readme_text) | 186 open(os.path.join(pepperdir, 'README'), 'w').write(readme_text) |
| 198 | 187 |
| 199 | 188 |
| 200 def BuildStepUntarToolchains(pepperdir, toolchains): | 189 def BuildStepUntarToolchains(pepperdir, toolchains): |
| 201 buildbot_common.BuildStep('Untar Toolchains') | 190 buildbot_common.BuildStep('Untar Toolchains') |
| 202 platform = getos.GetPlatform() | 191 platform = getos.GetPlatform() |
| 192 build_platform = '%s_x86' % platform | |
| 203 tmpdir = os.path.join(OUT_DIR, 'tc_temp') | 193 tmpdir = os.path.join(OUT_DIR, 'tc_temp') |
| 204 buildbot_common.RemoveDir(tmpdir) | 194 buildbot_common.RemoveDir(tmpdir) |
| 205 buildbot_common.MakeDir(tmpdir) | 195 buildbot_common.MakeDir(tmpdir) |
| 206 | 196 |
| 207 if 'newlib' in toolchains: | 197 # Create a list of extract packages tuples, the first part should be |
| 208 # Untar the newlib toolchains | 198 # "$PACKAGE_TARGET/$PACKAGE". The second part should be the destination |
| 209 tarfile = GetNewlibToolchain() | 199 # directory relative to pepperdir/toolchain. |
| 210 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], | 200 extract_packages = [] |
| 211 cwd=NACL_DIR) | 201 for toolchain in toolchains: |
| 202 toolchain_map = TOOLCHAIN_PACKAGE_MAP.get(toolchain, None) | |
| 203 if toolchain_map: | |
| 204 package_name, tcname = toolchain_map | |
| 205 package_tuple = (os.path.join(build_platform, package_name), tcname) | |
| 206 extract_packages.append(package_tuple) | |
| 212 | 207 |
| 213 # Then rename/move it to the pepper toolchain directory | 208 if extract_packages: |
| 214 srcdir = os.path.join(tmpdir, 'sdk', 'nacl-sdk') | 209 # Extract all of the packages into the temp directory. |
| 215 tcname = platform + '_x86_newlib' | 210 package_names = [package_name for package_name, dest in extract_packages] |
| 216 newlibdir = os.path.join(pepperdir, 'toolchain', tcname) | 211 buildbot_common.Run([sys.executable, PKGVER, |
| 217 buildbot_common.Move(srcdir, newlibdir) | 212 '--packages', ','.join(package_names), |
| 213 '--tar-dir', NACL_TOOLCHAINTARS_DIR, | |
| 214 '--dest-dir', tmpdir, | |
| 215 'extract']) | |
| 218 | 216 |
| 219 if 'bionic' in toolchains: | 217 # Move all the packages we extracted to the correct destination. |
| 220 # Untar the bionic toolchains | 218 for package_name, dest_dir in extract_packages: |
| 221 tarfile = GetBionicToolchain() | 219 full_src_dir = os.path.join(tmpdir, package_name) |
| 222 tcname = platform + '_arm_bionic' | 220 full_dst_dir = os.path.join(pepperdir, 'toolchain', dest_dir) |
| 223 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], | 221 buildbot_common.Move(full_src_dir, full_dst_dir) |
| 224 cwd=NACL_DIR) | |
| 225 srcdir = os.path.join(tmpdir, tcname) | |
| 226 bionicdir = os.path.join(pepperdir, 'toolchain', tcname) | |
| 227 buildbot_common.Move(srcdir, bionicdir) | |
| 228 | 222 |
| 229 if 'arm' in toolchains: | 223 # Cleanup the temporary directory we are no longer using. |
| 230 # Copy the existing arm toolchain from native_client tree | |
| 231 tcname = platform + '_arm_newlib' | |
| 232 arm_toolchain = os.path.join(NACL_DIR, 'toolchain', tcname) | |
| 233 arm_toolchain_sdk = os.path.join(pepperdir, 'toolchain', | |
| 234 os.path.basename(arm_toolchain)) | |
| 235 buildbot_common.CopyDir(arm_toolchain, arm_toolchain_sdk) | |
| 236 | |
| 237 if 'glibc' in toolchains: | |
| 238 # Untar the glibc toolchains | |
| 239 tarfile = GetGlibcToolchain() | |
| 240 tcname = platform + '_x86_glibc' | |
| 241 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], | |
| 242 cwd=NACL_DIR) | |
| 243 | |
| 244 # Then rename/move it to the pepper toolchain directory | |
| 245 srcdir = os.path.join(tmpdir, 'toolchain', platform + '_x86') | |
| 246 glibcdir = os.path.join(pepperdir, 'toolchain', tcname) | |
| 247 buildbot_common.Move(srcdir, glibcdir) | |
| 248 | |
| 249 # Untar the pnacl toolchains | |
| 250 if 'pnacl' in toolchains: | |
| 251 tmpdir = os.path.join(tmpdir, 'pnacl') | |
| 252 buildbot_common.RemoveDir(tmpdir) | |
| 253 buildbot_common.MakeDir(tmpdir) | |
| 254 tarfile = GetPNaClToolchain() | |
| 255 tcname = platform + '_pnacl' | |
| 256 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], | |
| 257 cwd=NACL_DIR) | |
| 258 | |
| 259 # Then rename/move it to the pepper toolchain directory | |
| 260 pnacldir = os.path.join(pepperdir, 'toolchain', tcname) | |
| 261 buildbot_common.Move(tmpdir, pnacldir) | |
| 262 | |
| 263 buildbot_common.RemoveDir(tmpdir) | 224 buildbot_common.RemoveDir(tmpdir) |
| 264 | 225 |
| 265 if options.gyp and platform != 'win': | 226 if options.gyp and platform != 'win': |
| 266 # If the gyp options is specified we install a toolchain | 227 # If the gyp options is specified we install a toolchain |
| 267 # wrapper so that gyp can switch toolchains via a commandline | 228 # wrapper so that gyp can switch toolchains via a commandline |
| 268 # option. | 229 # option. |
| 269 bindir = os.path.join(pepperdir, 'toolchain', tcname, 'bin') | 230 bindir = os.path.join(pepperdir, 'toolchain', tcname, 'bin') |
| 270 wrapper = os.path.join(SDK_SRC_DIR, 'tools', 'compiler-wrapper.py') | 231 wrapper = os.path.join(SDK_SRC_DIR, 'tools', 'compiler-wrapper.py') |
| 271 buildbot_common.MakeDir(bindir) | 232 buildbot_common.MakeDir(bindir) |
| 272 buildbot_common.CopyFile(wrapper, bindir) | 233 buildbot_common.CopyFile(wrapper, bindir) |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1037 | 998 |
| 1038 return 0 | 999 return 0 |
| 1039 | 1000 |
| 1040 | 1001 |
| 1041 if __name__ == '__main__': | 1002 if __name__ == '__main__': |
| 1042 try: | 1003 try: |
| 1043 sys.exit(main(sys.argv)) | 1004 sys.exit(main(sys.argv)) |
| 1044 except KeyboardInterrupt: | 1005 except KeyboardInterrupt: |
| 1045 buildbot_common.ErrorExit('build_sdk: interrupted') | 1006 buildbot_common.ErrorExit('build_sdk: interrupted') |
| 1046 | 1007 |
| OLD | NEW |