Пример #1
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
Пример #2
0
def MakeFile(quiet,
             output_file,
             input_file,
             no_git_hash,
             custom_for_pub,
             version_file=None):
    if version_file:
        version_string = utils.GetVersion(no_git_hash, version_file)
    else:
        version_string = MakeVersionString(quiet, no_git_hash, custom_for_pub)

    version_cc_text = open(input_file).read()
    version_cc_text = version_cc_text.replace("{{VERSION_STR}}",
                                              version_string)
    channel = utils.GetChannel()
    version_cc_text = version_cc_text.replace("{{CHANNEL}}", channel)
    version_time = utils.GetGitTimestamp()
    if no_git_hash or version_time == None:
        version_time = "Unknown timestamp"
    version_cc_text = version_cc_text.replace("{{COMMIT_TIME}}",
                                              version_time.decode("utf-8"))
    abi_version = utils.GetAbiVersion(version_file)
    version_cc_text = version_cc_text.replace("{{ABI_VERSION}}", abi_version)
    oldest_supported_abi_version = utils.GetOldestSupportedAbiVersion(
        version_file)
    version_cc_text = version_cc_text.replace(
        "{{OLDEST_SUPPORTED_ABI_VERSION}}", oldest_supported_abi_version)
    snapshot_hash = MakeSnapshotHashString()
    version_cc_text = version_cc_text.replace("{{SNAPSHOT_HASH}}",
                                              snapshot_hash)
    open(output_file, 'w').write(version_cc_text)
    return True
Пример #3
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
Пример #4
0
def GetSemanticVersionFormat(no_git_hash, custom_for_pub):
    version_format = '{{SEMANTIC_SDK_VERSION}}'

    if custom_for_pub and utils.GetChannel() == 'be':
        if no_git_hash:
            version_format = '{{LATEST}}.{{PUB_CUSTOM}}'
        else:
            version_format = '{{LATEST}}.{{PUB_CUSTOM}}-{{GIT_HASH}}'

    return version_format
Пример #5
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))
    else:
        version_string = utils.GetSemanticSDKVersion(no_git_hash=no_git_hash)
    if not quiet:
        debugLog("Returning version string: %s " % version_string)
    return version_string
Пример #6
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)
Пример #7
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
Пример #8
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
Пример #9
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, 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 = join(temp_dir, 'copyright')
            GenerateCopyright(copyright)
            tar.add(copyright, 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 bleeding_edge add the SVN_REVISION file.
            if utils.GetChannel() == 'be':
                svn_revision = join(temp_dir, 'SVN_REVISION')
                GenerateSvnRevision(svn_revision, utils.GetSVNRevision())
                tar.add(svn_revision,
                        arcname='%s/dart/tools/SVN_REVISION' % versiondir)
Пример #10
0
def Main():
    global OUTPUT
    global BUILD

    parser = BuildOptions()
    (options, args) = parser.parse_args()

    if args:
        parser.print_help()
        return 1

    osName = utils.GuessOS()
    mode = 'debug'
    arch = utils.GuessArchitecture()

    if not options.build:
        print >> sys.stderr, 'Error: no --build option specified'
        exit(1)
    else:
        BUILD = options.build

    if not options.out:
        print >> sys.stderr, 'Error: no --out option specified'
        exit(1)
    else:
        # TODO(devoncarew): Currently we scrape the output path to determine the
        # mode and arch. This is fragile and should moved into one location
        # (utils.py?) or made more explicit.
        OUTPUT = options.out
        mode = ('release', 'debug')['Debug' in OUTPUT]
        arch = ('ia32', 'x64')['X64' in OUTPUT]

    # Use explicit mode and arch information.
    if options.mode:
        mode = options.mode
    if options.arch:
        arch = options.arch

    OUTPUT = os.path.abspath(OUTPUT)
    BUILD = os.path.abspath(BUILD)

    print "\nBuilding the editor"
    print "  config : %s, %s, %s" % (osName, arch, mode)
    print "  output : %s" % OUTPUT

    # Clean the editor output directory.
    print '\ncleaning %s' % OUTPUT
    shutil.rmtree(OUTPUT, True)

    # These are the valid eclipse build configurations that we can produce.
    # We synthesize these up from the OS_CONFIG and ARCH_CONFIG information.
    # macosx, cocoa, x86 & macosx, cocoa, x86_64
    # win32, win32, x86 & win32, win32, x86_64
    # linux, gtk, x86 & linux, gtk, x86_64

    buildConfig = OS_CONFIG[osName] + ', ' + ARCH_CONFIG[arch]

    print "\ninvoking build_rcp.xml with buildConfig = [%s]\n" % buildConfig

    sys.stdout.flush()
    sys.stderr.flush()

    buildScript = join('editor', 'tools', 'features',
                       'com.google.dart.tools.deploy.feature_releng',
                       'build_rcp.xml')
    build_cmd = [
        AntPath(), '-lib',
        join('third_party', 'bzip2', 'bzip2.jar'), '-Dbuild.out=' + OUTPUT,
        '-Dbuild.configs=' + buildConfig,
        '-Dbuild.root=' + GetEclipseBuildRoot(),
        '-Dbuild.downloads=' + GetDownloadCache(),
        '-Dbuild.source=' + os.path.abspath('editor'),
        '-Dbuild.dart.sdk=' + GetSdkPath(), '-Dbuild.no.properties=true',
        '-Dbuild.channel=' + utils.GetChannel(),
        '-Dbuild.revision=' + utils.GetSVNRevision(),
        '-Dbuild.version.qualifier=' + utils.GetEclipseVersionQualifier(),
        '-Ddart.version.full=' + utils.GetVersion(), '-buildfile', buildScript
    ]
    print build_cmd
    buildRcpStatus = subprocess.call(build_cmd, shell=utils.IsWindows())

    if buildRcpStatus != 0:
        sys.exit(buildRcpStatus)

    # build_rcp.xml will put the built editor archive in the OUTPUT directory
    # (dart-editor-macosx.cocoa.x86.zip). It contains the editor application in a
    # dart/ subdirectory. We unzip the contents of the archive into OUTPUT. It
    # will use the ../dart-sdk directory as its SDK.
    archives = glob.glob(join(OUTPUT, '*.zip'))

    if archives:
        ProcessEditorArchive(arch, archives[0], OUTPUT)

    if os.path.exists(GetEditorTemp()):
        shutil.rmtree(GetEditorTemp())

    print('\nEditor build successful')