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 import build_utils | 8 This script is invoked from XXX, usually without arguments |
9 import lastchange | 9 to package an NNaCl SDK. It automatically determines whether |
10 this SDK is for mac, win, linux. | |
11 | |
12 If the script is invoked with the single argument 'pnacl' | |
sehr (please use chromium)
2012/01/31 16:38:11
Ultra-nit: two spaces should be one.
robertm
2012/01/31 17:29:48
Done.
| |
13 an PNaCl SDK is build instead. | |
14 | |
15 The script inspects the following environment variables: | |
16 | |
17 BUILDBOT_BUILDERNAME to determine whether the script is run locally | |
18 and whether it should upload an SDK to file storage (GSTORE) | |
19 ''' | |
20 | |
21 # std python includes | |
10 import os | 22 import os |
11 import subprocess | 23 import subprocess |
12 import sys | 24 import sys |
13 | 25 |
26 # local includes | |
27 import build_utils | |
28 import lastchange | |
29 | |
30 | |
14 # Create the various paths of interest | 31 # Create the various paths of interest |
15 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 32 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
16 SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR) | 33 SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR) |
17 SDK_DIR = os.path.dirname(SDK_SRC_DIR) | 34 SDK_DIR = os.path.dirname(SDK_SRC_DIR) |
18 SRC_DIR = os.path.dirname(SDK_DIR) | 35 SRC_DIR = os.path.dirname(SDK_DIR) |
19 NACL_DIR = os.path.join(SRC_DIR, 'native_client') | 36 NACL_DIR = os.path.join(SRC_DIR, 'native_client') |
20 OUT_DIR = os.path.join(SRC_DIR, 'out') | 37 OUT_DIR = os.path.join(SRC_DIR, 'out') |
21 PPAPI_DIR = os.path.join(SRC_DIR, 'ppapi') | 38 PPAPI_DIR = os.path.join(SRC_DIR, 'ppapi') |
22 | 39 |
23 | 40 |
24 # Add SDK make tools scripts to the python path. | 41 # Add SDK make tools scripts to the python path. |
25 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) | 42 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) |
26 sys.path.append(os.path.join(NACL_DIR, 'build')) | 43 sys.path.append(os.path.join(NACL_DIR, 'build')) |
27 | 44 |
28 | 45 import getos |
29 import http_download | 46 import http_download |
30 from getos import GetPlatform | |
31 import oshelpers | 47 import oshelpers |
32 | 48 |
33 GSTORE = 'http://commondatastorage.googleapis.com/nativeclient-mirror/nacl/' | 49 GSTORE = 'http://commondatastorage.googleapis.com/nativeclient-mirror/nacl/' |
34 MAKE = 'nacl_sdk/make_3_81/make.exe' | 50 MAKE = 'nacl_sdk/make_3_81/make.exe' |
35 GSUTIL = '/b/build/scripts/slave/gsutil' | 51 # For buildbots assume gsutil is stored in the build directory. |
52 BOT_GSUTIL = '/b/build/scripts/slave/gsutil' | |
53 # For loca runs just make sure gsutil is in your PATH | |
sehr (please use chromium)
2012/01/31 16:38:11
s/loca/local/ and add . at the end.
robertm
2012/01/31 17:29:48
Done.
| |
54 LOCAL_GSUTIL = 'gsutil' | |
36 | 55 |
37 def ErrorExit(msg): | 56 def ErrorExit(msg): |
38 """Write and error to stderr, then exit with 1 signaling failure.""" | 57 '''Write and error to stderr, then exit with 1 signaling failure.''' |
39 sys.stderr.write(msg + '\n') | 58 sys.stderr.write(msg + '\n') |
40 sys.exit(1) | 59 sys.exit(1) |
41 | 60 |
42 | 61 |
43 def BuildStep(name): | 62 def BuildStep(name): |
44 """Annotate a buildbot build step.""" | 63 '''Annotate a buildbot build step.''' |
45 sys.stdout.flush() | 64 sys.stdout.flush() |
46 print '\n@@@BUILD_STEP %s@@@' % name | 65 print '\n@@@BUILD_STEP %s@@@' % name |
47 sys.stdout.flush() | 66 sys.stdout.flush() |
48 | 67 |
49 | 68 |
50 def Run(args, cwd=None, shell=False): | 69 def Run(args, cwd=None, shell=False): |
51 """Start a process with the provided arguments. | 70 '''Start a process with the provided arguments. |
52 | 71 |
53 Starts a process in the provided directory given the provided arguments. If | 72 Starts a process in the provided directory given the provided arguments. If |
54 shell is not False, the process is launched via the shell to provide shell | 73 shell is not False, the process is launched via the shell to provide shell |
55 interpretation of the arguments. Shell behavior can differ between platforms | 74 interpretation of the arguments. Shell behavior can differ between platforms |
56 so this should be avoided when not using platform dependent shell scripts.""" | 75 so this should be avoided when not using platform dependent shell scripts.''' |
57 print 'Running: ' + ' '.join(args) | 76 print 'Running: ' + ' '.join(args) |
58 sys.stdout.flush() | 77 sys.stdout.flush() |
59 subprocess.check_call(args, cwd=cwd, shell=shell) | 78 subprocess.check_call(args, cwd=cwd, shell=shell) |
60 sys.stdout.flush() | 79 sys.stdout.flush() |
61 | 80 |
62 | 81 |
63 def Archive(filename): | 82 def Archive(filename): |
64 """Upload the given filename to Google Store.""" | 83 '''Upload the given filename to Google Store.''' |
65 chrome_version = build_utils.ChromeVersion() | 84 chrome_version = build_utils.ChromeVersion() |
66 bucket_path = 'nativeclient-mirror/nacl/nacl_sdk/%s/%s' % ( | 85 bucket_path = 'nativeclient-mirror/nacl/nacl_sdk/%s/%s' % ( |
67 chrome_version, filename) | 86 chrome_version, filename) |
68 full_dst = 'gs://%s' % bucket_path | 87 full_dst = 'gs://%s' % bucket_path |
69 | 88 |
70 if os.environ.get('BUILDBOT_BUILDERNAME', ''): | 89 if os.environ.get('BUILDBOT_BUILDERNAME', ''): |
71 # For buildbots assume gsutil is stored in the build directory. | 90 gsutil = BOT_GSUTIL |
72 gsutil = '/b/build/scripts/slave/gsutil' | |
73 else: | 91 else: |
74 # For non buildpots, you must have it in your path. | 92 gsutil = LOCAL_GSUTIL |
75 gsutil = 'gsutil' | |
76 | 93 |
77 subprocess.check_call( | 94 subprocess.check_call( |
78 '%s cp -a public-read %s %s' % ( | 95 '%s cp -a public-read %s %s' % ( |
79 gsutil, filename, full_dst), shell=True, cwd=OUT_DIR) | 96 gsutil, filename, full_dst), shell=True, cwd=OUT_DIR) |
80 url = 'https://commondatastorage.googleapis.com/%s' % bucket_path | 97 url = 'https://commondatastorage.googleapis.com/%s' % bucket_path |
81 print '@@@STEP_LINK@download@%s@@@' % url | 98 print '@@@STEP_LINK@download@%s@@@' % url |
82 sys.stdout.flush() | 99 sys.stdout.flush() |
83 | 100 |
84 | 101 |
85 def AddMakeBat(makepath): | 102 def AddMakeBat(makepath): |
86 """Create a simple batch file to execute Make. | 103 '''Create a simple batch file to execute Make. |
87 | 104 |
88 Creates a simple batch file named make.bat for the Windows platform at the | 105 Creates a simple batch file named make.bat for the Windows platform at the |
89 given path, pointing to the Make executable in the SDK.""" | 106 given path, pointing to the Make executable in the SDK.''' |
90 fp = open(os.path.join(makepath, 'make.bat'), 'wb') | 107 fp = open(os.path.join(makepath, 'make.bat'), 'wb') |
91 fp.write('@..\\..\\tools\\make.exe %*\n') | 108 fp.write('@..\\..\\tools\\make.exe %*\n') |
92 fp.close() | 109 fp.close() |
93 | 110 |
94 | 111 |
95 def CopyDir(src, dst, excludes=['.svn']): | 112 def CopyDir(src, dst, excludes=['.svn']): |
96 """Recursively copy a directory using.""" | 113 '''Recursively copy a directory using.''' |
97 args = ['-r', src, dst] | 114 args = ['-r', src, dst] |
98 for exc in excludes: | 115 for exc in excludes: |
99 args.append('--exclude=' + exc) | 116 args.append('--exclude=' + exc) |
100 print "cp -r %s %s" % (src, dst) | 117 print "cp -r %s %s" % (src, dst) |
101 oshelpers.Copy(args) | 118 oshelpers.Copy(args) |
102 | 119 |
103 def RemoveDir(dst): | 120 def RemoveDir(dst): |
104 """Remove the provided path.""" | 121 '''Remove the provided path.''' |
105 print "rm -fr " + dst | 122 print "rm -fr " + dst |
106 oshelpers.Remove(['-fr', dst]) | 123 oshelpers.Remove(['-fr', dst]) |
107 | 124 |
108 def MakeDir(dst): | 125 def MakeDir(dst): |
109 """Create the path including all parent directories as needed.""" | 126 '''Create the path including all parent directories as needed.''' |
110 print "mkdir -p " + dst | 127 print "mkdir -p " + dst |
111 oshelpers.Mkdir(['-p', dst]) | 128 oshelpers.Mkdir(['-p', dst]) |
112 | 129 |
113 def MoveDir(src, dst): | 130 def MoveDir(src, dst): |
114 """Move the path src to dst.""" | 131 '''Move the path src to dst.''' |
115 print "mv -fr %s %s" % (src, dst) | 132 print "mv -fr %s %s" % (src, dst) |
116 oshelpers.Move(['-f', src, dst]) | 133 oshelpers.Move(['-f', src, dst]) |
117 | 134 |
118 def BuildOutputDir(*paths): | 135 def BuildOutputDir(*paths): |
119 return os.path.join(OUT_DIR, *paths) | 136 return os.path.join(OUT_DIR, *paths) |
120 | 137 |
121 | 138 |
122 def GetGlibcToolchain(platform, arch): | 139 def GetGlibcToolchain(platform, arch): |
123 tcdir = os.path.join(NACL_DIR, 'toolchain', '.tars') | 140 tcdir = os.path.join(NACL_DIR, 'toolchain', '.tars') |
124 tcname = 'toolchain_%s_%s.tar.bz2' % (platform, arch) | 141 tcname = 'toolchain_%s_%s.tar.bz2' % (platform, arch) |
(...skipping 28 matching lines...) Expand all Loading... | |
153 def GetToolchainNaClLib(tcpath, arch, xarch): | 170 def GetToolchainNaClLib(tcpath, arch, xarch): |
154 if arch == 'x86': | 171 if arch == 'x86': |
155 if str(xarch) == '32': | 172 if str(xarch) == '32': |
156 return os.path.join(tcpath, 'x86_64-nacl', 'lib32') | 173 return os.path.join(tcpath, 'x86_64-nacl', 'lib32') |
157 if str(xarch) == '64': | 174 if str(xarch) == '64': |
158 return os.path.join(tcpath, 'x86_64-nacl', 'lib') | 175 return os.path.join(tcpath, 'x86_64-nacl', 'lib') |
159 ErrorExit('Unknown architecture.') | 176 ErrorExit('Unknown architecture.') |
160 | 177 |
161 | 178 |
162 def GetBuildArgs(tcname, tcpath, arch, xarch=None): | 179 def GetBuildArgs(tcname, tcpath, arch, xarch=None): |
163 """Return list of scons build arguments to generate user libraries.""" | 180 '''Return list of scons build arguments to generate user libraries.''' |
164 scons = GetScons() | 181 scons = GetScons() |
165 mode = '--mode=opt-host,nacl' | 182 mode = '--mode=opt-host,nacl' |
166 arch_name = GetArchName(arch, xarch) | 183 arch_name = GetArchName(arch, xarch) |
167 plat = 'platform=' + arch_name | 184 plat = 'platform=' + arch_name |
168 bin = ('bindir=' + | 185 bin = ('bindir=' + |
169 BuildOutputDir('pepper_' + build_utils.ChromeMajorVersion(), 'tools')) | 186 BuildOutputDir('pepper_' + build_utils.ChromeMajorVersion(), 'tools')) |
170 lib = ('libdir=' + | 187 lib = ('libdir=' + |
171 os.path.join(GetToolchainNaClLib(tcpath, arch, xarch))) | 188 os.path.join(GetToolchainNaClLib(tcpath, arch, xarch))) |
172 args = [scons, mode, plat, bin, lib, '-j10', | 189 args = [scons, mode, plat, bin, lib, '-j10', |
173 'install_bin', 'install_lib'] | 190 'install_bin', 'install_lib'] |
(...skipping 21 matching lines...) Expand all Loading... | |
195 'nacl_startup.h': 'src/untrusted/nacl/nacl_startup.h', | 212 'nacl_startup.h': 'src/untrusted/nacl/nacl_startup.h', |
196 'nacl_thread.h': 'src/untrusted/nacl/nacl_thread.h', | 213 'nacl_thread.h': 'src/untrusted/nacl/nacl_thread.h', |
197 'pnacl.h': 'src/untrusted/nacl/pnacl.h', | 214 'pnacl.h': 'src/untrusted/nacl/pnacl.h', |
198 'irt.h': 'src/untrusted/irt/irt.h', | 215 'irt.h': 'src/untrusted/irt/irt.h', |
199 'irt_ppapi.h': 'src/untrusted/irt/irt_ppapi.h', | 216 'irt_ppapi.h': 'src/untrusted/irt/irt_ppapi.h', |
200 }, | 217 }, |
201 } | 218 } |
202 | 219 |
203 | 220 |
204 def InstallHeaders(tc_dst_inc, pepper_ver, tc_name): | 221 def InstallHeaders(tc_dst_inc, pepper_ver, tc_name): |
205 """Copies NaCl headers to expected locations in the toolchain.""" | 222 '''Copies NaCl headers to expected locations in the toolchain.''' |
206 tc_map = header_map[tc_name] | 223 tc_map = header_map[tc_name] |
207 for filename in tc_map: | 224 for filename in tc_map: |
208 src = os.path.join(NACL_DIR, tc_map[filename]) | 225 src = os.path.join(NACL_DIR, tc_map[filename]) |
209 dst = os.path.join(tc_dst_inc, filename) | 226 dst = os.path.join(tc_dst_inc, filename) |
210 oshelpers.Copy(['-v', src, dst]) | 227 oshelpers.Copy(['-v', src, dst]) |
211 | 228 |
212 # Clean out per toolchain ppapi directory | 229 # Clean out per toolchain ppapi directory |
213 ppapi = os.path.join(tc_dst_inc, 'ppapi') | 230 ppapi = os.path.join(tc_dst_inc, 'ppapi') |
214 RemoveDir(ppapi) | 231 RemoveDir(ppapi) |
215 | 232 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 MakeDir(os.path.join(tc_dst_inc, 'GLES2')) | 272 MakeDir(os.path.join(tc_dst_inc, 'GLES2')) |
256 CopyDir(os.path.join(PPAPI_DIR,'lib','gl','include','GLES2', '*.h'), | 273 CopyDir(os.path.join(PPAPI_DIR,'lib','gl','include','GLES2', '*.h'), |
257 os.path.join(tc_dst_inc, 'GLES2')) | 274 os.path.join(tc_dst_inc, 'GLES2')) |
258 | 275 |
259 # Copy the KHR headers | 276 # Copy the KHR headers |
260 MakeDir(os.path.join(tc_dst_inc, 'KHR')) | 277 MakeDir(os.path.join(tc_dst_inc, 'KHR')) |
261 CopyDir(os.path.join(PPAPI_DIR,'lib','gl','include','KHR', '*.h'), | 278 CopyDir(os.path.join(PPAPI_DIR,'lib','gl','include','KHR', '*.h'), |
262 os.path.join(tc_dst_inc, 'KHR')) | 279 os.path.join(tc_dst_inc, 'KHR')) |
263 | 280 |
264 | 281 |
265 def main(): | 282 def main(argv): |
266 platform = GetPlatform() | 283 platform = getos.GetPlatform() |
267 arch = 'x86' | 284 arch = 'x86' |
285 # the vars below are intended for debugging | |
268 skip_untar = 0 | 286 skip_untar = 0 |
269 skip_build = 0 | 287 skip_build = 0 |
270 skip_tar = 0 | 288 skip_tar = 0 |
271 skip_examples = 0 | 289 skip_examples = 0 |
272 skip_headers = 0 | 290 skip_headers = 0 |
273 skip_make = 0 | 291 skip_make = 0 |
274 force_archive = 0 | 292 force_archive = 0 |
275 | 293 |
276 pepper_ver = build_utils.ChromeMajorVersion() | 294 pepper_ver = build_utils.ChromeMajorVersion() |
277 clnumber = lastchange.FetchVersionInfo(None).revision | 295 clnumber = lastchange.FetchVersionInfo(None).revision |
278 print 'Building PEPPER %s at %s' % (pepper_ver, clnumber) | 296 print 'Building PEPPER %s at %s' % (pepper_ver, clnumber) |
279 | 297 |
280 BuildStep('Clean Pepper Dir') | 298 BuildStep('Clean Pepper Dir') |
281 pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver) | 299 pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver) |
282 if not skip_untar: | 300 if not skip_untar: |
283 RemoveDir(pepperdir) | 301 RemoveDir(pepperdir) |
284 MakeDir(os.path.join(pepperdir, 'toolchain')) | 302 MakeDir(os.path.join(pepperdir, 'toolchain')) |
285 MakeDir(os.path.join(pepperdir, 'tools')) | 303 MakeDir(os.path.join(pepperdir, 'tools')) |
286 | 304 |
287 BuildStep('Untar Toolchains') | 305 BuildStep('Untar Toolchains') |
288 tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp') | 306 tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp') |
289 tcname = platform + '_' + arch | 307 tcname = platform + '_' + arch |
290 tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp') | 308 tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp') |
291 cygtar = os.path.join(NACL_DIR, 'build', 'cygtar.py') | 309 cygtar = os.path.join(NACL_DIR, 'build', 'cygtar.py') |
292 | 310 |
293 # Clean out the temporary toolchain untar directory | 311 # Clean out the temporary toolchain untar directory |
294 if not skip_untar: | 312 if not skip_untar: |
295 RemoveDir(tmpdir) | 313 RemoveDir(tmpdir) |
296 MakeDir(tmpdir) | 314 MakeDir(tmpdir) |
297 tcname = platform + '_' + arch | 315 tcname = platform + '_' + arch |
298 | 316 |
299 # Untar the newlib toolchains | 317 # Untar the newlib toolchains |
300 tarfile = GetNewlibToolchain(platform, arch) | 318 tarfile = GetNewlibToolchain(platform, arch) |
301 Run([sys.executable, cygtar, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) | 319 Run([sys.executable, cygtar, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) |
302 | 320 |
303 # Then rename/move it to the pepper toolchain directory | 321 # Then rename/move it to the pepper toolchain directory |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 if os.path.isfile(makefile): | 394 if os.path.isfile(makefile): |
377 if platform == 'win': | 395 if platform == 'win': |
378 AddMakeBat(dirnode) | 396 AddMakeBat(dirnode) |
379 print "\n\nMake: " + dirnode | 397 print "\n\nMake: " + dirnode |
380 Run(['make', 'all', '-j8'], cwd=os.path.abspath(dirnode), shell=True) | 398 Run(['make', 'all', '-j8'], cwd=os.path.abspath(dirnode), shell=True) |
381 | 399 |
382 return 0 | 400 return 0 |
383 | 401 |
384 | 402 |
385 if __name__ == '__main__': | 403 if __name__ == '__main__': |
386 sys.exit(main()) | 404 sys.exit(main(sys.argv)) |
387 | |
OLD | NEW |