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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
Index: build/write_build_date_header.py
diff --git a/build/write_build_date_header.py b/build/write_build_date_header.py
new file mode 100755
index 0000000000000000000000000000000000000000..9ad8eaafa55625166b72e01b0c137bb7f608cc8b
--- /dev/null
+++ b/build/write_build_date_header.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+# Copyright (c) 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# 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!
+# argv[1] is the location to write the file.
+# If argv[2] == "--official", returns the current date in UTC.
+# Otherwise, returns the first day of the current month (in UTC).
+# If argv[2] == "--override", use argv[3] as the build date.
+
+import sys
+from datetime import datetime
+
M-A Ruel 2016/02/01 17:52:28 2 lines between file level symbols.
Zachary Forman 2016/02/02 06:30:38 Done!
+def BuildDate(build_type):
+ 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!
+ format = "{:%b %d %Y}"
+ else:
+ 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
+ return format.format(datetime.utcnow())
+
+def main(arguments):
+ output_location = arguments[1];
M-A Ruel 2016/02/01 17:52:28 No trailing ;
Zachary Forman 2016/02/02 06:30:38 Done
+ 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!
+ if len(arguments) > 2 and arguments[2] == "--override":
+ build_date = arguments[3]
+ else:
+ build_date = BuildDate(build_type)
+ with open(output_location, "w") as output_file:
+ output_file.write("// Generated by //build/write_build_date_header.py\n")
+ output_file.write("#ifndef BUILD_DATE\n")
+ output_file.write("#define BUILD_DATE \"{}\"\n".format(build_date))
+ output_file.write("#endif // BUILD_DATE\n")
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))

Powered by Google App Engine
This is Rietveld 408576698