Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1061)

Side by Side Diff: build_tools/naclports.py

Issue 138913004: Build system for statically-linked Python. (Closed) Base URL: https://naclports.googlecode.com/svn/trunk/src
Patch Set: Final update with merge against current naclports.py Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build_tools/common.sh ('k') | ports/python-static/Setup.local » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Native Client Authors. All rights reserved. 2 # Copyright (c) 2013 The Native Client 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 """Tool for manipulating naclports packages in python. 5 """Tool for manipulating naclports packages in python.
6 6
7 This tool can be used to for working with naclports packages. 7 This tool can be used to for working with naclports packages.
8 It can also be incorporated into other tools that need to 8 It can also be incorporated into other tools that need to
9 work with packages (e.g. 'update_mirror.py' uses it to iterate 9 work with packages (e.g. 'update_mirror.py' uses it to iterate
10 through all packages and mirror them on Google Cloud Storage). 10 through all packages and mirror them on Google Cloud Storage).
11 """ 11 """
12 import optparse 12 import optparse
13 import os 13 import os
14 import posixpath 14 import posixpath
15 import shlex 15 import shlex
16 import shutil 16 import shutil
17 import subprocess 17 import subprocess
18 import sys 18 import sys
19 import tarfile 19 import tarfile
20 import tempfile 20 import tempfile
21 import time 21 import time
22 import urlparse 22 import urlparse
23 23
24 import sha1check 24 import sha1check
25 25
26 MIRROR_URL = 'http://storage.googleapis.com/naclports/mirror' 26 MIRROR_URL = 'http://storage.googleapis.com/naclports/mirror'
27 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 27 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
28 NACLPORTS_ROOT = os.path.dirname(SCRIPT_DIR) 28 NACLPORTS_ROOT = os.path.dirname(SCRIPT_DIR)
29 PORTS_DIR = os.path.join(NACLPORTS_ROOT, "ports")
29 OUT_DIR = os.path.join(NACLPORTS_ROOT, 'out') 30 OUT_DIR = os.path.join(NACLPORTS_ROOT, 'out')
30 STAMP_DIR = os.path.join(OUT_DIR, 'stamp') 31 STAMP_DIR = os.path.join(OUT_DIR, 'stamp')
31 BUILD_ROOT = os.path.join(OUT_DIR, 'build') 32 BUILD_ROOT = os.path.join(OUT_DIR, 'build')
32 ARCHIVE_ROOT = os.path.join(OUT_DIR, 'tarballs') 33 ARCHIVE_ROOT = os.path.join(OUT_DIR, 'tarballs')
33 PACKAGES_ROOT = os.path.join(OUT_DIR, 'packages') 34 PACKAGES_ROOT = os.path.join(OUT_DIR, 'packages')
34 PUBLISH_ROOT = os.path.join(OUT_DIR, 'publish') 35 PUBLISH_ROOT = os.path.join(OUT_DIR, 'publish')
35 PAYLOAD_DIR = 'payload/' 36 PAYLOAD_DIR = 'payload/'
36 37
37 NACL_SDK_ROOT = os.environ.get('NACL_SDK_ROOT') 38 NACL_SDK_ROOT = os.environ.get('NACL_SDK_ROOT')
38 39
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 298
298 class Package(object): 299 class Package(object):
299 """Representation of a single naclports package. 300 """Representation of a single naclports package.
300 301
301 Package objects correspond to folders on disk which 302 Package objects correspond to folders on disk which
302 contain a 'pkg_info' file. 303 contain a 'pkg_info' file.
303 """ 304 """
304 VALID_KEYS = ('NAME', 'VERSION', 'URL', 'ARCHIVE_ROOT', 'LICENSE', 'DEPENDS', 305 VALID_KEYS = ('NAME', 'VERSION', 'URL', 'ARCHIVE_ROOT', 'LICENSE', 'DEPENDS',
305 'MIN_SDK_VERSION', 'LIBC', 'DISABLED_ARCH', 'URL_FILENAME', 306 'MIN_SDK_VERSION', 'LIBC', 'DISABLED_ARCH', 'URL_FILENAME',
306 'BUILD_OS', 'SHA1', 'DISABLED') 307 'BUILD_OS', 'SHA1', 'DISABLED')
308 VALID_SUBDIRS = ('', 'ports', 'python_modules')
307 309
308 def __init__(self, pkg_root): 310 def __init__(self, pkg_root):
309 self.root = os.path.abspath(pkg_root) 311 self.root = os.path.abspath(pkg_root)
310 self.info = os.path.join(pkg_root, 'pkg_info') 312 self.basename = os.path.basename(self.root)
311 keys = [] 313 keys = []
312 for key in Package.VALID_KEYS: 314 for key in Package.VALID_KEYS:
313 setattr(self, key, None) 315 setattr(self, key, None)
314 self.DEPENDS = [] 316 self.DEPENDS = []
315 if not os.path.exists(self.info): 317 self.info = None
318 for subdir in Package.VALID_SUBDIRS:
319 info = os.path.join(PORTS_DIR, subdir, self.basename, 'pkg_info')
320 if os.path.exists(info):
321 self.info = info
322 break
323 if self.info is None:
316 raise Error('Invalid package folder: %s' % pkg_root) 324 raise Error('Invalid package folder: %s' % pkg_root)
325 self.root = os.path.dirname(self.info)
317 326
318 with open(self.info) as f: 327 with open(self.info) as f:
319 for i, line in enumerate(f): 328 for i, line in enumerate(f):
320 if line[0] == '#': 329 if line[0] == '#':
321 continue 330 continue
322 key, value = self.ParsePkgInfoLine(line, i+1) 331 key, value = self.ParsePkgInfoLine(line, i+1)
323 keys.append(key) 332 keys.append(key)
324 setattr(self, key, value) 333 setattr(self, key, value)
325 334
326 for required_key in ('NAME', 'VERSION'): 335 for required_key in ('NAME', 'VERSION'):
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 try: 742 try:
734 run_main(args) 743 run_main(args)
735 except Error as e: 744 except Error as e:
736 sys.stderr.write('naclports: %s\n' % e) 745 sys.stderr.write('naclports: %s\n' % e)
737 return 1 746 return 1
738 747
739 return 0 748 return 0
740 749
741 if __name__ == '__main__': 750 if __name__ == '__main__':
742 sys.exit(main(sys.argv[1:])) 751 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « build_tools/common.sh ('k') | ports/python-static/Setup.local » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698