OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 <fcntl.h> | |
6 | |
7 #include "base/files/file_util.h" | |
8 #include "mojo/nacl/nonsfi/nexe_launcher_nonsfi.h" | |
9 #include "mojo/public/c/system/main.h" | |
10 #include "mojo/public/cpp/application/application_connection.h" | |
11 #include "mojo/public/cpp/application/application_delegate.h" | |
12 #include "mojo/public/cpp/application/application_runner.h" | |
13 #include "mojo/public/cpp/application/interface_factory.h" | |
14 #include "mojo/public/cpp/bindings/strong_binding.h" | |
15 #include "services/nacl/pnacl_compile.mojom.h" | |
16 | |
17 namespace mojo { | |
18 namespace nacl { | |
19 | |
20 class PexeCompilerImpl : public PexeCompilerInit { | |
21 public: | |
22 void PexeCompilerStart(ScopedMessagePipeHandle handle) override { | |
23 char path[] = "native_client/toolchain/linux_x86/pnacl_translator" | |
Mark Seaborn
2015/10/27 17:30:21
You want "static const char kPath[]". "char path[
Sean Klein
2015/10/28 17:02:41
Done.
| |
24 "/translator/x86-32-nonsfi/bin/pnacl-llc.nexe"; | |
Petr Hosek
2015/10/27 15:07:52
Hardcoding this path makes it difficult to test or
Sean Klein
2015/10/28 17:02:41
I totally agree -- Updated irt_mojo_nonsfi, pnacl_
| |
25 int nexe_fd = open(path, O_RDONLY); | |
26 if (nexe_fd < 0) | |
27 LOG(FATAL) << "Could not open compiler nexe: " << path; | |
28 ::nacl::MojoLaunchNexeNonsfi(nexe_fd, | |
29 handle.release().value(), | |
30 true /* enable_translate_irt */); | |
31 } | |
32 }; | |
33 | |
34 class StrongBindingPexeCompilerImpl : public PexeCompilerImpl { | |
35 public: | |
36 explicit StrongBindingPexeCompilerImpl(InterfaceRequest<PexeCompilerInit> | |
37 request) | |
38 : strong_binding_(this, request.Pass()) {} | |
39 | |
40 private: | |
41 StrongBinding<PexeCompilerInit> strong_binding_; | |
42 }; | |
43 | |
44 class MultiPexeCompiler : public mojo::ApplicationDelegate, | |
45 public mojo::InterfaceFactory<PexeCompilerInit> { | |
46 public: | |
47 MultiPexeCompiler() {} | |
48 | |
49 // From ApplicationDelegate | |
50 bool ConfigureIncomingConnection( | |
51 mojo::ApplicationConnection* connection) override { | |
52 connection->AddService<PexeCompilerInit>(this); | |
53 return true; | |
54 } | |
55 | |
56 // From InterfaceFactory | |
57 void Create(mojo::ApplicationConnection* connection, | |
58 mojo::InterfaceRequest<PexeCompilerInit> request) override { | |
59 new StrongBindingPexeCompilerImpl(request.Pass()); | |
60 } | |
61 }; | |
62 | |
63 } // namespace nacl | |
64 } // namespace mojo | |
65 | |
66 MojoResult MojoMain(MojoHandle application_request) { | |
67 mojo::ApplicationRunner runner(new mojo::nacl::MultiPexeCompiler()); | |
68 return runner.Run(application_request); | |
69 } | |
OLD | NEW |