Exemple #1
0
def FormatVersionString(version,
                        no_git_hash,
                        custom_for_pub,
                        version_file=None,
                        git_revision_file=None):
    use_git_hash = not no_git_hash

    semantic_sdk_version = utils.GetSemanticSDKVersion(no_git_hash,
                                                       version_file,
                                                       git_revision_file)
    semantic_version_format = GetSemanticVersionFormat(no_git_hash,
                                                       custom_for_pub)
    version_str = (semantic_sdk_version
                   if version_file else semantic_version_format)

    version = version.replace('{{VERSION_STR}}', version_str)

    version = version.replace('{{SEMANTIC_SDK_VERSION}}', semantic_sdk_version)

    if custom_for_pub:
        # LATEST is only used for custom_for_pub.
        latest = None
        if use_git_hash:
            # If grabbing the dev tag fails, then fall back on the default VERSION file.
            latest = utils.GetLatestDevTag()
        if not latest:
            latest = utils.GetSemanticSDKVersion(no_git_hash=True)
        version = version.replace('{{LATEST}}', latest)

        version = version.replace('{{PUB_CUSTOM}}', custom_for_pub)

    git_hash = None
    if use_git_hash:
        git_hash = utils.GetShortGitHash()
    if git_hash is None or len(git_hash) != 10:
        git_hash = '0000000000'
    version = version.replace('{{GIT_HASH}}', git_hash)

    channel = utils.GetChannel()
    version = version.replace('{{CHANNEL}}', channel)

    version_time = None
    if use_git_hash:
        version_time = utils.GetGitTimestamp()
    if version_time == None:
        version_time = 'Unknown timestamp'
    version = version.replace('{{COMMIT_TIME}}', version_time.decode('utf-8'))

    abi_version = utils.GetAbiVersion(version_file)
    version = version.replace('{{ABI_VERSION}}', abi_version)

    oldest_supported_abi_version = utils.GetOldestSupportedAbiVersion(
        version_file)
    version = version.replace('{{OLDEST_SUPPORTED_ABI_VERSION}}',
                              oldest_supported_abi_version)

    snapshot_hash = MakeSnapshotHashString()
    version = version.replace('{{SNAPSHOT_HASH}}', snapshot_hash)

    return version
Exemple #2
0
def MakeVersionString(quiet, no_git_hash, custom_for_pub=None):
    channel = utils.GetChannel()
    if custom_for_pub and channel == 'be':
        latest = utils.GetLatestDevTag()
        if not latest:
            # If grabbing the dev tag fails, then fall back on the VERSION file.
            latest = utils.GetSemanticSDKVersion(no_git_hash=True)
        if no_git_hash:
            version_string = ("%s.%s" % (latest, custom_for_pub))
        else:
            git_hash = utils.GetShortGitHash()
            version_string = ("%s.%s-%s" % (latest, custom_for_pub, git_hash))
        # TODO(athom): remove the custom 2.7.0 logic post release.
        # For 2.7.0, we want flutter to claim Dart is 2.7.0 even before it is
        # decided what exactly 2.7.0 will be. Dart & Flutter stable releases
        # will be synced, so that what will be released as Dart 2.7.0 will also
        # be what will be packaged with Flutter.
        version = utils.ReadVersionFile()
        custom_version_string = "%s.%s.%s" % (version.major, version.minor,
                                              version.patch)
        if custom_version_string == "2.7.0" and custom_for_pub == "flutter":
            version_string = "2.7.0"

    else:
        version_string = utils.GetSemanticSDKVersion(no_git_hash=no_git_hash)
    if not quiet:
        debugLog("Returning version string: %s " % version_string)
    return version_string
Exemple #3
0
def MakeVersionString(quiet, no_git_hash, custom_for_pub=None):
    if custom_for_pub:
        latest = utils.GetLatestDevTag()
        if not latest:
            # If grabbing the dev tag fails, then fall back on the VERSION file.
            latest = utils.GetSemanticSDKVersion(no_git_hash=True)
        if no_git_hash:
            version_string = ("%s.%s" % (latest, custom_for_pub))
        else:
            git_hash = utils.GetShortGitHash()
            version_string = ("%s.%s-%s" % (latest, custom_for_pub, git_hash))
    else:
        version_string = utils.GetSemanticSDKVersion(no_git_hash=no_git_hash)
    if not quiet:
        debugLog("Returning version string: %s " % version_string)
    return version_string
def Main():
    args = sys.argv[1:]
    version_cc = args[2]
    version = utils.GetSemanticSDKVersion()
    updated_content = version_cc_template % {"version": version}
    with open(version_cc, 'w') as f:
        f.write(updated_content)
    return 0
Exemple #5
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
Exemple #6
0
def FormatVersionString(version,
                        no_git_hash,
                        no_sdk_hash,
                        version_file=None,
                        git_revision_file=None):
    semantic_sdk_version = utils.GetSemanticSDKVersion(no_git_hash,
                                                       version_file,
                                                       git_revision_file)
    semantic_version_format = GetSemanticVersionFormat(no_git_hash)
    version_str = (semantic_sdk_version
                   if version_file else semantic_version_format)

    version = version.replace('{{VERSION_STR}}', version_str)

    version = version.replace('{{SEMANTIC_SDK_VERSION}}', semantic_sdk_version)

    git_hash = None
    # If we need SDK hash and git usage is not suppressed then try to get it.
    if not no_sdk_hash and not no_git_hash:
        git_hash = utils.GetShortGitHash()
    if git_hash is None or len(git_hash) != 10:
        git_hash = '0000000000'
    version = version.replace('{{GIT_HASH}}', git_hash)

    channel = utils.GetChannel()
    version = version.replace('{{CHANNEL}}', channel)

    version_time = None
    if not no_git_hash:
        version_time = utils.GetGitTimestamp()
    if version_time == None:
        version_time = 'Unknown timestamp'
    version = version.replace('{{COMMIT_TIME}}', version_time)

    snapshot_hash = MakeSnapshotHashString()
    version = version.replace('{{SNAPSHOT_HASH}}', snapshot_hash)

    return version
Exemple #7
0
def FormatVersionString(version,
                        no_git_hash,
                        version_file=None,
                        git_revision_file=None):
    use_git_hash = not no_git_hash

    semantic_sdk_version = utils.GetSemanticSDKVersion(no_git_hash,
                                                       version_file,
                                                       git_revision_file)
    semantic_version_format = GetSemanticVersionFormat(no_git_hash)
    version_str = (semantic_sdk_version
                   if version_file else semantic_version_format)

    version = version.replace('{{VERSION_STR}}', version_str)

    version = version.replace('{{SEMANTIC_SDK_VERSION}}', semantic_sdk_version)

    git_hash = None
    if use_git_hash:
        git_hash = utils.GetShortGitHash()
    if git_hash is None or len(git_hash) != 10:
        git_hash = '0000000000'
    version = version.replace('{{GIT_HASH}}', git_hash)

    channel = utils.GetChannel()
    version = version.replace('{{CHANNEL}}', channel)

    version_time = None
    if use_git_hash:
        version_time = utils.GetGitTimestamp()
    if version_time == None:
        version_time = 'Unknown timestamp'
    version = version.replace('{{COMMIT_TIME}}', version_time.decode('utf-8'))

    snapshot_hash = MakeSnapshotHashString()
    version = version.replace('{{SNAPSHOT_HASH}}', snapshot_hash)

    return version
def makeVersionString(quiet, no_svn):
    version_string = utils.GetSemanticSDKVersion(ignore_svn_revision=no_svn)
    if not quiet:
        debugLog("Returning version string: %s " % version_string)
    return version_string
Exemple #9
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")
    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