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

Unified Diff: tools/concatenate-files.py

Issue 315033002: Support external startup data in V8. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix build issue by making sure the target is empty (as opposed to not the chain of depedencies) whe… Created 6 years, 6 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
« no previous file with comments | « test/cctest/test-serialize.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/concatenate-files.py
diff --git a/tools/push-to-trunk/script_test.py b/tools/concatenate-files.py
old mode 100755
new mode 100644
similarity index 55%
copy from tools/push-to-trunk/script_test.py
copy to tools/concatenate-files.py
index cbb2134f6d92f9d7a8c8e7dda3a3a2e9e1c0a45c..86bdf5638366ad5ee681ae2e4ab89499e4ebe18e
--- a/tools/push-to-trunk/script_test.py
+++ b/tools/concatenate-files.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+#
# Copyright 2014 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -26,29 +27,49 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-# Wraps test execution with a coverage analysis. To get the best speed, the
-# native python coverage version >= 3.7.1 should be installed.
+# This utility concatenates several files into one. On Unix-like systems
+# it is equivalent to:
+# cat file1 file2 file3 ...files... > target
+#
+# The reason for writing a seperate utility is that 'cat' is not available
+# on all supported build platforms, but Python is, and hence this provides
+# us with an easy and uniform way of doing this on all platforms.
+
+import optparse
+
+
+def Concatenate(filenames):
+ """Concatenate files.
+
+ Args:
+ files: Array of file names.
+ The last name is the target; all earlier ones are sources.
+
+ Returns:
+ True, if the operation was successful.
+ """
+ if len(filenames) < 2:
+ print "An error occured generating %s:\nNothing to do." % filenames[-1]
+ return False
-import coverage
-import os
-import unittest
-import sys
+ try:
+ with open(filenames[-1], "wb") as target:
+ for filename in filenames[:-1]:
+ with open(filename, "rb") as current:
+ target.write(current.read())
+ return True
+ except IOError as e:
+ print "An error occured when writing %s:\n%s" % (filenames[-1], e)
+ return False
-def Main(argv):
- script_path = os.path.dirname(os.path.abspath(__file__))
- cov = coverage.coverage(include=([os.path.join(script_path, '*.py')]))
- cov.start()
- import test_scripts
- alltests = map(unittest.TestLoader().loadTestsFromTestCase, [
- test_scripts.ToplevelTest,
- test_scripts.ScriptTest,
- test_scripts.SystemTest,
- ])
- unittest.TextTestRunner(verbosity=2).run(unittest.TestSuite(alltests))
- cov.stop()
- print cov.report()
+def main():
+ parser = optparse.OptionParser()
+ parser.set_usage("""Concatenate several files into one.
+ Equivalent to: cat file1 ... > target.""")
+ (options, args) = parser.parse_args()
+ exit(0 if Concatenate(args) else 1)
-if __name__ == '__main__':
- sys.exit(Main(sys.argv))
+if __name__ == "__main__":
+ main()
« no previous file with comments | « test/cctest/test-serialize.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698