8from __future__
import print_function
40 vmhash = hashlib.md5()
41 for vmfilename
in VM_SNAPSHOT_FILES:
42 vmfilepath = os.path.join(utils.DART_DIR,
'runtime',
'vm', vmfilename)
43 with open(vmfilepath,
'rb')
as vmfile:
44 vmhash.update(vmfile.read())
45 return vmhash.hexdigest()
49 version_format =
'{{SEMANTIC_SDK_VERSION}}'
57 git_revision_file=None,
58 git_timestamp_file=None):
62 version_str = (semantic_sdk_version
63 if version_file
else semantic_version_format)
65 version = version.replace(
'{{VERSION_STR}}', version_str)
67 version = version.replace(
'{{SEMANTIC_SDK_VERSION}}', semantic_sdk_version)
71 if not no_sdk_hash
and not no_git_hash:
73 if git_hash
is None or len(git_hash) != 10:
74 git_hash =
'0000000000'
75 version = version.replace(
'{{GIT_HASH}}', git_hash)
78 version = version.replace(
'{{CHANNEL}}', channel)
83 if version_time ==
None:
84 version_time =
'Unknown timestamp'
85 version = version.replace(
'{{COMMIT_TIME}}', version_time)
88 version = version.replace(
'{{SNAPSHOT_HASH}}', snapshot_hash)
96 parser = argparse.ArgumentParser()
97 parser.add_argument(
'--input', help=
'Input template file.')
102 help=(
'Don\'t try to call git to derive things like '
103 'git revision hash.'))
108 help=
'Use null SDK hash to disable SDK verification in the VM')
109 parser.add_argument(
'--output', help=
'output file name')
110 parser.add_argument(
'-q',
114 help=
'DEPRECATED: Does nothing!')
115 parser.add_argument(
'--version-file', help=
'Path to the VERSION file.')
116 parser.add_argument(
'--git-revision-file',
117 help=
'Path to the GIT_REVISION file.')
118 parser.add_argument(
'--git-timestamp-file',
119 help=
'Path to the GIT_TIMESTAMP file.')
122 default=
'{{VERSION_STR}}',
123 help=
'Version format used if no input template is given.')
125 args = parser.parse_args()
131 version_template =
''
133 version_template = open(args.input).
read()
134 elif not args.format
is None:
135 version_template = args.format
137 raise 'No version template given! Set either --input or --format.'
140 args.no_sdk_hash, args.version_file,
141 args.git_revision_file,
142 args.git_timestamp_file)
145 with open(args.output,
'w')
as fh:
148 sys.stdout.write(version)
152 except Exception
as inst:
153 sys.stderr.write(
'make_version.py exception\n')
154 sys.stderr.write(str(inst))
155 sys.stderr.write(
'\n')
160if __name__ ==
'__main__':
static bool read(SkStream *stream, void *buffer, size_t amount)
def MakeSnapshotHashString()
def GetSemanticVersionFormat(no_git_hash)
def FormatVersionString(version, no_git_hash, no_sdk_hash, version_file=None, git_revision_file=None, git_timestamp_file=None)
def GetGitTimestamp(git_timestamp_file=None, repo_path=DART_DIR)
def GetShortGitHash(repo_path=DART_DIR)
def GetChannel(version_file=None)
def GetVersion(no_git_hash=False, version_file=None, git_revision_file=None)