tmp
Showing posts with label
Native Client
.
Show all posts
Showing posts with label
Native Client
.
Show all posts
Tuesday, October 15, 2013
Native Client Tutorial 3
[前回の続き](http://fiahfy.blogspot.jp/2013/10/native-client-hello-tutorial.html) * ログ用関数追加 ``` #include
#include
#include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/var.h" // 追加 #include
void logmsg(const char* pMsg){ fprintf(stdout,"logmsg: %s\n",pMsg); } void errormsg(const char* pMsg){ fprintf(stderr,"logerr: %s\n",pMsg); } ``` ``` virtual void HandleMessage(const pp::Var& var_message) { // 追加(試しにここでログを取ってみる) logmsg("hoge"); if (!var_message.is_string()) return; std::string message = var_message.AsString(); pp::Var var_reply; if (message == kHelloString) { var_reply = pp::Var(kReplyString); PostMessage(var_reply); }``` * ログファイルを指定 ``` $ export NACL_EXE_STDOUT=/Users/[username]/nacl.log $ export NACL_EXE_STDERR=/Users/[username]/nacl.log ``` * chromeをsandboxモードで再起動 ``` $ open "/Applications/Google Chrome.app/" --args --no-sandbox ``` *
を表示すると `/Users/[username]/nacl.log` にログが出力される ``` $ tail /Users/[username]/nacl.log logmsg: hoge ``` * web側に投げる場合 ``` $export NACL_EXE_STDOUT=DEBUG_ONLY:dev://postmessage $export NACL_EXE_STDERR=DEBUG_ONLY:dev://postmessage ``` * chromeをsandboxモードで再起動 *
を表示すると alertでログが表示される ``` DEBUG_POSTMESSAGE:logmsg: hoge ```
Friday, October 11, 2013
Native Client Tutorial 2
[前回の続き](http://fiahfy.blogspot.jp/2013/10/native-client-tutorial-example.html) [Step 4: Create a set of stub files for your application.](https://developers.google.com/native-client/devguide/tutorial#templates) * [hello_tutorial.zip](https://developers.google.com/native-client/devguide/hello_tutorial.zip) をDLして解凍 * hello_tutorial をexampleの中へ ```bash $ mv hello_tutorial nacl_sdk/pepper_30/examples/ ``` * make ```bash $ cd nacl_sdk/pepper_30/examples/hello_tutorial $ make ``` *
を表示 LOADING.. -> SUCCESSが表示されればおk (nacl_sdk/pepper_30/tools/httpd.py は起動しておく) * hello_tutorial.html に以下を追加 ```javascript // Indicate load success. function moduleDidLoad() { HelloTutorialModule = document.getElementById('hello_tutorial'); updateStatus('SUCCESS'); // 追加 HelloTutorialModule.postMessage('hello'); } ``` * hello_tutorial.cc に以下追加 ```cs #include
#include
#include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/var.h" // 追加 namespace { const char* const kHelloString = "hello"; const char* const kReplyString = "hello from NaCl"; } // namespace ``` ```cs virtual void HandleMessage(const pp::Var& var_message) { // 追加 if (!var_message.is_string()) return; std::string message = var_message.AsString(); pp::Var var_reply; if (message == kHelloString) { var_reply = pp::Var(kReplyString); PostMessage(var_reply); } } ``` * make ```bash $ make ``` *
を表示 alertで `hello from NaCl` と表示される 表示されない場合は httpd.py, chrome を再起動とかしてみる
Native Client Tutorial 1
##Download SDK [Download the Native Client SDK](https://developers.google.com/native-client/sdk/download)
からDLして解凍 ##install pepper ```bash $ cd naclsdk $ ./naclsdk list Bundles: I: installed *: update available I sdk_tools (stable) vs_addin (dev) pepper_26 (post_stable) pepper_27 (post_stable) pepper_28 (post_stable) pepper_29 (post_stable) pepper_30 (stable) pepper_31 (beta) pepper_canary (canary) All installed bundles are up-to-date. $ ./naclsdk update pepper_30 ``` ##Tutorial [C++ Tutorial: Getting Started](https://developers.google.com/native-client/devguide/tutorial) * Local Server 起動 ```bash $ cd pepper_30/examples $ python ../tools/httpd.py ``` * chrome のネイティブ クライアントを有効にする `chrome://flags/` の ネイティブ クライアント Mac, Windows, Linux, Chrome OS *
を表示するとexampleが見れる ##参考 *
Older Posts
Home
Subscribe to:
Posts (Atom)