tomoyuki-nohara-abeja / jp-transcript-chrome-extensiona

Google meet + Google Speech API on Chrome Extension
0 stars 0 forks source link

jsをコンパイルできないのか #3

Open tomoyuki-nohara-abeja opened 3 years ago

tomoyuki-nohara-abeja commented 3 years ago

gRPC-webのチュートリアルを読んでいたら、最後にコンパイル的な話を見つけた。これ! これができればgoogleのクライアントライブラリをそのまま使える。 とわ言え全くわからないので、ひとまずgRPC-webのチュートリアルにダイブする

image

tomoyuki-nohara-abeja commented 3 years ago

Basics Tutorial – gRPC

tomoyuki-nohara-abeja commented 3 years ago

gRPC-web

Tutorial

Quick Start

Quick Start – gRPC

Install Protocol buffers

Protocol Buffers 導入メモ Mac/Win - Qiita

brewでインストール

brew install protobuf
protoc --version
libprotoc 3.13.0

build

buildコードでエラー。 gRPC-Web Hello World Guideをやってみた - Qiita

inputのディレクトリと出力のディレクトリを適当に決める。

- protoc -I=$DIR echo.proto --js_out=import_style=commonjs:$OUT_DIR
> protoc -I=. echo.proto  --js_out=import_style=commonjs:build

syntaxを追加

> protoc -I=. echo.proto  --js_out=import_style=commonjs:build
[libprotobuf WARNING google/protobuf/compiler/parser.cc:648] No syntax specified for the proto file: echo.proto. Please use 'syntax = "proto2";' or 'syntax = "proto3";' to specify a syntax version. (Defaulted to proto2 syntax.)
echo.proto:2:3: Expected "required", "optional", or "repeated".
echo.proto:6:3: Expected "required", "optional", or "repeated".

echo.protoの先頭にsyntaxを追加. たまたま記事で見かけていたので gRPC-Web Hello World Guideをやってみた - Qiita

syntax = "proto3";

message EchoRequest {
  string message = 1;
}

message EchoResponse {
  string message = 1;
}

service EchoService {
  rpc Echo(EchoRequest) returns (EchoResponse);
}

build/echo_pb.jsができた。

なにかをmake

> sudo make install-plugin
Password:
cd "/Users/tomoyuki.nohara/GoogleDrive/02_Codes/tmp-node-compile/gRPC-tutorial/grpc-web"/javascript/net/grpc/web && make install
c++ -std=c++11 -I/usr/local/include -pthread  -c -o grpc_generator.o grpc_generator.cc
c++ grpc_generator.o -L/usr/local/lib -lprotoc -lprotobuf -lpthread -ldl -o protoc-gen-grpc-web
install protoc-gen-grpc-web /usr/local/bin/protoc-gen-grpc-web

成功

またbuild

もとのディレクトリに戻って

protoc -I=. echo.proto --grpc-web_out=import_style=commonjs,mode=grpcwebtext:build

するとbuild/echo_grpc_web_pb.jsができている

終わり。

なんかよくわからなかった。 別のqiita記事を参考にしよ。

tomoyuki-nohara-abeja commented 3 years ago

これが最新ぽい grpc-web/net/grpc/gateway/examples/helloworld at master · grpc/grpc-web