Beispiel #1
0
def main(argv):
    args = parse_args(argv)

    manifest_output = args.output + '.manifest'
    with open(manifest_output, 'w') as manifest:
        # Write the Dart tree.
        for root, dirs, files in os.walk(DART_ROOT):
            dirs[:] = [d for d in dirs if d not in EXCLUDE_DIRS]
            for file in files:
                filepath = os.path.join(root, file)
                relpath = filepath[len(DART_ROOT) + 1:]
                fuchsiapath = os.path.join(FUCHSIA_TEST_MANIFEST_PREFIX,
                                           relpath)
                manifest.write(
                    '%s=%s\n' % (fuchsiapath, os.path.join(root, file)))

        dart_conf = utils.GetBuildConf(args.mode, args.arch)
        dart_out = os.path.join(FUCHSIA_TEST_MANIFEST_PREFIX, 'out', dart_conf)
        fuchsia_conf = '%s-%s' % (args.mode, fuchsia_arch(args.arch))
        fuchsia_out = os.path.join(FUCHSIA_ROOT, 'out', fuchsia_conf)
        for file in BINARY_FILES:
            manifest.write('%s=%s\n' % (os.path.join(dart_out, file),
                                        os.path.join(fuchsia_out, file)))

    return 0
Beispiel #2
0
def main(argv):
  #allow local editor builds to deploy to a different bucket
  if os.environ.has_key('DART_LOCAL_BUILD'):
    gsdir = os.environ['DART_LOCAL_BUILD']
  else:
    gsdir = GS_DIR
    
  if not os.path.exists(argv[1]):
    sys.stderr.write('Path not found: %s\n' % argv[1])
    Usage(argv[0])
    return 1

  if not os.path.exists(GSUTIL):
    #TODO: Determine where we are running, if we're running on a buildbot we
    #should fail with a message.  
    #If we are not on a buildbot then fail silently. 
    utils.Touch(os.path.join(argv[1], 'upload.stamp'))
    exit(0)
  
  revision = utils.GetSVNRevision()
  if revision is None:
    sys.stderr.write('Unable to find SVN revision.\n')
    return 1

  os.chdir(os.path.dirname(argv[1]))

  if (os.path.basename(os.path.dirname(argv[1])) ==
      utils.GetBuildConf('release', 'ia32')):
    sdk_suffix = ''
  else:
    sdk_suffix = '-debug'
  # TODO(dgrove) - deal with architectures that are not ia32.
  sdk_file_zip = 'dart-%s-%s%s.zip' % (utils.GuessOS(), revision, sdk_suffix)
  sdk_file_targz = 'dart-%s-%s%s.tar.gz' % (utils.GuessOS(), revision,
      sdk_suffix)
  if (os.path.exists(SDK_LOCAL_ZIP)):
    os.remove(SDK_LOCAL_ZIP)
  if (os.path.exists(SDK_LOCAL_TARGZ)):
    os.remove(SDK_LOCAL_TARGZ)
  if platform.system() == 'Windows':
    # Windows does not have zip. We use the 7 zip utility in third party.
    ExecuteCommand([os.path.join('..', 'third_party', '7zip', '7za'), 'a',
        '-tzip', SDK_LOCAL_ZIP, os.path.basename(argv[1])])
  else:
    ExecuteCommand(['zip', '-yr', SDK_LOCAL_ZIP, os.path.basename(argv[1])])
    ExecuteCommand(['tar', 'czf', SDK_LOCAL_TARGZ, os.path.basename(argv[1])])
  UploadArchive(SDK_LOCAL_ZIP,
                GS_SITE + '/'.join([gsdir, GS_SDK_DIR, sdk_file_zip]))
  if (os.path.exists(SDK_LOCAL_TARGZ)):
    UploadArchive(SDK_LOCAL_TARGZ,
                GS_SITE + '/'.join([gsdir, GS_SDK_DIR, sdk_file_targz]))
  latest_name_zip = 'dart-%s-latest%s.zip' % (utils.GuessOS(), sdk_suffix)
  latest_name_targz = 'dart-%s-latest%s.tar.gz' % (utils.GuessOS(), sdk_suffix)
  UploadArchive(SDK_LOCAL_ZIP,
                GS_SITE + '/'.join([gsdir, GS_SDK_DIR, latest_name_zip]))
  if (os.path.exists(SDK_LOCAL_TARGZ)):
    UploadArchive(SDK_LOCAL_TARGZ,
                GS_SITE + '/'.join([gsdir, GS_SDK_DIR, latest_name_targz]))
  utils.Touch('upload.stamp')
Beispiel #3
0
def main():
    GetOptions()

    SetGsutil()

    # Execute Docgen.dart on the SDK.
    utils.ExecuteCommand(['python', 'dartdoc.py', '-d'])

    # Use SVN Revision to get the revision number.
    revision = None
    if trustSVN:
        revision = utils.GetSVNRevision()

    if revision is None:
        # Try to find the version from the dart-sdk folder.
        revision_file_location = abspath(
            join(
                dirname(__file__), '../../../%s/%s/dart-sdk/revision' %
                (utils.BUILD_ROOT[utils.GuessOS()],
                 utils.GetBuildConf('release', utils.GuessArchitecture()))))
        with open(revision_file_location, 'r') as revision_file:
            revision = revision_file.readline(5)
            revision_file.close()

        if revision is None:
            raise Exception("Unable to find revision. ")

    # Upload the all files in Docs into a folder based off Revision number on
    # Cloud Storage.
    # TODO(alanknight): If we give it ./docs/* it fails to upload files in the
    # subdirectory, probably due to escaping. Work around it by changing dir.
    # Better, generalize this to be less dependent on the working directory.
    os.chdir('docs')
    Upload('.', GS_SITE + '/' + revision + '/')
    os.chdir('..')

    # Update VERSION file in Cloud Storage.
    with open('VERSION', 'w') as version_file:
        version_file.write(revision)
        version_file.close()
    Upload('./VERSION', GS_SITE + '/VERSION')
    Upload('./VERSION', GS_SITE + '/' + revision + '/' + 'VERSION')

    # Clean up the files it creates.
    utils.ExecuteCommand(['rm', '-rf', './docs'])
    utils.ExecuteCommand(['rm', '-f', './VERSION'])
Beispiel #4
0
def BuildOneConfig(options, targets, target_os, mode, arch, sanitizer):
    build_config = utils.GetBuildConf(mode, arch, target_os, sanitizer)
    out_dir = utils.GetBuildRoot(HOST_OS, mode, arch, target_os, sanitizer)
    using_goma = False
    command = ['ninja', '-C', out_dir]
    if options.verbose:
        command += ['-v']
    if UseGoma(out_dir):
        if options.no_start_goma or EnsureGomaStarted(out_dir):
            using_goma = True
            command += [('-j%s' % str(options.j))]
            command += [('-l%s' % str(options.l))]
        else:
            # If we couldn't ensure that goma is started, let the build start, but
            # slowly so we can see any helpful error messages that pop out.
            command += ['-j1']
    command += targets
    return (build_config, command, using_goma)
Beispiel #5
0
def BuildOneConfig(options, targets, target_os, mode, arch, kbc):
    build_config = utils.GetBuildConf(mode, arch, target_os, kbc=kbc)
    out_dir = utils.GetBuildRoot(HOST_OS, mode, arch, target_os, kbc=kbc)
    using_goma = False
    # TODO(zra): Remove auto-run of gn, replace with prompt for user to run
    # gn.py manually.
    if ShouldRunGN(out_dir):
        RunGN(target_os, mode, arch)
    command = ['ninja', '-C', out_dir]
    if options.verbose:
        command += ['-v']
    if UseGoma(out_dir):
        if options.no_start_goma or EnsureGomaStarted(out_dir):
            using_goma = True
            command += [('-j%s' % str(options.j))]
        else:
            # If we couldn't ensure that goma is started, let the build start, but
            # slowly so we can see any helpful error messages that pop out.
            command += ['-j1']
    command += targets
    return (build_config, command, using_goma)
Beispiel #6
0
def Main():
    utils.ConfigureJava()
    # Parse the options.
    parser = BuildOptions()
    (options, args) = parser.parse_args()
    if not ProcessOptions(options, args):
        parser.print_help()
        return 1
    # Determine which targets to build. By default we build the "all" target.
    if len(args) == 0:
        if HOST_OS == 'macos':
            targets = ['All']
        else:
            targets = ['samples']
    else:
        targets = args

    filter_xcodebuild_output = False
    # Remember path
    old_path = os.environ['PATH']
    # Build all targets for each requested configuration.
    for target in targets:
        for target_os in options.os:
            for mode in options.mode:
                for arch in options.arch:
                    os.environ['DART_BUILD_MODE'] = mode
                    build_config = utils.GetBuildConf(mode, arch)
                    if HOST_OS == 'macos':
                        filter_xcodebuild_output = True
                        project_file = 'dart.xcodeproj'
                        if os.path.exists('dart-%s.gyp' %
                                          CurrentDirectoryBaseName()):
                            project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName(
                            )
                        args = [
                            'xcodebuild', '-project', project_file, '-target',
                            target, '-configuration', build_config,
                            'SYMROOT=%s' % os.path.abspath('xcodebuild')
                        ]
                    elif HOST_OS == 'win32':
                        project_file = 'dart.sln'
                        if os.path.exists('dart-%s.gyp' %
                                          CurrentDirectoryBaseName()):
                            project_file = 'dart-%s.sln' % CurrentDirectoryBaseName(
                            )
                        if target == 'all':
                            args = [
                                options.devenv + os.sep + options.executable,
                                '/build', build_config, project_file
                            ]
                        else:
                            args = [
                                options.devenv + os.sep + options.executable,
                                '/build', build_config, '/project', target,
                                project_file
                            ]
                    else:
                        make = 'make'
                        if HOST_OS == 'freebsd':
                            make = 'gmake'
                            # work around lack of flock
                            os.environ['LINK'] = '$(CXX)'
                        args = [
                            make,
                            '-j',
                            options.j,
                            'BUILDTYPE=' + build_config,
                        ]
                        if target_os != HOST_OS:
                            args += [
                                'builddir_name=' +
                                utils.GetBuildDir(HOST_OS, target_os)
                            ]
                        if options.verbose:
                            args += ['V=1']

                        args += [target]

                    if target_os != HOST_OS:
                        SetCrossCompilationEnvironment(HOST_OS, target_os,
                                                       arch, old_path)
                    else:
                        gypDefinesList = ['target_arch=%s' % arch]
                        os.environ['GYP_DEFINES'] = ' '.join(gypDefinesList)

                    RunhooksIfNeeded(HOST_OS, mode, arch, target_os)

                    toolchainprefix = None
                    if target_os == 'android':
                        if arch == 'ia32':
                            toolchainprefix = ('%s/i686-linux-android' %
                                               os.environ['ANDROID_TOOLCHAIN'])

                        if arch == 'arm':
                            toolchainprefix = ('%s/arm-linux-androideabi' %
                                               os.environ['ANDROID_TOOLCHAIN'])

                        sysroot = os.environ[
                            'ANDROID_NDK_ROOT'] + "/platforms/android-19/arch-arm"
                        args.append("CFLAGS=--sysroot=" + sysroot)
                        args.append(
                            "CXXFLAGS=-Ithird_party/dart/third_party/android_tools/ndk/sources/cxx-stl/stlport/stlport/ --sysroot="
                            + sysroot)
                        args.append("LDFLAGS=--sysroot=" + sysroot)

                    toolsOverride = SetTools(arch, toolchainprefix)
                    if toolsOverride:
                        printToolOverrides = target_os != 'android'
                        for k, v in toolsOverride.iteritems():
                            args.append(k + "=" + v)
                            if printToolOverrides:
                                print k + " = " + v
                        if not os.path.isfile(toolsOverride['CC.target']):
                            if arch == 'arm':
                                print arm_cc_error
                            else:
                                print "Couldn't find compiler: %s" % toolsOverride[
                                    'CC.target']
                            return 1

                    process = None
                    if filter_xcodebuild_output:
                        process = subprocess.Popen(
                            args,
                            stdin=None,
                            bufsize=1,  # Line buffered.
                            stdout=subprocess.PIPE,
                            stderr=subprocess.STDOUT)
                        FilterEmptyXcodebuildSections(process)
                    else:
                        process = subprocess.Popen(args, stdin=None)
                    process.wait()
                    if process.returncode != 0:
                        print "BUILD FAILED"
                        return 1

    return 0
Beispiel #7
0
def BuildOneConfig(options, target, target_os, mode, arch, override_tools):
  global filter_xcodebuild_output
  start_time = time.time()
  args = []
  build_config = utils.GetBuildConf(mode, arch, target_os)
  if not options.gyp:
    args = BuildNinjaCommand(options, target, target_os, mode, arch)
  else:
    os.environ['DART_BUILD_MODE'] = mode
    if HOST_OS == 'macos':
      filter_xcodebuild_output = True
      project_file = 'dart.xcodeproj'
      if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()):
        project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName()
      if target == 'all':
        target = 'All'
      args = ['xcodebuild',
              '-project',
              project_file,
              '-target',
              target,
              '-configuration',
              build_config,
              'SYMROOT=%s' % os.path.abspath('xcodebuild')
              ]
    elif HOST_OS == 'win32':
      project_file = 'dart.sln'
      if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()):
        project_file = 'dart-%s.sln' % CurrentDirectoryBaseName()
      # Select a platform suffix to pass to devenv.
      if arch == 'ia32':
        platform_suffix = 'Win32'
      elif arch == 'x64':
        platform_suffix = 'x64'
      else:
        print 'Unsupported arch for MSVC build: %s' % arch
        return 1
      config_name = '%s|%s' % (build_config, platform_suffix)
      if target == 'all':
        args = [options.devenv + os.sep + options.executable,
                '/build',
                config_name,
                project_file
               ]
      else:
        args = [options.devenv + os.sep + options.executable,
                '/build',
                config_name,
                '/project',
                target,
                project_file
               ]
    else:
      make = 'make'
      if HOST_OS == 'freebsd':
        make = 'gmake'
        # work around lack of flock
        os.environ['LINK'] = '$(CXX)'
      args = [make,
              '-j',
              options.j,
              'BUILDTYPE=' + build_config,
              ]
      if target_os != HOST_OS:
        args += ['builddir_name=' + utils.GetBuildDir(HOST_OS)]
      if options.verbose:
        args += ['V=1']

      args += [target]

    toolsOverride = None
    if override_tools:
      toolsOverride = SetTools(arch, target_os, options)
    if toolsOverride:
      for k, v in toolsOverride.iteritems():
        args.append(  k + "=" + v)
        if options.verbose:
          print k + " = " + v
      if not os.path.isfile(toolsOverride['CC.target']):
        if arch == 'arm':
          print arm_cc_error
        else:
          print "Couldn't find compiler: %s" % toolsOverride['CC.target']
        return 1

  print ' '.join(args)
  process = None
  if filter_xcodebuild_output:
    process = subprocess.Popen(args,
                               stdin=None,
                               bufsize=1, # Line buffered.
                               stdout=subprocess.PIPE,
                               stderr=subprocess.STDOUT)
    FilterEmptyXcodebuildSections(process)
  else:
    process = subprocess.Popen(args, stdin=None)
  process.wait()
  if process.returncode != 0:
    NotifyBuildDone(build_config, success=False, start=start_time)
    return 1
  else:
    NotifyBuildDone(build_config, success=True, start=start_time)

  return 0
Beispiel #8
0
def Main():
    utils.ConfigureJava()
    # Parse the options.
    parser = BuildOptions()
    (options, args) = parser.parse_args()
    if not ProcessOptions(options):
        parser.print_help()
        return 1
    # Determine which targets to build. By default we build the "all" target.
    if len(args) == 0:
        if HOST_OS == 'macos':
            target = 'All'
        else:
            target = 'all'
    else:
        target = args[0]
    # Build the targets for each requested configuration.
    for mode in options.mode:
        for arch in options.arch:
            build_config = utils.GetBuildConf(mode, arch)
            if HOST_OS == 'macos':
                project_file = 'dart.xcodeproj'
                if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()):
                    project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName(
                    )
                args = [
                    'xcodebuild', '-project', project_file, '-target', target,
                    '-parallelizeTargets', '-configuration', build_config,
                    'SYMROOT=%s' % os.path.abspath('xcodebuild')
                ]
            elif HOST_OS == 'win32':
                project_file = 'dart.sln'
                if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()):
                    project_file = 'dart-%s.sln' % CurrentDirectoryBaseName()
                if target == 'all':
                    args = [
                        options.devenv + os.sep + 'devenv.com', '/build',
                        build_config, project_file
                    ]
                else:
                    args = [
                        options.devenv + os.sep + 'devenv.com', '/build',
                        build_config, '/project', target, project_file
                    ]
            else:
                make = 'make'
                if HOST_OS == 'freebsd':
                    make = 'gmake'
                    # work around lack of flock
                    os.environ['LINK'] = '$(CXX)'
                args = [
                    make,
                    '-j',
                    options.j,
                    'BUILDTYPE=' + build_config,
                ]
                if options.verbose:
                    args += ['V=1']

                args += [target]

            toolsOverride = setTools(arch)
            if toolsOverride:
                for k, v in toolsOverride.iteritems():
                    args.append(k + "=" + v)
                    print k + " = " + v

            print ' '.join(args)
            process = subprocess.Popen(args)
            process.wait()
            if process.returncode != 0:
                print "BUILD FAILED"
                return 1

    return 0
Beispiel #9
0
 def _GetNativeDest(self, mode, name):
     return path.join('native', self._os, utils.GetBuildConf(mode, 'ia32'),
                      name)
Beispiel #10
0
 def GetBuildConf(self, mode, arch):
     result = utils.GetBuildConf(mode, arch)
     return result
Beispiel #11
0
def Main():
    utils.ConfigureJava()
    # Parse the options.
    parser = BuildOptions()
    (options, args) = parser.parse_args()
    if not ProcessOptions(options, args):
        parser.print_help()
        return 1
    # Determine which targets to build. By default we build the "all" target.
    if len(args) == 0:
        if HOST_OS == 'macos':
            targets = ['All']
        else:
            targets = ['all']
    else:
        targets = args

    filter_xcodebuild_output = False
    # Build all targets for each requested configuration.
    for target in targets:
        for target_os in options.os:
            for mode in options.mode:
                for arch in options.arch:
                    start_time = time.time()
                    os.environ['DART_BUILD_MODE'] = mode
                    build_config = utils.GetBuildConf(mode, arch, target_os)
                    if HOST_OS == 'macos':
                        filter_xcodebuild_output = True
                        project_file = 'dart.xcodeproj'
                        if os.path.exists('dart-%s.gyp' %
                                          CurrentDirectoryBaseName()):
                            project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName(
                            )
                        args = [
                            'xcodebuild', '-project', project_file, '-target',
                            target, '-configuration', build_config,
                            'SYMROOT=%s' % os.path.abspath('xcodebuild')
                        ]
                    elif HOST_OS == 'win32':
                        project_file = 'dart.sln'
                        if os.path.exists('dart-%s.gyp' %
                                          CurrentDirectoryBaseName()):
                            project_file = 'dart-%s.sln' % CurrentDirectoryBaseName(
                            )
                        if target == 'all':
                            args = [
                                options.devenv + os.sep + options.executable,
                                '/build', build_config, project_file
                            ]
                        else:
                            args = [
                                options.devenv + os.sep + options.executable,
                                '/build', build_config, '/project', target,
                                project_file
                            ]
                    else:
                        make = 'make'
                        if HOST_OS == 'freebsd':
                            make = 'gmake'
                            # work around lack of flock
                            os.environ['LINK'] = '$(CXX)'
                        args = [
                            make,
                            '-j',
                            options.j,
                            'BUILDTYPE=' + build_config,
                        ]
                        if target_os != HOST_OS:
                            args += [
                                'builddir_name=' +
                                utils.GetBuildDir(HOST_OS, target_os)
                            ]
                        if options.verbose:
                            args += ['V=1']

                        args += [target]

                    toolchainprefix = options.toolchain
                    toolsOverride = SetTools(arch, target_os, toolchainprefix)
                    if toolsOverride:
                        for k, v in toolsOverride.iteritems():
                            args.append(k + "=" + v)
                            if options.verbose:
                                print k + " = " + v
                        if not os.path.isfile(toolsOverride['CC.target']):
                            if arch == 'arm':
                                print arm_cc_error
                            else:
                                print "Couldn't find compiler: %s" % toolsOverride[
                                    'CC.target']
                            return 1

                    print ' '.join(args)
                    process = None
                    if filter_xcodebuild_output:
                        process = subprocess.Popen(
                            args,
                            stdin=None,
                            bufsize=1,  # Line buffered.
                            stdout=subprocess.PIPE,
                            stderr=subprocess.STDOUT)
                        FilterEmptyXcodebuildSections(process)
                    else:
                        process = subprocess.Popen(args, stdin=None)
                    process.wait()
                    if process.returncode != 0:
                        NotifyBuildDone(build_config,
                                        success=False,
                                        start=start_time)
                        return 1
                    else:
                        NotifyBuildDone(build_config,
                                        success=True,
                                        start=start_time)

    return 0
Beispiel #12
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)
Beispiel #13
0
def Main():
  utils.ConfigureJava()
  # Parse the options.
  parser = BuildOptions()
  (options, args) = parser.parse_args()
  if not ProcessOptions(options, args):
    parser.print_help()
    return 1
  # Determine which targets to build. By default we build the "all" target.
  if len(args) == 0:
    if HOST_OS == 'macos':
      target = 'All'
    else:
      target = 'all'
  else:
    target = args[0]

  # Remember path
  old_path = os.environ['PATH']
  # Build the targets for each requested configuration.
  for target_os in options.os:
    for mode in options.mode:
      for arch in options.arch:
        build_config = utils.GetBuildConf(mode, arch)
        if HOST_OS == 'macos':
          project_file = 'dart.xcodeproj'
          if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()):
            project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName()
          args = ['xcodebuild',
                  '-project',
                  project_file,
                  '-target',
                  target,
                  '-parallelizeTargets',
                  '-configuration',
                  build_config,
                  'SYMROOT=%s' % os.path.abspath('xcodebuild')
                  ]
        elif HOST_OS == 'win32':
          project_file = 'dart.sln'
          if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()):
            project_file = 'dart-%s.sln' % CurrentDirectoryBaseName()
          if target == 'all':
            args = [options.devenv + os.sep + 'devenv.com',
                    '/build',
                    build_config,
                    project_file
                   ]
          else:
            args = [options.devenv + os.sep + 'devenv.com',
                    '/build',
                    build_config,
                    '/project',
                    target,
                    project_file
                   ]
        else:
          make = 'make'
          if HOST_OS == 'freebsd':
            make = 'gmake'
            # work around lack of flock
            os.environ['LINK'] = '$(CXX)'
          args = [make,
                  '-j',
                  options.j,
                  'BUILDTYPE=' + build_config,
                  ]
          if target_os != HOST_OS:
            args += ['builddir_name=' + utils.GetBuildDir(HOST_OS, target_os)]
          if options.verbose:
            args += ['V=1']

          args += [target]

        if target_os != HOST_OS:
          SetCrossCompilationEnvironment(
              HOST_OS, target_os, arch, old_path)

        RunhooksIfNeeded(HOST_OS, mode, arch, target_os)

        toolchainprefix = None
        if target_os == 'android':
          toolchainprefix = ('%s/i686-linux-android'
                              % os.environ['ANDROID_TOOLCHAIN'])
        toolsOverride = SetTools(arch, toolchainprefix)
        if toolsOverride:
          printToolOverrides = target_os != 'android'
          for k, v in toolsOverride.iteritems():
            args.append(  k + "=" + v)
            if printToolOverrides:
              print k + " = " + v

        print ' '.join(args)
        process = subprocess.Popen(args)
        process.wait()
        if process.returncode != 0:
          print "BUILD FAILED"
          return 1

  return 0
Beispiel #14
0
"""

import optparse
import os
from os.path import join, dirname, abspath, exists
import platform
import subprocess
import sys
sys.path.append(abspath(join(dirname(__file__), '../../../tools')))
import utils

DART = abspath(
    join(
        dirname(__file__), '../../../%s/%s/dart-sdk/bin/dart' %
        (utils.BUILD_ROOT[utils.GuessOS()],
         utils.GetBuildConf('release', utils.GuessArchitecture()))))
PACKAGE_ROOT = abspath(
    join(
        dirname(__file__), '../../../%s/%s/packages/' %
        (utils.BUILD_ROOT[utils.GuessOS()],
         utils.GetBuildConf('release', utils.GuessArchitecture()))))
GSUTIL = utils.GetBuildbotGSUtilPath()
GS_SITE = 'gs://dartlang-docgen'
DESCRIPTION = 'Runs docgen.dart on the SDK libraries, and uploads them to Google \
    Cloud Storage for the dartdoc-viewer. '

# Allow us to override checking SVN's revision number. Useful for development
# so we can upload docs from a branch using an SDK that was built on a
# revision newer than when the branch was forked.
trustSVN = None