Microsoft / pxt-sample
まずpxt-sample
のリポジトリを取得して手順通りやってみる。前回やったpxt target云々と同じである。
> git clone https://github.com/Microsoft/pxt-sample.git
Cloning into 'pxt-sample'...
:
> cd pxt-sample
> npm install
> pxt serve
Using target sample with build engine none
target: v /home/hoge/pxt-sample
pxt-core: v /home/hoge/pxt-sample/node_modules/pxt-core
:
To launch the editor, open this URL:
http://localhost:3232/#local_token=f5ad0091-3eae-47e4-e9ee-304cbb6a93d3&wsport=3233
モジュールの構築が終了したら、上記のURLを閲覧してみる。
プロジェクトを新規作成すると、MakeCode Microbitとよくに似た画面が表示される。どうもPXTのひな型?のようなものだと思われる。
Microbitの開発環境がほしいので、これではない。(だからpxt-sampleなのね。。)
Microsoft / pxt-microbit
** WSL環境で構築しようとすると、うまく行かないので、素直にデスクトップ環境で構築したほうがいい。Win10、OSXで構築できることを確認(試してないが、デスクトップのLinux環境でも可能) sshでサーバーにログインして構築するのが多分できない。 **
同じように今度は、pxt-microbit
を試してみる。
Microsoft/pxt-microbit
下準備がいるようなので、以下を実行する。pxt-microbitがpxtに依存しているらしい。
> sudo npm install -g jake typings
> git clone https://github.com/microsoft/pxt
> cd pxt
> git checkout v0
> npm install
> typings install
> jake
> cd ../
pxt-microbitをクローンして同様にサーバーを構築する。
> git clone https://github.com/Microsoft/pxt-microbit.git
Cloning into 'pxt-microbit'...
:
> cd pxt-microbit
> npm install
以下のようなフォルダ構成にする(要するにpxtとpxt-microbitが同階層にあれば良いだけかもしれないが、念のため)
makecode
├ pxt
└ pxt-microbit
> mkdir makecode
> mv pxt makecode
> mv pxt-microbit makecode
pxtとpxt-microbitを紐づける?
> cd makecode/pxt-microbit
> sudo npm link ../pxt
サーバーを起動する
> pxt serve --cloud
:
To launch the editor, open this URL:
http://localhost:3232/#local_token=f5ad0091-3eae-47e4-e9ee-304cbb6a93d3&wsport=3233
:
気になっていたlibsのフォルダを覗くと、radioやbluetoothなどのフォルダがある。ビルドされた形跡があり、パッケージを追加メニューで表示される追加モジュールがここのものだと思われる。
> cd libs
> ls
blocksprj bluetoothprj cpp-test hello lang-test1 test-snippets tsprj
bluetooth core devices lang-test0 radio tsconfig.json
試しにHelloなどビルドしてみると、追加パッケージから選択できる。。と予想。次回試してみる。
しかし、書いてあるんだろうけど、情報が少なくてもよくわからない。。
ちなみに--cloud
オプションなしの場合、libsフォルダ以下のパッケージを順番にビルドしてから起動?するような動作をしているが、libs/blocksprj
でエラーになっていて、そのままだと起動しなかった。
> pxt serve
Using target PXT/microbit with build engine yotta
Target dir: /home/hoge/makecode/pxt-microbit
PXT Core dir: /home/hoge/makecode/pxt
building node_modules/pxt-core...
[run] cd node_modules/pxt-core; jake
local pxt-core built.
building sim...
[run] cd sim; node ../node_modules/typescript/bin/tsc
log strings: 63 files; 0 strings -> sim-strings.json
building target.json in /home/hoge/makecode/pxt-microbit...
building libs/core
skip native build of non-project
building libs/radio
skip native build of non-project
building libs/devices
skip native build of non-project
building libs/bluetooth
skip native build of non-project
building libs/blocksprj
*** yotta target bbc-microbit-classic-gcc
INTERNAL ERROR: Error: spawn yotta ENOENT
at _errnoException (util.js:1022:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
at onErrorNT (internal/child_process.js:372:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
libsフォルダの中身を必須パッケージだけ?すると、起動するようになる。
> ls libs
bluetooth core devices projects radio tsconfig.json
> pxt serve
Using target PXT/microbit with build engine yotta
Target dir: /home/hoge/makecode/pxt-microbit
PXT Core dir: /home/hoge/makecode/pxt
Going to /home/hoge/makecode/pxt-microbit
building node_modules/pxt-core...
[run] cd node_modules/pxt-core; jake
local pxt-core built.
building sim...
[run] cd sim; node ../node_modules/typescript/bin/tsc
log strings: 63 files; 0 strings -> sim-strings.json
building target.json in /home/hoge/makecode/pxt-microbit...
building libs/core
skip native build of non-project
building libs/radio
skip native build of non-project
building libs/devices
skip native build of non-project
building libs/bluetooth
skip native build of non-project
target.json built.
building editor...
[run] cd editor; node ../node_modules/typescript/bin/tsc
building docs in libs/core
Package built; written to binary.hex; size: 0
generated _locales/core-strings.json; size=17703
generated _locales/core-jsdoc-strings.json; size=36535
building docs in libs/radio
Package built; written to binary.hex; size: 0
generated _locales/radio-strings.json; size=892
generated _locales/radio-jsdoc-strings.json; size=4312
building docs in libs/devices
Package built; written to binary.hex; size: 0
generated _locales/devices-strings.json; size=2436
generated _locales/devices-jsdoc-strings.json; size=1297
building docs in libs/bluetooth
Package built; written to binary.hex; size: 0
generated _locales/bluetooth-strings.json; size=1557
generated _locales/bluetooth-jsdoc-strings.json; size=3382
watching /home/hoge/makecode/pxt-microbit/node_modules/pxt-core, libs/core, libs/radio, libs/devices, libs/bluetooth, theme, theme/site/globals, sim, sim/public, sim/state, sim/visuals, editor...
Starting server in /home/hoge/makecode/pxt-microbit
With pxt core at /home/hoge/makecode/pxt
starting local ws server at 3233...
serial: monitoring ports...
---------------------------------------------
To launch the editor, open this URL:
http://localhost:3232/#local_token=f5ad0091-3eae-47e4-e9ee-304cbb6a93d3&wsport=3233
---------------------------------------------
opening http://localhost:3232/#local_token=f5ad0091-3eae-47e4-e9ee-304cbb6a93d3&wsport=3233
サーバーは起動するようにはなったが、「プロジェクトを作成しています。。。」で止まったまま。内部的にエラーが発生しているようだ。。
この状態で、--cloud
を付けて起動しても止まったままになっている。libsの中身をデフォルトに戻して、--cloud
を付けると、また起動するようになった。
まだ、ビルド環境としては不完全なのかもしれない。WSLだから?わからない。。。
ほかにもこんなエラーが
> pxt serve
Using target PXT/microbit with build engine yotta
Target dir: /home/web/makecode/pxt-microbit
PXT Core dir: /home/web/makecode/pxt
INTERNAL ERROR: Error: Cannot autolaunch D-Bus without X11 $DISPLAY
at Error (native)
:
どうも、画面X11を使う機能が実行されており、sshログインした状態で実行すると、表示されるエラーろぐらしい。pxt serve
はホスティング目的の起動コマンドではなく、開発用のデスクトップ向けの起動コマンドらしい。
うーん。。WSLで開発環境作成するのは向いていないのか?