OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium 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 <iostream> | |
6 | |
7 #include "base/files/file.h" | |
8 #include "base/files/file_path.h" | |
9 #include "base/logging.h" | |
10 #include "mojo/edk/embedder/embedder.h" | |
11 #include "mojo/edk/embedder/simple_platform_support.h" | |
12 #include "mojo/nacl/sfi/nacl_bindings/monacl_sel_main.h" | |
13 #include "native_client/src/public/nacl_desc.h" | |
14 | |
15 NaClDesc* OpenFile(const char* filename) { | |
16 base::FilePath path(filename); | |
17 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ); | |
18 if (!file.IsValid()) { | |
19 perror(filename); | |
20 exit(1); | |
21 } | |
22 return NaClDescCreateWithFilePathMetadata(file.TakePlatformFile(), ""); | |
23 } | |
24 | |
25 int main(int argc, char* argv[]) { | |
26 if (argc < 3) { | |
27 std::cout << "Usage: " << argv[0] << " irt.nexe app.nexe [args for app]" << | |
28 std::endl; | |
29 return 1; | |
30 } | |
31 | |
32 const char* irt_file = argv[1]; | |
33 const char* nexe_file = argv[2]; | |
34 | |
35 NaClDesc* irt_desc = OpenFile(irt_file); | |
36 NaClDesc* nexe_desc = OpenFile(nexe_file); | |
37 | |
38 mojo::embedder::Init(mojo::embedder::CreateSimplePlatformSupport()); | |
39 | |
40 int exit_code = mojo::LaunchNaCl(nexe_desc, irt_desc, argc - 2, argv + 2, | |
41 MOJO_HANDLE_INVALID); | |
42 | |
43 // Exits the process cleanly, does not return. | |
44 mojo::NaClExit(exit_code); | |
45 NOTREACHED(); | |
46 return 1; | |
47 } | |
OLD | NEW |