Example #1
0
DARTIUM_DIR = os.path.join('client', 'tests', 'dartium')
DARTIUM_VERSION = os.path.join(DARTIUM_DIR, 'LAST_VERSION')
DARTIUM_LATEST_PATTERN = (
    'gs://dartium-archive/latest/dartium-%(osname)s-%(bot)s-*.zip')
DARTIUM_PERMANENT_PATTERN = ('gs://dartium-archive/dartium-%(osname)s-%(bot)s/'
                             'dartium-%(osname)s-%(bot)s-%(num1)s.%(num2)s.zip')

CHROMEDRIVER_DIR = os.path.join('tools', 'testing', 'dartium-chromedriver')
CHROMEDRIVER_VERSION = os.path.join(CHROMEDRIVER_DIR, 'LAST_VERSION')
CHROMEDRIVER_LATEST_PATTERN = (
    'gs://dartium-archive/latest/chromedriver-%(osname)s-%(bot)s-*.zip')
CHROMEDRIVER_PERMANENT_PATTERN = ('gs://dartium-archive/chromedriver-%(osname)s'
                                  '-%(bot)s/chromedriver-%(osname)s-%(bot)s-%(num1)s.'
                                  '%(num2)s.zip')

SDK_DIR = os.path.join(utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32'),
    'dart-sdk')
SDK_VERSION = os.path.join(SDK_DIR, 'LAST_VERSION')
SDK_LATEST_PATTERN = 'gs://dart-editor-archive-continuous/latest/VERSION'
# TODO(efortuna): Once the x64 VM also is optimized, select the version
# based on whether we are running on a 32-bit or 64-bit system.
SDK_PERMANENT = ('gs://dart-editor-archive-continuous/%(version_num)s/' +
    'dartsdk-%(osname)s-32.zip')

# Dictionary storing the earliest revision of each download we have stored.
LAST_VALID = {'dartium': 4285, 'chromedriver': 7823, 'sdk': 9761, 'drt': 5342}

sys.path.append(os.path.join(GSUTIL_DIR, 'boto'))
import boto

Example #2
0
def GetBuildRoot(mode, arch, sanitizer):
    return utils.GetBuildRoot(HOST_OS, mode, arch, sanitizer)
Example #3
0
def Main(argv):
    # Pull in all of the gpyi files which will be munged into the sdk.
    builtin_runtime_sources = \
      (eval(open("runtime/bin/builtin_sources.gypi").read()))['sources']
    corelib_sources = \
      (eval(open("corelib/src/corelib_sources.gypi").read()))['sources']
    corelib_frog_sources = \
      (eval(open("frog/lib/frog_corelib_sources.gypi").read()))['sources']
    corelib_runtime_sources = \
      (eval(open("runtime/lib/lib_sources.gypi").read()))['sources']
    corelib_compiler_sources =  \
      (eval(open("compiler/compiler_corelib_sources.gypi").read())) \
      ['variables']['compiler_corelib_resources']
    coreimpl_sources = \
      (eval(open("corelib/src/implementation/corelib_impl_sources.gypi").read()))\
      ['sources']
    coreimpl_frog_sources = \
      (eval(open("frog/lib/frog_coreimpl_sources.gypi").read()))['sources']
    coreimpl_runtime_sources = \
      (eval(open("runtime/lib/lib_impl_sources.gypi").read()))['sources']
    json_compiler_sources = \
      (eval(open("compiler/jsonlib_sources.gypi").read())) \
      ['variables']['jsonlib_resources']
    json_frog_sources = \
      (eval(open("frog/lib/frog_json_sources.gypi").read()))['sources']

    HOME = dirname(dirname(realpath(__file__)))

    SDK_tmp = tempfile.mkdtemp()
    SDK = argv[1]

    # TODO(dgrove) - deal with architectures that are not ia32.
    if (os.path.basename(os.path.dirname(SDK)) != utils.GetBuildConf(
            'release', 'ia32')):
        print "SDK is not built in Debug mode."
        if not os.path.exists(SDK):
            # leave empty dir behind
            os.makedirs(SDK)
        exit(0)

    if exists(SDK):
        rmtree(SDK)

    # Create and populate sdk/bin.
    BIN = join(SDK_tmp, 'bin')
    os.makedirs(BIN)

    # Copy the Dart VM binary into sdk/bin.
    # TODO(dgrove) - deal with architectures that are not ia32.
    build_dir = utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32')
    if utils.GuessOS() == 'win32':
        # TODO(dgrove) - deal with frogc.bat
        dart_src_binary = join(HOME, build_dir, 'dart.exe')
        dart_dest_binary = join(BIN, 'dart.exe')
    else:
        frogc_src_binary = join(HOME, 'frog', 'frogc')
        dart_src_binary = join(HOME, build_dir, 'dart')
        dart_dest_binary = join(BIN, 'dart')
        frogc_dest_binary = join(BIN, 'frogc')
    copyfile(dart_src_binary, dart_dest_binary)
    copymode(dart_src_binary, dart_dest_binary)
    copyfile(frogc_src_binary, frogc_dest_binary)
    copymode(frogc_src_binary, frogc_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('../lib/frog/", frogc_contents))
    frogc_dest.close()

    # TODO(dgrove): copy and fix up frog.dart, minfrogc.dart.

    #
    # Create and populate sdk/lib.
    #

    LIB = join(SDK_tmp, 'lib')
    os.makedirs(LIB)
    corelib_dest_dir = join(LIB, 'core')
    os.makedirs(corelib_dest_dir)
    os.makedirs(join(corelib_dest_dir, 'compiler'))
    os.makedirs(join(corelib_dest_dir, 'frog'))
    os.makedirs(join(corelib_dest_dir, 'runtime'))

    coreimpl_dest_dir = join(LIB, 'coreimpl')
    os.makedirs(coreimpl_dest_dir)
    os.makedirs(join(coreimpl_dest_dir, 'compiler'))
    os.makedirs(join(coreimpl_dest_dir, 'frog'))
    os.makedirs(join(coreimpl_dest_dir, 'frog', 'node'))
    os.makedirs(join(coreimpl_dest_dir, 'runtime'))

    #
    # Create and populate lib/runtime.
    #
    builtin_dest_dir = join(LIB, 'builtin')
    os.makedirs(builtin_dest_dir)
    os.makedirs(join(builtin_dest_dir, 'runtime'))
    for filename in builtin_runtime_sources:
        if filename.endswith('.dart'):
            copyfile(join(HOME, 'runtime', 'bin', filename),
                     join(builtin_dest_dir, 'runtime', filename))

    # Construct lib/builtin/builtin_runtime.dart from whole cloth.
    dest_file = open(join(builtin_dest_dir, 'builtin_runtime.dart'), 'w')
    dest_file.write('#library("dart:builtin");\n')
    for filename in builtin_runtime_sources:
        if filename.endswith('.dart'):
            dest_file.write('#source("runtime/' + filename + '");\n')
    dest_file.close()

    #
    # Create and populate lib/frog.
    #
    frog_dest_dir = join(LIB, '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))

    copytree(join(frog_src_dir, 'leg'),
             join(frog_dest_dir, 'leg'),
             ignore=ignore_patterns('.svn'))

    #
    # Create and populate lib/html and lib/htmlimpl.
    #
    html_src_dir = join(HOME, 'client', 'html')
    html_dest_dir = join(LIB, 'html')
    os.makedirs(html_dest_dir)
    htmlimpl_dest_dir = join(LIB, 'htmlimpl')
    os.makedirs(htmlimpl_dest_dir)

    copyfile(join(html_src_dir, 'release', 'html.dart'),
             join(html_dest_dir, 'html.dart'))
    copyfile(join(html_src_dir, 'release', 'htmlimpl.dart'),
             join(htmlimpl_dest_dir, 'htmlimpl.dart'))

    # TODO(dgrove): prune the correct files in html and htmlimpl.
    for target_dir in [html_dest_dir, htmlimpl_dest_dir]:
        copytree(join(html_src_dir, 'src'),
                 join(target_dir, 'src'),
                 ignore=ignore_patterns('.svn'))
        copytree(join(html_src_dir, 'generated'),
                 join(target_dir, 'generated'),
                 ignore=ignore_patterns('.svn'))

    #
    # Create and populate lib/json.
    #

    json_frog_dest_dir = join(LIB, 'json', 'frog')
    json_compiler_dest_dir = join(LIB, 'json', 'compiler')
    os.makedirs(json_frog_dest_dir)
    os.makedirs(json_compiler_dest_dir)

    for filename in json_frog_sources:
        copyfile(join(HOME, 'frog', 'lib', filename),
                 join(json_frog_dest_dir, filename))

    for filename in json_compiler_sources:
        copyfile(join(HOME, 'compiler', filename),
                 join(json_compiler_dest_dir, os.path.basename(filename)))

    # Create json_compiler.dart and json_frog.dart from whole cloth.
    dest_file = open(join(LIB, 'json', 'json_compiler.dart'), 'w')
    dest_file.write('#library("dart:json");\n')
    dest_file.write('#import("compiler/json.dart");\n')
    dest_file.close()
    dest_file = open(join(LIB, 'json', 'json_frog.dart'), 'w')
    dest_file.write('#library("dart:json");\n')
    dest_file.write('#import("frog/json.dart");\n')
    dest_file.close()

    #
    # Create and populate lib/dom.
    #
    dom_src_dir = join(HOME, 'client', 'dom')
    dom_dest_dir = join(LIB, 'dom')
    os.makedirs(dom_dest_dir)

    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*'))

    #
    # Create and populate lib/core.
    #

    # First, copy corelib/* to lib/{compiler, frog, runtime}
    for filename in corelib_sources:
        for target_dir in ['compiler', 'frog', 'runtime']:
            copyfile(join('corelib', 'src', filename),
                     join(corelib_dest_dir, target_dir, filename))

    # Next, copy the compiler sources on top of {core,coreimpl}/compiler
    for filename in corelib_compiler_sources:
        if filename.endswith('.dart'):
            filename = re.sub('lib/', '', filename)
            if (not filename.startswith('implementation/')
                    and not filename.startswith('corelib')):
                copyfile(join('compiler', 'lib', filename),
                         join(corelib_dest_dir, 'compiler', filename))

    # Next, copy the frog library source on top of core/frog
    # TOOD(dgrove): move json to top-level
    for filename in corelib_frog_sources:
        copyfile(join('frog', 'lib', filename),
                 join(corelib_dest_dir, 'frog', filename))

    # Next, copy the runtime library source on top of core/runtime
    for filename in corelib_runtime_sources:
        if filename.endswith('.dart'):
            copyfile(join('runtime', 'lib', filename),
                     join(corelib_dest_dir, 'runtime', filename))

    #
    # At this point, it's time to create lib/core/core*dart .
    #
    # munge frog/lib/corelib.dart into lib/core_frog.dart .
    src_file = join('frog', 'lib', 'corelib.dart')
    dest_file = open(join(corelib_dest_dir, 'core_frog.dart'), 'w')
    contents = open(src_file).read()
    contents = re.sub('source\(\"../../corelib/src/', 'source(\"', contents)
    contents = re.sub("source\(\"", "source(\"frog/", contents)
    dest_file.write(contents)
    dest_file.close()

    # construct lib/core_runtime.dart from whole cloth.
    dest_file = open(join(corelib_dest_dir, 'core_runtime.dart'), 'w')
    dest_file.write('#library("dart:core");\n')
    dest_file.write('#import("dart:coreimpl");\n')
    for filename in corelib_sources:
        dest_file.write('#source("runtime/' + filename + '");\n')
    for filename in corelib_runtime_sources:
        if filename.endswith('.dart'):
            dest_file.write('#source("runtime/' + filename + '");\n')
    dest_file.close()

    # construct lib/core_compiler.dart from whole cloth.
    dest_file = open(join(corelib_dest_dir, 'core_compiler.dart'), 'w')
    dest_file.write('#library("dart:core");\n')
    dest_file.write('#import("dart:coreimpl");\n')
    for filename in os.listdir(join(corelib_dest_dir, 'compiler')):
        dest_file.write('#import("compiler/' + filename + '");\n')
    dest_file.close()

    #
    # Create and populate lib/coreimpl.
    #

    # First, copy corelib/src/implementation to corelib/{compiler, frog, runtime}.
    for filename in coreimpl_sources:
        for target_dir in ['compiler', 'frog', 'runtime']:
            copyfile(join('corelib', 'src', 'implementation', filename),
                     join(coreimpl_dest_dir, target_dir, filename))

    # Next, copy {compiler, frog, runtime}-specific implementations.
    for filename in corelib_compiler_sources:
        if (filename.endswith(".dart")):
            if filename.startswith("lib/implementation/"):
                filename = os.path.basename(filename)
                copyfile(join('compiler', 'lib', 'implementation', filename),
                         join(coreimpl_dest_dir, 'compiler', filename))

    for filename in coreimpl_frog_sources:
        copyfile(join('frog', 'lib', filename),
                 join(coreimpl_dest_dir, 'frog', filename))

    for filename in coreimpl_runtime_sources:
        if filename.endswith('.dart'):
            copyfile(join('runtime', 'lib', filename),
                     join(coreimpl_dest_dir, 'runtime', filename))

    # Create and fix up lib/coreimpl/coreimpl_frog.dart .
    src_file = join('frog', 'lib', 'corelib_impl.dart')
    dest_file = open(join(coreimpl_dest_dir, 'coreimpl_frog.dart'), 'w')
    contents = open(src_file).read()
    contents = re.sub('source\(\"../../corelib/src/implementation/',
                      'source(\"', contents)
    contents = re.sub('source\(\"', 'source(\"frog/', contents)
    dest_file.write(contents)
    dest_file.close()

    # Construct lib/coreimpl/coreimpl_runtime.dart from whole cloth.
    dest_file = open(join(coreimpl_dest_dir, 'coreimpl_runtime.dart'), 'w')
    dest_file.write('#library("dart:coreimpl");\n')
    for filename in coreimpl_sources:
        dest_file.write('#source("runtime/' + filename + '");\n')
    for filename in coreimpl_runtime_sources:
        if filename.endswith('.dart'):
            dest_file.write('#source("runtime/' + filename + '");\n')
    dest_file.close()

    # construct lib/coreimpl_compiler.dart from whole cloth.
    dest_file = open(join(coreimpl_dest_dir, 'coreimpl_compiler.dart'), 'w')
    dest_file.write('#library("dart:coreimpl");\n')
    for filename in os.listdir(join(coreimpl_dest_dir, 'compiler')):
        dest_file.write('#import("compiler/' + filename + '");\n')
    dest_file.close()

    # Create and copy tools.

    UTIL = join(SDK_tmp, 'util')
    os.makedirs(UTIL)

    copytree(join(HOME, 'utils', 'dartdoc'),
             join(UTIL, 'dartdoc'),
             ignore=ignore_patterns('.svn'))

    copytree(SDK_tmp, SDK)
    rmtree(SDK_tmp)
Example #4
0
def GetOutDir(mode, arch, target_os, sanitizer):
    return utils.GetBuildRoot(HOST_OS, mode, arch, target_os, sanitizer)
Example #5
0
    def SplitMultiTest(self, test_path, filename):
        """Takes a file with multiple test case defined.

    Splits the file into multiple TestCase instances.

    Args:
      test_path: temporary dir to write split test case data.
      filename: name of the file to split.

    Returns:
      sequence of test cases split from file.

    Raises:
      TestConfigurationError: when a problem with the multi-test-case
          syntax is encountered.
    """
        (name, extension) = os.path.splitext(os.path.basename(filename))
        with open(filename, 'r') as s:
            source = s.read()
        lines = source.splitlines()
        tags = {}
        for line in lines:
            (unused_code, sep, info) = line.partition(' /// ')
            if sep:
                (tag, sep, kind) = info.partition(': ')
                if tag in tags:
                    if kind != 'continued':
                        raise TestConfigurationError('duplicated tag %s' % tag)
                elif kind not in StandardTestConfiguration.LEGAL_KINDS:
                    raise TestConfigurationError('unrecognized kind %s' % kind)
                else:
                    tags[tag] = kind
        if not tags:
            return {}
        # Prepare directory for generated tests.
        tests = {}
        generated_test_dir = os.path.join(utils.GetBuildRoot(utils.GuessOS()),
                                          'generated_tests')
        generated_test_dir = os.path.join(generated_test_dir, *test_path[:-1])
        if not os.path.exists(generated_test_dir):
            os.makedirs(generated_test_dir)
        # Copy referenced files to generated tests directory.
        referenced_files = self.FindReferencedFiles(lines)
        for referenced_file in referenced_files:
            shutil.copy(
                os.path.join(os.path.dirname(filename), referenced_file),
                os.path.join(generated_test_dir, referenced_file))
        # Generate test for each tag found in the main test file.
        for tag in tags:
            test_lines = []
            for line in lines:
                if ' /// ' in line:
                    if ' /// %s:' % tag in line:
                        test_lines.append(line)
                    else:
                        test_lines.append('// %s' % line)
                else:
                    test_lines.append(line)
            test_filename = os.path.join(generated_test_dir,
                                         '%s_%s%s' % (name, tag, extension))
            with open(test_filename, 'w') as test_file:
                for line in test_lines:
                    print >> test_file, line
            tests[tag] = (tags[tag], test_filename)
        test_filename = os.path.join(generated_test_dir,
                                     '%s%s' % (name, extension))
        with open(test_filename, 'w') as test_file:
            for line in lines:
                if ' /// ' not in line:
                    print >> test_file, line
                else:
                    print >> test_file, '//', line
        tests['none'] = ('', test_filename)
        return tests
Example #6
0
#

# This script builds a Chrome App file (.crx) for Swarm
import os
import platform
import subprocess
import sys

DART_PATH = os.path.normpath(os.path.dirname(__file__) + '/../../..')
CLIENT_PATH = os.path.normpath(DART_PATH + '/client')

# Add the tools directory so we can find utils.py.
sys.path.append(os.path.abspath(DART_PATH + '/tools'))
import utils

buildRoot = CLIENT_PATH + '/' + utils.GetBuildRoot(utils.GuessOS(), 'debug',
                                                   'dartc')


def execute(*command):
    '''
  Executes the given command in a new process. If the command fails (returns
  non-zero) halts the script and returns that exit code.
  '''
    exitcode = subprocess.call(command)
    if exitcode != 0:
        sys.exit(exitcode)


def createChromeApp(buildRoot, antTarget, resultFile):
    buildDir = os.path.join(buildRoot, 'war')
Example #7
0
# Copyright (c) 2013, 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 makes it easy to execute common DOM-related tasks

import os
import subprocess
import sys
from sys import argv

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import utils

dart_out_dir = utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32')
if utils.IsWindows():
    dart_bin = os.path.join(dart_out_dir, 'dart.exe')
else:
    dart_bin = os.path.join(dart_out_dir, 'dart')

dart_dir = os.path.abspath(
    os.path.join(os.path.dirname(os.path.realpath(__file__)), os.path.pardir,
                 os.path.pardir))


def help():
    print(
        'Helper script to make it easy to perform common tasks encountered '
        'during the life of a Dart DOM developer.\n'
        '\n'
Example #8
0
TOOLS_PATH = os.path.join(dirname(dirname(dirname(abspath(__file__)))))
sys.path.append(TOOLS_PATH)
import utils

"""This script runs to track performance and size progress of
different svn revisions. It tests to see if there a newer version of the code on
the server, and will sync and run the performance tests if so."""

DART_INSTALL_LOCATION = abspath(os.path.join(dirname(abspath(__file__)),
                                             '..', '..', '..'))
_suffix = ''
if platform.system() == 'Windows':
  _suffix = '.exe'
DART_VM = os.path.join(DART_INSTALL_LOCATION,
                       utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32'),
                       'dart-sdk',
                       'bin',
                       'dart' + _suffix)
DART_COMPILER = os.path.join(DART_INSTALL_LOCATION,
                             utils.GetBuildRoot(utils.GuessOS(),
                                                'release', 'ia32'),
                             'dart-sdk',
                             'bin',
                             'frogc')

GEO_MEAN = 'Geo-Mean'
COMMAND_LINE = 'commandline'
JS = 'js'
FROG = 'frog'
JS_AND_FROG = [JS, FROG]
Example #9
0
File: gn.py Project: alorenzen/sdk
def get_out_dir(mode, arch, target_os):
  return utils.GetBuildRoot(HOST_OS, mode, arch, target_os)
Example #10
0
def GetOutDir(mode, arch, target_os, use_nnbd):
    return utils.GetBuildRoot(HOST_OS, mode, arch, target_os, use_nnbd)
Example #11
0
def GetBuildRoot(mode, arch):
    return utils.GetBuildRoot(HOST_OS, mode, arch)
Example #12
0
 def GetBuildRoot(self, mode, arch):
     """The top level directory containing compiler, runtime, tools..."""
     result = utils.GetBuildRoot(self.os, mode, arch)
     return result
Example #13
0
def GetOutDir(mode, arch, target_os, kbc):
    return utils.GetBuildRoot(HOST_OS, mode, arch, target_os, kbc=kbc)