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

Unified Diff: tools/create_sdk.py

Issue 8619005: Initial CL to create SDK directory (this will be done as a build step). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« dart.gyp ('K') | « frog/reader.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/create_sdk.py
===================================================================
--- tools/create_sdk.py (revision 0)
+++ tools/create_sdk.py (revision 0)
@@ -0,0 +1,156 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+#
+# A script which will be invoked from gyp to create an SDK. The SDK will be
+# used either from the command-line or from the editor. Top structure is
+#
+# ..sdk/
+# ....bin/
+# ......dart or dart.exe (executable)
+# ......frogc.dart
+# ......frogsh (coming later)
+# ......frog/ (frog source code)
+# ....lib/
+# ......corelib/
+# ........frog/ (from dart/frog/lib)
+# ........share/ (from dart/corelib/src)
+# ......dom/
+# ......html/
+# ......(more will come here - io, etc)
+# ....utils/
+# ......dartdoc/
+# ......(more will come here)
+
+
+
+import os
+import re
+import utils
+
+from os.path import dirname, join, realpath, exists, isdir
+from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree
+
+HOME = dirname(dirname(realpath(__file__)))
+
+SDK = join(HOME, 'sdk')
+if exists(SDK):
+ rmtree(SDK)
+
+#
+# Create sdk/bin.
+#
+
+BIN = join(SDK, 'bin')
+os.makedirs(BIN)
+
+# Copy the Dart VM binary into sdk/bin.
+# 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
+build_dir = utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32')
+if utils.GuessOS() == 'win32':
+ dart_src_binary = join(join(HOME, build_dir), 'dart.exe')
+ dart_dest_binary = join(BIN, 'dart.exe')
+else:
+ dart_src_binary = join(join(HOME, build_dir), 'dart')
+ dart_dest_binary = join(BIN, 'dart')
+copyfile(dart_src_binary, dart_dest_binary)
+copymode(dart_src_binary, dart_dest_binary)
+
+# Create sdk/bin/frogc.dart, and hack as needed.
+frog_src_dir = join(HOME, 'frog')
+
+# Convert frogc.dart's imports from import('*') -> import('frog/*').
+frogc_contents = open(join(frog_src_dir, 'frogc.dart')).read()
+frogc_dest = open(join(BIN, 'frogc.dart'), 'w')
+frogc_dest.write(re.sub("#import\('", "#import('frog/", frogc_contents))
+frogc_dest.close()
+
+# TODO(dgrove): copy and fix up frog.dart
+
+# Copy all files from src/frog/ to sdk/bin/frog.
+frog_dest_dir = join(BIN, 'frog')
+os.makedirs(frog_dest_dir)
+
+for filename in os.listdir(frog_src_dir):
+ if filename == 'frog_options.dart':
+ # change config from 'dev' to 'sdk' in frog_options.dart
+ frog_options_contents = open(join(frog_src_dir, filename)).read()
+ frog_options_dest = open(join(frog_dest_dir, filename), 'w')
+ frog_options_dest.write(re.sub("final config = \'dev\';",
+ "final config = \'sdk\';",
+ frog_options_contents))
+ frog_options_dest.close()
+ elif filename.endswith('.dart'):
+ copyfile(join(frog_src_dir, filename), join(frog_dest_dir, filename))
+
+# Copy frog/leg to bin/frog.
+copytree(join(frog_src_dir, 'leg'), join(frog_dest_dir, 'leg'),
+ ignore=ignore_patterns('.svn'))
+
+#
+# Create sdk/lib.
+#
+
+LIB = join(SDK, 'lib')
+os.makedirs(LIB)
+
+html_src_dir = join(HOME, 'client', 'html')
+html_dest_dir = join(LIB, 'html')
+os.makedirs(html_dest_dir)
+
+dom_src_dir = join(HOME, 'client', 'dom')
+dom_dest_dir = join(LIB, 'dom')
+os.makedirs(dom_dest_dir)
+
+corelib_dest_dir = join(LIB, 'corelib')
+os.makedirs(corelib_dest_dir)
+os.makedirs(join(corelib_dest_dir, 'frog'))
+
+copyfile(join(html_src_dir, 'release', 'html.dart'),
+ join(html_dest_dir, 'html.dart'))
+copytree(join(html_src_dir, 'src'), join(html_dest_dir, 'src'),
+ ignore=ignore_patterns('.svn'))
+copytree(join(html_src_dir, 'generated'), join(html_dest_dir, 'generated'),
+ ignore=ignore_patterns('.svn'))
+
+for filename in os.listdir(dom_src_dir):
+ src_file = join(dom_src_dir, filename)
+ dest_file = join(dom_dest_dir, filename)
+ if filename.endswith('.dart') or filename.endswith('.js'):
+ copyfile(src_file, dest_file)
+ elif isdir(src_file):
+ if filename not in ['benchmarks', 'idl', 'scripts', 'snippets', '.svn']:
+ copytree(src_file, dest_file,
+ ignore=ignore_patterns('.svn', 'interface', 'wrapping',
+ '*monkey*'))
+
+
+frog_lib_src_dir = join(HOME, 'frog', 'lib')
+
+for filename in os.listdir(frog_lib_src_dir):
+ src_file = join(frog_lib_src_dir, filename)
+ dest_file = join(corelib_dest_dir, 'frog', filename)
+ if filename.endswith('.dart') or filename.endswith('.js'):
+ if filename == 'corelib.dart' or filename == 'corelib_impl.dart':
+ contents = open(src_file).read()
+ dest_file = open(dest_file, "w")
+ dest_file.write(re.sub("../../corelib/src/", "../share/", contents))
+ dest_file.close()
+ else:
+ copyfile(src_file, dest_file)
+ elif isdir(src_file) and filename != '.svn':
+ copytree(src_file, dest_file, ignore=ignore_patterns('.svn'))
+
+copytree(join(HOME, 'corelib', 'src'), join(corelib_dest_dir, 'share'),
+ ignore=ignore_patterns('.svn'))
+
+
+# Create and copy utils.
+
+UTIL = join(SDK, 'utils')
+os.makedirs(UTIL)
+
+copytree(join(HOME, 'utils', 'dartdoc'), join(UTIL, 'dartdoc'),
+ ignore=ignore_patterns('.svn'))
« dart.gyp ('K') | « frog/reader.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698