| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // A simple command-line compiler for JTL (JSON Traversal Language). | 5 // A simple command-line compiler for JTL (JSON Traversal Language). |
| 6 // | 6 // |
| 7 // Translates rules from a text-based, human-readable format to an easy-to-parse | 7 // Translates rules from a text-based, human-readable format to an easy-to-parse |
| 8 // byte-code format, which then can be interpreted by JtlInterpreter. | 8 // byte-code format, which then can be interpreted by JtlInterpreter. |
| 9 // | 9 // |
| 10 // Example usage: | 10 // Example usage: |
| 11 // jtl_compiler --input=blah.txt --hash-seed="foobar" --output=blah.dat | 11 // jtl_compiler --input=blah.txt --hash-seed="foobar" --output=blah.dat |
| 12 | 12 |
| 13 #include <iostream> | 13 #include <iostream> |
| 14 #include <string> | 14 #include <string> |
| 15 | 15 |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/file_util.h" | |
| 18 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
| 18 #include "base/files/file_util.h" |
| 19 #include "chrome/tools/profile_reset/jtl_compiler.h" | 19 #include "chrome/tools/profile_reset/jtl_compiler.h" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // Command-line argument name: path to the input text-based JTL source code. | 23 // Command-line argument name: path to the input text-based JTL source code. |
| 24 const char kInputPath[] = "input"; | 24 const char kInputPath[] = "input"; |
| 25 | 25 |
| 26 // Command-line argument name: path to the output byte-code. | 26 // Command-line argument name: path to the output byte-code. |
| 27 const char kOutputPath[] = "output"; | 27 const char kOutputPath[] = "output"; |
| 28 | 28 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 base::WriteFile(cmd_line->GetSwitchValuePath(kOutputPath), | 103 base::WriteFile(cmd_line->GetSwitchValuePath(kOutputPath), |
| 104 bytecode.data(), | 104 bytecode.data(), |
| 105 static_cast<int>(bytecode.size())); | 105 static_cast<int>(bytecode.size())); |
| 106 if (bytes_written != static_cast<int>(bytecode.size())) { | 106 if (bytes_written != static_cast<int>(bytecode.size())) { |
| 107 std::cerr << "ERROR: Cannot write output file." << std::endl; | 107 std::cerr << "ERROR: Cannot write output file." << std::endl; |
| 108 return -3; | 108 return -3; |
| 109 } | 109 } |
| 110 | 110 |
| 111 return 0; | 111 return 0; |
| 112 } | 112 } |
| OLD | NEW |