forked from grpc/grpc-web
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
119 lines (101 loc) · 4.18 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
OS := $(shell uname)
CC := g++
ROOT_DIR := $(shell pwd)
GRPC_GATEWAY_PROTOS := $(ROOT_DIR)/net/grpc/gateway/protos
PROTO_INC := $(ROOT_DIR)/third_party/grpc/third_party/protobuf/include
PROTO_SRC := $(ROOT_DIR)/third_party/grpc/third_party/protobuf/src
PROTO_LIB := $(PROTO_SRC)/.libs
PROTOC := $(PROTO_SRC)/protoc
GRPC_INC := $(ROOT_DIR)/third_party/grpc/include
GRPC_SRC := $(ROOT_DIR)/third_party/grpc
GRPC_LIB := $(ROOT_DIR)/third_party/grpc/libs/opt
all: clean package_static
protos:
cd "$(ROOT_DIR)" && LD_LIBRARY_PATH="$(PROTO_LIB):$(GRPC_LIB)" "$(PROTOC)" \
--proto_path="$(GRPC_GATEWAY_PROTOS)" \
--proto_path="$(PROTO_SRC)" "$(GRPC_GATEWAY_PROTOS)/pair.proto" \
--cpp_out="$(GRPC_GATEWAY_PROTOS)"
cd "$(ROOT_DIR)" && LD_LIBRARY_PATH="$(PROTO_LIB):$(GRPC_LIB)" "$(PROTOC)" \
--proto_path="$(GRPC_GATEWAY_PROTOS)" \
--proto_path="$(PROTO_SRC)" "$(GRPC_GATEWAY_PROTOS)/stream_body.proto" \
--cpp_out="$(GRPC_GATEWAY_PROTOS)"
NGINX_DIR := third_party/nginx
NGINX_LD_OPT := -L"$(PROTO_LIB)" -L"$(GRPC_LIB)" -lgrpc++ \
-lgrpc -lprotobuf -lpthread -ldl -lrt -lstdc++ -lm
ifeq ($(OS), Darwin)
NGINX_LD_OPT := -L"$(PROTO_LIB)" -L"$(GRPC_LIB)" -lgrpc++ \
-lgrpc -lprotobuf -lpthread -lstdc++ -lm
endif
NGINX_STATIC_LD_OPT := -L"$(PROTO_LIB)" -L"$(GRPC_LIB)" \
-l:libgrpc++.a -l:libgrpc.a -l:libprotobuf.a -lpthread -ldl \
-lrt -lstdc++ -lm
ifeq ($(OS), Darwin)
NGINX_STATIC_LD_OPT := $(NGINX_LD_OPT)
endif
nginx_config:
cd "$(NGINX_DIR)/src" && LD_LIBRARY_PATH="$(PROTO_LIB):$(GRPC_LIB)" \
auto/configure \
--with-http_ssl_module \
--with-http_v2_module \
--with-cc-opt="-I /usr/local/include -I $(ROOT_DIR) -I $(PROTO_INC) -I $(PROTO_SRC) \
-I $(GRPC_INC) -I $(GRPC_SRC)" \
--with-ld-opt="$(NGINX_LD_OPT)" \
--with-openssl="$(ROOT_DIR)/third_party/openssl" \
--add-module="$(ROOT_DIR)/net/grpc/gateway/nginx"
nginx_config_static:
cd "$(NGINX_DIR)/src" && LD_LIBRARY_PATH="$(PROTO_LIB):$(GRPC_LIB)" \
auto/configure \
--with-http_ssl_module \
--with-http_v2_module \
--with-cc-opt="-I /usr/local/include -I $(ROOT_DIR) -I $(PROTO_INC) -I $(PROTO_SRC) \
-I $(GRPC_INC) -I $(GRPC_SRC)" \
--with-ld-opt="$(NGINX_STATIC_LD_OPT)" \
--add-module="$(ROOT_DIR)/net/grpc/gateway/nginx"
nginx: protos nginx_config
cd "$(NGINX_DIR)/src" && make
nginx_static: protos nginx_config_static
cd "$(NGINX_DIR)/src" && make
package: nginx
mkdir -p "$(ROOT_DIR)"/gConnector/conf
cp "$(ROOT_DIR)"/third_party/nginx/src/conf/* "$(ROOT_DIR)"/gConnector/conf
cp "$(ROOT_DIR)"/net/grpc/gateway/nginx/package/nginx.conf \
"$(ROOT_DIR)"/gConnector/conf
cp "$(ROOT_DIR)"/net/grpc/gateway/nginx/package/nginx.sh \
"$(ROOT_DIR)"/gConnector
cp "$(ROOT_DIR)"/third_party/nginx/src/objs/nginx \
"$(ROOT_DIR)"/gConnector
cd "$(ROOT_DIR)" && zip -r gConnector.zip gConnector/*
package_static: nginx_static
mkdir -p "$(ROOT_DIR)"/gConnector_static/conf
cp "$(ROOT_DIR)"/third_party/nginx/src/conf/* \
"$(ROOT_DIR)"/gConnector_static/conf
cp "$(ROOT_DIR)"/net/grpc/gateway/nginx/package/nginx.conf \
"$(ROOT_DIR)"/gConnector_static/conf
cp "$(ROOT_DIR)"/net/grpc/gateway/nginx/package/nginx.sh \
"$(ROOT_DIR)"/gConnector_static
cp "$(ROOT_DIR)"/third_party/nginx/src/objs/nginx \
"$(ROOT_DIR)"/gConnector_static
cd "$(ROOT_DIR)" && zip -r gConnector_static.zip gConnector_static/*
plugin:
cd "$(ROOT_DIR)"/javascript/net/grpc/web && make
install-plugin:
cd "$(ROOT_DIR)"/javascript/net/grpc/web && make install
example: plugin
cd "$(ROOT_DIR)"/net/grpc/gateway/examples/echo && make
standalone-proxy: package_static
cd "$(ROOT_DIR)"/net/grpc/gateway/examples/echo && make standalone-proxy
echo_server:
cd "$(ROOT_DIR)"/net/grpc/gateway/examples/echo && make echo_server
client:
cd "$(ROOT_DIR)"/net/grpc/gateway/examples/echo && make client
install-example:
cd "$(ROOT_DIR)"/net/grpc/gateway/examples/echo && make install
clean:
cd "$(ROOT_DIR)" && rm -rf objs gConnector gConnector_static \
third_party/nginx/src/objs third_party/openssl/.openssl
cd "$(ROOT_DIR)" && rm -f gConnector.zip gConnector_static.zip \
"$(GRPC_GATEWAY_PROTOS)"/*.pb.cc "$(GRPC_GATEWAY_PROTOS)"/*.pb.h \
third_party/nginx/src/Makefile
cd "$(ROOT_DIR)"/net/grpc/gateway/examples/echo && make clean
cd "$(ROOT_DIR)"/javascript/net/grpc/web && make clean
cd "$(ROOT_DIR)"