Flutter Engine
The Flutter Engine
Functions | Variables
make_version Namespace Reference

Functions

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 main ()
 

Variables

list VM_SNAPSHOT_FILES
 

Function Documentation

◆ FormatVersionString()

def make_version.FormatVersionString (   version,
  no_git_hash,
  no_sdk_hash,
  version_file = None,
  git_revision_file = None,
  git_timestamp_file = None 
)

Definition at line 53 of file make_version.py.

58 git_timestamp_file=None):
59 semantic_sdk_version = utils.GetVersion(no_git_hash, version_file,
60 git_revision_file)
61 semantic_version_format = GetSemanticVersionFormat(no_git_hash)
62 version_str = (semantic_sdk_version
63 if version_file else semantic_version_format)
64
65 version = version.replace('{{VERSION_STR}}', version_str)
66
67 version = version.replace('{{SEMANTIC_SDK_VERSION}}', semantic_sdk_version)
68
69 git_hash = None
70 # If we need SDK hash and git usage is not suppressed then try to get it.
71 if not no_sdk_hash and not no_git_hash:
72 git_hash = utils.GetShortGitHash()
73 if git_hash is None or len(git_hash) != 10:
74 git_hash = '0000000000'
75 version = version.replace('{{GIT_HASH}}', git_hash)
76
77 channel = utils.GetChannel()
78 version = version.replace('{{CHANNEL}}', channel)
79
80 version_time = None
81 if not no_git_hash:
82 version_time = utils.GetGitTimestamp(git_timestamp_file)
83 if version_time == None:
84 version_time = 'Unknown timestamp'
85 version = version.replace('{{COMMIT_TIME}}', version_time)
86
87 snapshot_hash = MakeSnapshotHashString()
88 version = version.replace('{{SNAPSHOT_HASH}}', snapshot_hash)
89
90 return version
91
92
def MakeSnapshotHashString()
Definition: make_version.py:39
def GetSemanticVersionFormat(no_git_hash)
Definition: make_version.py:48
def GetGitTimestamp(git_timestamp_file=None, repo_path=DART_DIR)
Definition: utils.py:458
def GetShortGitHash(repo_path=DART_DIR)
Definition: utils.py:443
def GetChannel(version_file=None)
Definition: utils.py:376
def GetVersion(no_git_hash=False, version_file=None, git_revision_file=None)
Definition: utils.py:357

◆ GetSemanticVersionFormat()

def make_version.GetSemanticVersionFormat (   no_git_hash)

Definition at line 48 of file make_version.py.

48def GetSemanticVersionFormat(no_git_hash):
49 version_format = '{{SEMANTIC_SDK_VERSION}}'
50 return version_format
51
52

◆ main()

def make_version.main ( )

Definition at line 93 of file make_version.py.

93def main():
94 try:
95 # Parse input.
96 parser = argparse.ArgumentParser()
97 parser.add_argument('--input', help='Input template file.')
98 parser.add_argument(
99 '--no-git-hash',
100 action='store_true',
101 default=False,
102 help=('Don\'t try to call git to derive things like '
103 'git revision hash.'))
104 parser.add_argument(
105 '--no-sdk-hash',
106 action='store_true',
107 default=False,
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',
111 '--quiet',
112 action='store_true',
113 default=False,
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.')
120 parser.add_argument(
121 '--format',
122 default='{{VERSION_STR}}',
123 help='Version format used if no input template is given.')
124
125 args = parser.parse_args()
126
127 # If there is no input template, then write the bare version string to
128 # args.output. If there is no args.output, then write the version
129 # string to stdout.
130
131 version_template = ''
132 if args.input:
133 version_template = open(args.input).read()
134 elif not args.format is None:
135 version_template = args.format
136 else:
137 raise 'No version template given! Set either --input or --format.'
138
139 version = FormatVersionString(version_template, args.no_git_hash,
140 args.no_sdk_hash, args.version_file,
141 args.git_revision_file,
142 args.git_timestamp_file)
143
144 if args.output:
145 with open(args.output, 'w') as fh:
146 fh.write(version)
147 else:
148 sys.stdout.write(version)
149
150 return 0
151
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')
156
157 return -1
158
159
static bool read(SkStream *stream, void *buffer, size_t amount)
def FormatVersionString(version, no_git_hash, no_sdk_hash, version_file=None, git_revision_file=None, git_timestamp_file=None)
Definition: make_version.py:58

◆ MakeSnapshotHashString()

def make_version.MakeSnapshotHashString ( )

Definition at line 39 of file make_version.py.

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()
46
47

Variable Documentation

◆ VM_SNAPSHOT_FILES

list make_version.VM_SNAPSHOT_FILES
Initial value:
1= [
2 # Header files.
3 'app_snapshot.h',
4 'datastream.h',
5 'image_snapshot.h',
6 'object.h',
7 'raw_object.h',
8 'snapshot.h',
9 'symbols.h',
10 # Source files.
11 'app_snapshot.cc',
12 'dart.cc',
13 'dart_api_impl.cc',
14 'image_snapshot.cc',
15 'object.cc',
16 'raw_object.cc',
17 'snapshot.cc',
18 'symbols.cc',
19]

Definition at line 18 of file make_version.py.