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

Side by Side Diff: dart/tools/create_sdk.py

Issue 10266011: Shoehorn dart2js into the SDK. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 8 years, 7 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 # 6 #
7 # A script which will be invoked from gyp to create an SDK. 7 # A script which will be invoked from gyp to create an SDK.
8 # 8 #
9 # Usage: create_sdk.py sdk_directory 9 # Usage: create_sdk.py sdk_directory
10 # 10 #
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 saves them back out. subs should by a list of (pattern, replace) tuples.''' 67 saves them back out. subs should by a list of (pattern, replace) tuples.'''
68 for path in paths: 68 for path in paths:
69 contents = open(path).read() 69 contents = open(path).read()
70 for pattern, replace in subs: 70 for pattern, replace in subs:
71 contents = re.sub(pattern, replace, contents) 71 contents = re.sub(pattern, replace, contents)
72 72
73 dest = open(path, 'w') 73 dest = open(path, 'w')
74 dest.write(contents) 74 dest.write(contents)
75 dest.close() 75 dest.close()
76 76
77
78 def Copy(src, dest):
79 copyfile(src, dest)
80 copymode(src, dest)
81
82
83 def CopyDart2Js(build_dir, sdk_root):
84 '''
85 Install dart2js in SDK/lib/dart2js.
86
87 Currently, we copy too much stuff to this location, but the SDK's
88 layout matches the repository's which frees us from rewriting
kasperl 2012/05/02 11:20:46 the repository's -> the layout of the part of the
89 files. The long term plan is to align the layout of the repository
90 and the SDK, at which point we should be able to simplify Main below
91 and share the dart files between the various components to minimize
92 SDK download size.
93 '''
94 copytree('lib', os.path.join(sdk_root, 'lib', 'dart2js', 'lib'),
95 ignore=ignore_patterns('.svn'))
96 copytree(os.path.join('corelib', 'src'),
97 os.path.join(sdk_root, 'lib', 'dart2js', 'corelib', 'src'),
98 ignore=ignore_patterns('.svn'))
99 copytree(os.path.join('runtime', 'lib'),
100 os.path.join(sdk_root, 'lib', 'dart2js', 'runtime', 'lib'),
101 ignore=ignore_patterns('.svn'))
102 copytree(os.path.join('runtime', 'bin'),
103 os.path.join(sdk_root, 'lib', 'dart2js', 'runtime', 'bin'),
104 ignore=ignore_patterns('.svn'))
105 if utils.GuessOS() == 'win32':
106 dart2js = os.path.join(sdk_root, 'bin', 'dart2js.bat')
107 Copy(os.path.join(build_dir, 'dart2js.bat'), dart2js)
108 ReplaceInFiles([dart2js],
109 [(r'%SCRIPTPATH%\.\.\\lib',
110 r'%SCRIPTPATH%..\lib\dart2js\lib')])
111 else:
112 dart2js = os.path.join(sdk_root, 'bin', 'dart2js')
113 Copy(os.path.join(build_dir, 'dart2js'), dart2js)
114 ReplaceInFiles([dart2js],
115 [(r'\$BIN_DIR/\.\./\.\./lib',
116 r'$BIN_DIR/../lib/dart2js/lib')])
117
118
119
77 def Main(argv): 120 def Main(argv):
78 # Pull in all of the gpyi files which will be munged into the sdk. 121 # Pull in all of the gpyi files which will be munged into the sdk.
79 builtin_runtime_sources = \ 122 builtin_runtime_sources = \
80 (eval(open("runtime/bin/builtin_sources.gypi").read()))['sources'] 123 (eval(open("runtime/bin/builtin_sources.gypi").read()))['sources']
81 io_runtime_sources = \ 124 io_runtime_sources = \
82 (eval(open("runtime/bin/io_sources.gypi").read()))['sources'] 125 (eval(open("runtime/bin/io_sources.gypi").read()))['sources']
83 corelib_sources = \ 126 corelib_sources = \
84 (eval(open("corelib/src/corelib_sources.gypi").read()))['sources'] 127 (eval(open("corelib/src/corelib_sources.gypi").read()))['sources']
85 corelib_frog_sources = \ 128 corelib_frog_sources = \
86 (eval(open("frog/lib/frog_corelib_sources.gypi").read()))['sources'] 129 (eval(open("frog/lib/frog_corelib_sources.gypi").read()))['sources']
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 460
418 461
419 # Copy import maps 462 # Copy import maps
420 PLATFORMS = ['any', 'vm', 'dartium', 'dart2js', 'frog' ] 463 PLATFORMS = ['any', 'vm', 'dartium', 'dart2js', 'frog' ]
421 os.makedirs(join(LIB, 'config')) 464 os.makedirs(join(LIB, 'config'))
422 for platform in PLATFORMS: 465 for platform in PLATFORMS:
423 import_src = join(HOME, 'lib', 'config', 'import_' + platform + '.config') 466 import_src = join(HOME, 'lib', 'config', 'import_' + platform + '.config')
424 import_dst = join(LIB, 'config', 'import_' + platform + '.config') 467 import_dst = join(LIB, 'config', 'import_' + platform + '.config')
425 copyfile(import_src, import_dst); 468 copyfile(import_src, import_dst);
426 469
470 CopyDart2Js(build_dir, SDK_tmp)
471
427 # Write the 'revision' file 472 # Write the 'revision' file
428 revision = utils.GetSVNRevision() 473 revision = utils.GetSVNRevision()
429 if revision is not None: 474 if revision is not None:
430 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: 475 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f:
431 f.write(revision + '\n') 476 f.write(revision + '\n')
432 f.close() 477 f.close()
433 478
434 move(SDK_tmp, SDK) 479 move(SDK_tmp, SDK)
435 utils.Touch(os.path.join(SDK, 'create.stamp')) 480 utils.Touch(os.path.join(SDK, 'create.stamp'))
436 481
437 if __name__ == '__main__': 482 if __name__ == '__main__':
438 sys.exit(Main(sys.argv)) 483 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/filenames.dart ('k') | dart/tools/testing/dart/test_options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698