def Main(argv): args = ParseArgs(argv) revision = utils.GetGitRevision() if revision is not None: with open(args.output, 'w') as f: f.write('%s\n' % revision) return 0
def Main(): parser = argparse.ArgumentParser() parser.add_argument( '--fail-loudly', action='store_true', default=False, help= "Return an error code if a prebuilt couldn't be fetched and extracted") args = parser.parse_args() fail_loudly = 1 if args.fail_loudly else 0 prebuilt_enabled = os.environ.get(FLUTTER_PREBUILTS_ENV_VAR, 'false') if prebuilt_enabled == '0' or prebuilt_enabled.lower() == 'false': return 0 os.makedirs(FLUTTER_PREBUILTS_DIR, exist_ok=True) # Read //third_party/dart/tools/VERSION to extract information about the # Dart SDK version. version = utils.ReadVersionFile() if version == None: return fail_loudly channel = version.channel # A short Dart SDK version string used in the download url. if channel == 'be': dart_git_rev = utils.GetGitRevision() semantic_version = 'hash/{}'.format(dart_git_rev) semantic_version = utils.GetSemanticSDKVersion() os_name = GuessOS() if os_name == None: return fail_loudly architectures = ArchitecturesForOS(os_name) if architectures == None: return fail_loudly # Download and extract variants in parallel pool = multiprocessing.Pool() tasks = [(channel, semantic_version, os_name, arch) for arch in architectures] async_results = [pool.apply_async(DownloadAndExtract, t) for t in tasks] success = True for async_result in async_results: result = async_result.get() success = success and (result == 0) return 0 if success else fail_loudly
def Main(argv): args = ParseArgs(argv) # TODO(jcollins-g): switch to version numbers when github has its tags synced revision = utils.GetGitRevision() if revision is None: revision = 'master' output = '''dartdoc: categoryOrder: ["Core", "VM", "Web"] linkToSource: root: '.' uriTemplate: 'https://github.com/dart-lang/sdk/blob/%s/sdk/%%f%%#L%%l%%' ''' % revision with open(args.output, 'w') as f: f.write(output) return 0
def CreateTarball(tarfilename): global ignoredPaths # Used for adding the output directory. # Generate the name of the tarfile version = utils.GetVersion() global versiondir versiondir = 'dart-%s' % version debian_dir = 'tools/linux_dist_support/debian' # Don't include the build directory in the tarball (ignored paths # are relative to DART_DIR). builddir = utils.GetBuildDir(HOST_OS) ignoredPaths.append(builddir) print 'Creating tarball: %s' % tarfilename with tarfile.open(tarfilename, mode='w:gz') as tar: for f in listdir(DART_DIR): tar.add(join(DART_DIR, f), filter=Filter) for f in listdir(join(DART_DIR, debian_dir)): tar.add(join(DART_DIR, debian_dir, f), arcname='%s/debian/%s' % (versiondir, f)) with utils.TempDir() as temp_dir: # Generate and add debian/copyright copyright_file = join(temp_dir, 'copyright') GenerateCopyright(copyright_file) tar.add(copyright_file, arcname='%s/debian/copyright' % versiondir) # Generate and add debian/changelog change_log = join(temp_dir, 'changelog') GenerateChangeLog(change_log, version) tar.add(change_log, arcname='%s/debian/changelog' % versiondir) # For generated version file build dependency, add fake git reflog. empty = join(temp_dir, 'empty') GenerateEmpty(empty) tar.add(empty, arcname='%s/dart/.git/logs/HEAD' % versiondir) # For bleeding_edge add the GIT_REVISION file. if utils.GetChannel() == 'be': git_revision = join(temp_dir, 'GIT_REVISION') GenerateGitRevision(git_revision, utils.GetGitRevision()) tar.add(git_revision, arcname='%s/dart/tools/GIT_REVISION' % versiondir)
def CreateTarball(tarfilename): global ignoredPaths # Used for adding the output directory. # Generate the name of the tarfile version = utils.GetVersion() global versiondir versiondir = 'dartino-%s' % version debian_dir = 'tools/linux_dist_support/debian' # Don't include the build directory in the tarball (ignored paths # are relative to DARTINO_DIR). builddir = utils.GetBuildDir(HOST_OS) ignoredPaths.append(builddir) print 'Creating tarball: %s' % tarfilename with tarfile.open(tarfilename, mode='w:gz') as tar: for f in listdir(DARTINO_DIR): tar.add(join(DARTINO_DIR, f), filter=Filter) for f in listdir(join(DARTINO_DIR, debian_dir)): tar.add(join(DARTINO_DIR, debian_dir, f), arcname='%s/debian/%s' % (versiondir, f)) tar.add(join(DARTINO_DIR, 'platforms/raspberry-pi2/data/dartino-agent'), arcname='%s/debian/dartino-agent.init' % versiondir) tar.add(join(DARTINO_DIR, 'platforms/raspberry-pi2/data/dartino-agent.env'), arcname='%s/debian/dartino-agent.default' % versiondir) with utils.TempDir() as temp_dir: # Generate and add debian/copyright copyright_file = join(temp_dir, 'copyright') GenerateCopyright(copyright_file) tar.add(copyright_file, arcname='%s/debian/copyright' % versiondir) # Generate and add debian/changelog change_log = join(temp_dir, 'changelog') GenerateChangeLog(change_log, version) tar.add(change_log, arcname='%s/debian/changelog' % versiondir) # Add the GIT_REVISION file. git_revision = join(temp_dir, 'GIT_REVISION') GenerateGitRevision(git_revision, utils.GetGitRevision()) tar.add(git_revision, arcname='%s/sdk/tools/GIT_REVISION' % versiondir)
def Main(argv): args = ParseArgs(argv) # TODO(jcollins-g): switch to version numbers when github has its tags synced revision = utils.GetGitRevision() if revision is None: revision = 'master' output = '''dartdoc: categoryOrder: ["Core", "VM", "Web"] linkToSource: root: '.' uriTemplate: 'https://github.com/dart-lang/sdk/blob/%s/sdk/%%f%%#L%%l%%' errors: # Default errors of dartdoc: - duplicate-file - invalid-parameter - no-defining-library-found - tool-error - unresolved-export # Warnings that are elevated to errors: - ambiguous-doc-reference - ambiguous-reexport - broken-link - category-order-gives-missing-package-name - deprecated - ignored-canonical-for - missing-from-search-index - no-canonical-found - no-documentable-libraries - no-library-level-docs - not-implemented - orphaned-file - reexported-private-api-across-packages # - unknown-directive # Disabled due to https://github.com/dart-lang/dartdoc/issues/2353 - unknown-file - unknown-macro - unresolved-doc-reference ''' % revision with open(args.output, 'w') as f: f.write(output) return 0
def Main(): # Pull in all of the gypi files which will be munged into the sdk. HOME = dirname(dirname(realpath(__file__))) (options, args) = GetOptions() SDK = options.sdk_output_dir SDK_tmp = '%s.tmp' % SDK SNAPSHOT = options.snapshot_location # TODO(dgrove) - deal with architectures that are not ia32. if exists(SDK): rmtree(SDK) if exists(SDK_tmp): rmtree(SDK_tmp) os.makedirs(SDK_tmp) # Create and populate sdk/bin. BIN = join(SDK_tmp, 'bin') os.makedirs(BIN) os.makedirs(join(BIN, 'snapshots')) # Copy the Dart VM binary and the Windows Dart VM link library # into sdk/bin. # # TODO(dgrove) - deal with architectures that are not ia32. build_dir = os.path.dirname(SDK) dart_file_extension = '' if HOST_OS == 'win32': dart_file_extension = '.exe' dart_import_lib_src = join(HOME, build_dir, 'dart.lib') dart_import_lib_dest = join(BIN, 'dart.lib') copyfile(dart_import_lib_src, dart_import_lib_dest) dart_src_binary = join(HOME, build_dir, 'dart' + dart_file_extension) dart_dest_binary = join(BIN, 'dart' + dart_file_extension) copyfile(dart_src_binary, dart_dest_binary) copymode(dart_src_binary, dart_dest_binary) # Strip the binaries on platforms where that is supported. if HOST_OS == 'linux' and not options.disable_stripping: subprocess.call(['strip', dart_dest_binary]) elif HOST_OS == 'macos' and not options.disable_stripping: subprocess.call(['strip', '-x', dart_dest_binary]) # # Create and populate sdk/include. # INCLUDE = join(SDK_tmp, 'include') os.makedirs(INCLUDE) copyfile(join(HOME, 'runtime', 'include', 'dart_api.h'), join(INCLUDE, 'dart_api.h')) copyfile(join(HOME, 'runtime', 'include', 'dart_mirrors_api.h'), join(INCLUDE, 'dart_mirrors_api.h')) copyfile(join(HOME, 'runtime', 'include', 'dart_native_api.h'), join(INCLUDE, 'dart_native_api.h')) copyfile(join(HOME, 'runtime', 'include', 'dart_tools_api.h'), join(INCLUDE, 'dart_tools_api.h')) # # Create and populate sdk/lib. # LIB = join(SDK_tmp, 'lib') os.makedirs(LIB) # # Create and populate lib/{async, core, isolate, ...}. # os.makedirs(join(LIB, 'html')) for library in [ join('_blink', 'dartium'), join('_chrome', 'dart2js'), join('_chrome', 'dartium'), join('_internal', 'js_runtime'), join('_internal', 'sdk_library_metadata'), 'async', 'collection', 'convert', 'core', 'developer', 'internal', 'io', 'isolate', join('html', 'dart2js'), join('html', 'dartium'), join('html', 'html_common'), join('indexed_db', 'dart2js'), join('indexed_db', 'dartium'), 'js', 'js_util', 'math', 'mirrors', 'profiler', 'typed_data', join('svg', 'dart2js'), join('svg', 'dartium'), join('web_audio', 'dart2js'), join('web_audio', 'dartium'), join('web_gl', 'dart2js'), join('web_gl', 'dartium'), join('web_sql', 'dart2js'), join('web_sql', 'dartium') ]: copytree(join(HOME, 'sdk', 'lib', library), join(LIB, library), ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh', '.gitignore')) # Copy the platform descriptors. for file_name in [ "dart_client.platform", "dart_server.platform", "dart_shared.platform" ]: copyfile(join(HOME, 'sdk', 'lib', file_name), join(LIB, file_name)) # Copy libraries.dart to lib/_internal/libraries.dart for backwards # compatibility. # # TODO(sigmund): stop copying libraries.dart. Old versions (<=0.25.1-alpha.4) # of the analyzer package do not support the new location of this file. We # should be able to remove the old file once we release a newer version of # analyzer and popular frameworks have migrated to use it. copyfile( join(HOME, 'sdk', 'lib', '_internal', 'sdk_library_metadata', 'lib', 'libraries.dart'), join(LIB, '_internal', 'libraries.dart')) # Create and copy tools. UTIL = join(SDK_tmp, 'util') os.makedirs(UTIL) RESOURCE = join(SDK_tmp, 'lib', '_internal', 'pub', 'asset') os.makedirs(os.path.dirname(RESOURCE)) copytree(join(HOME, 'third_party', 'pkg', 'pub', 'lib', 'src', 'asset'), join(RESOURCE), ignore=ignore_patterns('.svn')) # Copy in 7zip for Windows. if HOST_OS == 'win32': copytree(join(HOME, 'third_party', '7zip'), join(RESOURCE, '7zip'), ignore=ignore_patterns('.svn')) # Copy dart2js/pub. CopyDartScripts(HOME, SDK_tmp) CopySnapshots(SNAPSHOT, SDK_tmp) CopyDartdocResources(HOME, SDK_tmp) CopyAnalyzerSources(HOME, LIB) CopyAnalysisSummaries(SNAPSHOT, LIB) CopyDevCompilerSdk(HOME, LIB) if options.copy_libs: CopyLibs(build_dir, BIN) # Write the 'version' file version = utils.GetVersion() versionFile = open(os.path.join(SDK_tmp, 'version'), 'w') versionFile.write(version + '\n') versionFile.close() # Write the 'revision' file revision = utils.GetGitRevision() if revision is not None: with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: f.write('%s\n' % revision) f.close() Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README')) Copy(join(HOME, 'LICENSE'), join(SDK_tmp, 'LICENSE')) Copy(join(HOME, 'sdk', 'api_readme.md'), join(SDK_tmp, 'lib', 'api_readme.md')) move(SDK_tmp, SDK)
def Main(): parser = argparse.ArgumentParser() parser.add_argument( '--fail-loudly', action='store_true', default=False, help= "Return an error code if a prebuilt couldn't be fetched and extracted") parser.add_argument('--verbose', action='store_true', default='LUCI_CONTEXT' in os.environ, help='Emit verbose output') args = parser.parse_args() fail_loudly = 1 if args.fail_loudly else 0 verbose = args.verbose prebuilt_enabled = os.environ.get(FLUTTER_PREBUILTS_ENV_VAR, 'true') if prebuilt_enabled == '0' or prebuilt_enabled.lower() == 'false': if verbose: print('Skipping prebuild Dart SDK download.') return 0 os.makedirs(FLUTTER_PREBUILTS_DIR, exist_ok=True) # Read //third_party/dart/tools/VERSION to extract information about the # Dart SDK version. version = utils.ReadVersionFile() if version == None: eprint('Failed to read the Dart VERSION file.') return fail_loudly channel = version.channel if verbose: print('Dart SDK channel = "%s".' % channel) # A short Dart SDK version string used in the download url. if channel == 'be': dart_git_rev = utils.GetGitRevision() semantic_version = 'hash/{}'.format(dart_git_rev) else: semantic_version = utils.GetSemanticSDKVersion() if verbose: print('Semantic Dart SDK version = "%s".' % semantic_version) os_name = GuessOS() if os_name == None: return fail_loudly architectures = ArchitecturesForOS(os_name) if architectures == None: return fail_loudly # Work around a bug in Python. # # The multiprocessing package relies on the win32 WaitForMultipleObjects() # call, which supports waiting on a maximum of MAXIMUM_WAIT_OBJECTS (defined # by Windows to be 64) handles, processes in this case. To avoid hitting # this, we limit ourselves to 60 handles (since there are a couple extra # processes launched for the queue reader and thread wakeup reader). # # See: https://bugs.python.org/issue26903 max_processes = os.cpu_count() if sys.platform.startswith(('cygwin', 'win')) and max_processes > 60: max_processes = 60 # Download and extract variants in parallel pool = multiprocessing.Pool(processes=max_processes) tasks = [(channel, semantic_version, os_name, arch, verbose) for arch in architectures] async_results = [pool.apply_async(DownloadAndExtract, t) for t in tasks] success = True for async_result in async_results: result = async_result.get() success = success and (result == 0) return 0 if success else fail_loudly