94 try:
95
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
128
129
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
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)