Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 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 | |
| 5 # BSD-style license that can be found in the LICENSE file. | |
| 6 # | |
| 7 # A script which will be invoked from gyp to create an SDK. The SDK will be | |
| 8 # used either from the command-line or from the editor. Top structure is | |
| 9 # | |
| 10 # ..sdk/ | |
| 11 # ....bin/ | |
| 12 # ......dart or dart.exe (executable) | |
| 13 # ......frogc.dart | |
| 14 # ......frogsh (coming later) | |
| 15 # ......frog/ (frog source code) | |
| 16 # ....lib/ | |
| 17 # ......corelib/ | |
| 18 # ........frog/ (from dart/frog/lib) | |
| 19 # ........share/ (from dart/corelib/src) | |
| 20 # ......dom/ | |
| 21 # ......html/ | |
| 22 # ......(more will come here - io, etc) | |
| 23 # ....utils/ | |
| 24 # ......dartdoc/ | |
| 25 # ......(more will come here) | |
| 26 | |
| 27 | |
| 28 | |
| 29 import os | |
| 30 import re | |
| 31 import utils | |
| 32 | |
| 33 from os.path import dirname, join, realpath, exists, isdir | |
| 34 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree | |
| 35 | |
| 36 HOME = dirname(dirname(realpath(__file__))) | |
| 37 | |
| 38 SDK = join(HOME, 'sdk') | |
| 39 if exists(SDK): | |
| 40 rmtree(SDK) | |
| 41 | |
| 42 # | |
| 43 # Create sdk/bin. | |
| 44 # | |
| 45 | |
| 46 BIN = join(SDK, 'bin') | |
| 47 os.makedirs(BIN) | |
| 48 | |
| 49 # Copy the Dart VM binary into sdk/bin. | |
| 50 # TODO(dgrove) - deal with architectures that are not ia32 | |
|
Ivan Posva
2011/11/22 06:54:42
How do you plan to deal with SDKs for x64 or arm?
dgrove
2011/11/22 19:18:51
I don't have a plan yet, but I definitely agree t
| |
| 51 build_dir = utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32') | |
| 52 if utils.GuessOS() == 'win32': | |
| 53 dart_src_binary = join(join(HOME, build_dir), 'dart.exe') | |
| 54 dart_dest_binary = join(BIN, 'dart.exe') | |
| 55 else: | |
| 56 dart_src_binary = join(join(HOME, build_dir), 'dart') | |
| 57 dart_dest_binary = join(BIN, 'dart') | |
| 58 copyfile(dart_src_binary, dart_dest_binary) | |
| 59 copymode(dart_src_binary, dart_dest_binary) | |
| 60 | |
| 61 # Create sdk/bin/frogc.dart, and hack as needed. | |
| 62 frog_src_dir = join(HOME, 'frog') | |
| 63 | |
| 64 # Convert frogc.dart's imports from import('*') -> import('frog/*'). | |
| 65 frogc_contents = open(join(frog_src_dir, 'frogc.dart')).read() | |
| 66 frogc_dest = open(join(BIN, 'frogc.dart'), 'w') | |
| 67 frogc_dest.write(re.sub("#import\('", "#import('frog/", frogc_contents)) | |
| 68 frogc_dest.close() | |
| 69 | |
| 70 # TODO(dgrove): copy and fix up frog.dart | |
| 71 | |
| 72 # Copy all files from src/frog/ to sdk/bin/frog. | |
| 73 frog_dest_dir = join(BIN, 'frog') | |
| 74 os.makedirs(frog_dest_dir) | |
| 75 | |
| 76 for filename in os.listdir(frog_src_dir): | |
| 77 if filename == 'frog_options.dart': | |
| 78 # change config from 'dev' to 'sdk' in frog_options.dart | |
| 79 frog_options_contents = open(join(frog_src_dir, filename)).read() | |
| 80 frog_options_dest = open(join(frog_dest_dir, filename), 'w') | |
| 81 frog_options_dest.write(re.sub("final config = \'dev\';", | |
| 82 "final config = \'sdk\';", | |
| 83 frog_options_contents)) | |
| 84 frog_options_dest.close() | |
| 85 elif filename.endswith('.dart'): | |
| 86 copyfile(join(frog_src_dir, filename), join(frog_dest_dir, filename)) | |
| 87 | |
| 88 # Copy frog/leg to bin/frog. | |
| 89 copytree(join(frog_src_dir, 'leg'), join(frog_dest_dir, 'leg'), | |
| 90 ignore=ignore_patterns('.svn')) | |
| 91 | |
| 92 # | |
| 93 # Create sdk/lib. | |
| 94 # | |
| 95 | |
| 96 LIB = join(SDK, 'lib') | |
| 97 os.makedirs(LIB) | |
| 98 | |
| 99 html_src_dir = join(HOME, 'client', 'html') | |
| 100 html_dest_dir = join(LIB, 'html') | |
| 101 os.makedirs(html_dest_dir) | |
| 102 | |
| 103 dom_src_dir = join(HOME, 'client', 'dom') | |
| 104 dom_dest_dir = join(LIB, 'dom') | |
| 105 os.makedirs(dom_dest_dir) | |
| 106 | |
| 107 corelib_dest_dir = join(LIB, 'corelib') | |
| 108 os.makedirs(corelib_dest_dir) | |
| 109 os.makedirs(join(corelib_dest_dir, 'frog')) | |
| 110 | |
| 111 copyfile(join(html_src_dir, 'release', 'html.dart'), | |
| 112 join(html_dest_dir, 'html.dart')) | |
| 113 copytree(join(html_src_dir, 'src'), join(html_dest_dir, 'src'), | |
| 114 ignore=ignore_patterns('.svn')) | |
| 115 copytree(join(html_src_dir, 'generated'), join(html_dest_dir, 'generated'), | |
| 116 ignore=ignore_patterns('.svn')) | |
| 117 | |
| 118 for filename in os.listdir(dom_src_dir): | |
| 119 src_file = join(dom_src_dir, filename) | |
| 120 dest_file = join(dom_dest_dir, filename) | |
| 121 if filename.endswith('.dart') or filename.endswith('.js'): | |
| 122 copyfile(src_file, dest_file) | |
| 123 elif isdir(src_file): | |
| 124 if filename not in ['benchmarks', 'idl', 'scripts', 'snippets', '.svn']: | |
| 125 copytree(src_file, dest_file, | |
| 126 ignore=ignore_patterns('.svn', 'interface', 'wrapping', | |
| 127 '*monkey*')) | |
| 128 | |
| 129 | |
| 130 frog_lib_src_dir = join(HOME, 'frog', 'lib') | |
| 131 | |
| 132 for filename in os.listdir(frog_lib_src_dir): | |
| 133 src_file = join(frog_lib_src_dir, filename) | |
| 134 dest_file = join(corelib_dest_dir, 'frog', filename) | |
| 135 if filename.endswith('.dart') or filename.endswith('.js'): | |
| 136 if filename == 'corelib.dart' or filename == 'corelib_impl.dart': | |
| 137 contents = open(src_file).read() | |
| 138 dest_file = open(dest_file, "w") | |
| 139 dest_file.write(re.sub("../../corelib/src/", "../share/", contents)) | |
| 140 dest_file.close() | |
| 141 else: | |
| 142 copyfile(src_file, dest_file) | |
| 143 elif isdir(src_file) and filename != '.svn': | |
| 144 copytree(src_file, dest_file, ignore=ignore_patterns('.svn')) | |
| 145 | |
| 146 copytree(join(HOME, 'corelib', 'src'), join(corelib_dest_dir, 'share'), | |
| 147 ignore=ignore_patterns('.svn')) | |
| 148 | |
| 149 | |
| 150 # Create and copy utils. | |
| 151 | |
| 152 UTIL = join(SDK, 'utils') | |
| 153 os.makedirs(UTIL) | |
| 154 | |
| 155 copytree(join(HOME, 'utils', 'dartdoc'), join(UTIL, 'dartdoc'), | |
| 156 ignore=ignore_patterns('.svn')) | |
| OLD | NEW |