Line data Source code
1 : // Copyright 2017 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #include "src/torque/source-positions.h"
6 : #include "src/torque/torque-compiler.h"
7 :
8 : namespace v8 {
9 : namespace internal {
10 : namespace torque {
11 :
12 1 : int WrappedMain(int argc, const char** argv) {
13 : std::string output_directory;
14 : bool verbose = false;
15 1 : std::vector<std::string> files;
16 :
17 107 : for (int i = 1; i < argc; ++i) {
18 : // Check for options
19 53 : if (!strcmp("-o", argv[i])) {
20 1 : output_directory = argv[++i];
21 : continue;
22 : }
23 52 : if (!strcmp("-v", argv[i])) {
24 : verbose = true;
25 : continue;
26 : }
27 :
28 : // Otherwise it's a .tq file. Remember it for compilation.
29 52 : files.emplace_back(argv[i]);
30 : }
31 :
32 : TorqueCompilerOptions options;
33 : options.output_directory = output_directory;
34 1 : options.verbose = verbose;
35 1 : options.collect_language_server_data = false;
36 1 : options.abort_on_lint_errors = true;
37 :
38 3 : TorqueCompilerResult result = CompileTorque(files, options);
39 1 : if (result.error) {
40 : // PositionAsString requires the SourceFileMap to be set to
41 : // resolve the file name.
42 0 : SourceFileMap::Scope source_file_map_scope(result.source_file_map);
43 :
44 : TorqueError& error = *result.error;
45 0 : if (error.position) std::cerr << PositionAsString(*error.position) << ": ";
46 0 : std::cerr << "Torque error: " << error.message << "\n";
47 0 : v8::base::OS::Abort();
48 : }
49 :
50 1 : return 0;
51 : }
52 :
53 : } // namespace torque
54 : } // namespace internal
55 : } // namespace v8
56 :
57 1 : int main(int argc, const char** argv) {
58 1 : return v8::internal::torque::WrappedMain(argc, argv);
59 2 : }
|