Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1027)

Side by Side Diff: build/write_build_date_header.py

Issue 1641413002: Makes GetBuildTime behave identically on all build types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed bad input Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 # Writes a file that contains a define that approximates the build date.
M-A Ruel 2016/02/01 17:52:28 Convert to docstring.
Zachary Forman 2016/02/02 06:30:38 Done!
7 # argv[1] is the location to write the file.
8 # If argv[2] == "--official", returns the current date in UTC.
9 # Otherwise, returns the first day of the current month (in UTC).
10 # If argv[2] == "--override", use argv[3] as the build date.
11
12 import sys
13 from datetime import datetime
14
M-A Ruel 2016/02/01 17:52:28 2 lines between file level symbols.
Zachary Forman 2016/02/02 06:30:38 Done!
15 def BuildDate(build_type):
16 if build_type == "--official":
M-A Ruel 2016/02/01 17:52:28 use single quotes everywhere.
Zachary Forman 2016/02/02 06:30:38 Done!
17 format = "{:%b %d %Y}"
18 else:
19 format = "{:%b 01 %Y}"
M-A Ruel 2016/02/01 17:52:28 I thought about it more and I'd want a slightly mo
Zachary Forman 2016/02/02 06:30:38 I like this idea. I'd want it to switch on Sunday
20 return format.format(datetime.utcnow())
21
22 def main(arguments):
23 output_location = arguments[1];
M-A Ruel 2016/02/01 17:52:28 No trailing ;
Zachary Forman 2016/02/02 06:30:38 Done
24 build_type = arguments[2] if len(arguments) > 2 else "default"
M-A Ruel 2016/02/01 17:52:28 Please use argparse. It's going to make the script
Zachary Forman 2016/02/02 06:30:38 Done!
25 if len(arguments) > 2 and arguments[2] == "--override":
26 build_date = arguments[3]
27 else:
28 build_date = BuildDate(build_type)
29 with open(output_location, "w") as output_file:
30 output_file.write("// Generated by //build/write_build_date_header.py\n")
31 output_file.write("#ifndef BUILD_DATE\n")
32 output_file.write("#define BUILD_DATE \"{}\"\n".format(build_date))
33 output_file.write("#endif // BUILD_DATE\n")
34 return 0
35
36
37 if __name__ == '__main__':
38 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698