-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
221 lines (179 loc) · 6.63 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# Copyright (c) 2010 , NetEase.com,Inc. All rights reserved.
#
# Author: Yang Bo (pop.atry@gmail.com)
#
# Use, modification and distribution are subject to the "New BSD License"
# as listed at <url: http://www.opensource.org/licenses/bsd-license.php >.
include config.mk
ifeq ($(OS), Windows_NT)
PROTOC_GEN_AS3=dist\\protoc-gen-as3$(BAT)
else
PROTOC_GEN_AS3=dist/protoc-gen-as3$(BAT)
endif
ALL=dist/protoc-gen-as3 dist/protoc-gen-as3.bat dist/LICENSE \
dist/protobuf.swc dist/README dist/options.proto \
dist/protoc-gen-as3.jar dist/protobuf-java-$(PROTOBUF_VERSION).jar \
dist/run.n dist/haxelib.xml dist/com dist/google
all: $(ALL)
ifndef PROTOC
PROTOC=$(PROTOBUF_DIR)/src/protoc$(EXE)
PROTOCDEPS=$(PROTOC)
$(PROTOC): $(PROTOBUF_DIR)/Makefile
cd $(PROTOBUF_DIR) && $(MAKE)
$(PROTOBUF_DIR)/Makefile: $(PROTOBUF_DIR)/configure
cd $(PROTOBUF_DIR) && ./configure
$(PROTOBUF_DIR)/configure:
cd $(PROTOBUF_DIR) && ./autogen.sh
$(PROTOBUF_DIR)/java/target/protobuf-java-$(PROTOBUF_VERSION).jar: \
$(PROTOBUF_DIR)/src \
$(PROTOC)
cd $(PROTOBUF_DIR)/java && $(MVN) package -Dmaven.test.skip=true
endif
hxclasses: dist/protobuf.swc
$(RM) -r $@
$(HAXE) --gen-hx-classes -swf-lib dist/protobuf.swc -swf dummy.swf --no-output
dist/com: hxclasses
$(RM) -r $@
cp -r hxclasses/com $@
dist/google: hxclasses
$(RM) -r $@
cp -r hxclasses/google $@
dist/haxelib.xml: haxelib.xml
install --mode=644 $< $@
dist/run.n: hx/com/dongxiguo/protobuf/Run.hx
$(HAXE) -cp hx -lib haxelib-run -main com.dongxiguo.protobuf.Run -neko $@
classes/com/netease/protocGenAs3/Main.class: \
plugin.proto.java/google/protobuf/compiler/Plugin.java \
options.proto.java/com \
compiler/com/netease/protocGenAs3/Main.java \
$(PROTOBUF_DIR)/java/target/protobuf-java-$(PROTOBUF_VERSION).jar \
| classes
$(JAVAC) -source 1.5 -target 1.5 -encoding UTF-8 -d classes \
-classpath "$(PROTOBUF_DIR)/java/target/protobuf-java-$(PROTOBUF_VERSION).jar" \
-sourcepath "plugin.proto.java$(PATH_SEPARATOR)compiler$(PATH_SEPARATOR)options.proto.java" \
compiler/com/netease/protocGenAs3/Main.java
plugin.proto.java/google/protobuf/compiler/Plugin.java: \
$(PROTOCDEPS) | plugin.proto.java
$(PROTOC) \
"--proto_path=$(PROTOBUF_DIR)/src" --java_out=plugin.proto.java \
"$(PROTOBUF_DIR)/src/google/protobuf/compiler/plugin.proto"
dist.tar.gz: $(ALL)
tar -acf dist.tar.gz -C dist .
release.zip: $(ALL)
cd dist && zip --recurse-paths --filesync ../$@ $(patsubst dist/%,%,$^)
dist/LICENSE: LICENSE | dist
install --mode=644 $< $@
dist/README: README | dist
install --mode=644 $< $@
dist/options.proto: options.proto | dist
install --mode=644 $< $@
dist/protoc-gen-as3: dist/protoc-gen-as3.jar dist/protobuf-java-$(PROTOBUF_VERSION).jar \
| dist
(echo '#!/bin/sh';\
echo 'cd "`dirname "$$0"`" && java -jar protoc-gen-as3.jar') > $@
chmod +x $@
dist/protoc-gen-as3.bat: dist/protoc-gen-as3.jar dist/protobuf-java-$(PROTOBUF_VERSION).jar \
| dist
(echo '@cd %~dp0';\
echo '@java -jar protoc-gen-as3.jar') > $@
chmod +x $@
COMMA=,
dist/protobuf.swc: $(wildcard as3/com/netease/protobuf/*/*.as as3/com/netease/protobuf/*.as) descriptor.proto.as3/google | dist
$(COMPC) -target-player=10 \
-source-path+=as3,descriptor.proto.as3 \
-include-sources+=as3 \
-output=$@
doc: \
$(wildcard as3/com/netease/protobuf/*/*.as as3/com/netease/protobuf/*.as) \
descriptor.proto.as3/google \
| dist
$(ASDOC) -target-player=10 \
--doc-sources+=as3 \
--source-path+=descriptor.proto.as3 \
-output=$@ \
-exclude-sources+=as3/com/netease/protobuf/CustomOption.as
doc.tar.gz: doc
tar -acf $@ $<
MANIFEST.MF:
echo Class-Path: protobuf-java-$(PROTOBUF_VERSION).jar > $@
dist/protoc-gen-as3.jar: classes/com/netease/protocGenAs3/Main.class \
MANIFEST.MF | dist
$(JAR) cemf com/netease/protocGenAs3/Main MANIFEST.MF $@ -C classes .
dist/protobuf-java-$(PROTOBUF_VERSION).jar: \
$(PROTOBUF_DIR)/java/target/protobuf-java-$(PROTOBUF_VERSION).jar \
| dist
cp $< $@
options.proto.java descriptor.proto.as3 classes plugin.proto.java unittest.proto.as3 dist:
mkdir $@
clean:
$(RM) -r release.zip doc doc.tar.gz dist dist.tar.gz classes unittest.proto.as3 descriptor.proto.as3 plugin.proto.java test.swc test.swf options.proto.java
test: test.swf
(sleep 1s; echo c; sleep 3s; echo c; sleep 1s) | $(FDB) $<
haxe-test: haxe-test.swf
(sleep 1s; echo c; sleep 1s; echo c; sleep 1s) | $(FDB) $<
haxe-test.swc: test/com/netease/protobuf/test/TestAll.as \
dist/protobuf.swc test.swc descriptor.proto.as3/google unittest.bin
$(RM) -r $@
$(COMPC) -target-player=10 \
-directory -include-sources+=$< \
-source-path+=descriptor.proto.as3 \
-library-path+=test.swc,dist/protobuf.swc \
-output=$@
haxe-test.swf: haxe-test.swc test/com/netease/protobuf/test/HaxeTest.hx test.swf
$(HAXE) -cp test -main com.netease.protobuf.test.HaxeTest \
-debug -D fdb --macro 'patchTypes("haxe-test.patch")' \
-swf $@ -swf-version 10 -swf-lib $</library.swf
test.swf: test.swc test/com/netease/protobuf/test/TestAll.as \
test/com/netease/protobuf/test/Test.mxml dist/protobuf.swc \
descriptor.proto.as3/google unittest.bin
$(MXMLC) -target-player=10 \
-library-path+=test.swc,dist/protobuf.swc -output=$@ \
-source-path+=descriptor.proto.as3,test test/com/netease/protobuf/test/Test.mxml -debug
test.swc: unittest.proto.as3/protobuf_unittest dist/protobuf.swc
$(COMPC) -target-player=10 \
-include-sources+=unittest.proto.as3 \
-external-library-path+=dist/protobuf.swc -output=$@
options.proto.java/com: \
options.proto \
$(PROTOCDEPS) \
| options.proto.java
$(PROTOC) \
--proto_path=. \
"--proto_path=$(PROTOBUF_DIR)/src" \
--java_out=options.proto.java $<
touch $@
descriptor.proto.as3/google: \
$(PROTOCDEPS) \
dist/protoc-gen-as3$(BAT) \
| descriptor.proto.as3
$(PROTOC) \
--plugin=protoc-gen-as3=$(PROTOC_GEN_AS3) \
"--proto_path=$(PROTOBUF_DIR)/src" \
--as3_out=descriptor.proto.as3 \
"$(PROTOBUF_DIR)/src/google/protobuf/descriptor.proto"
touch $@
unittest.bin: $(PROTOCDEPS) $(wildcard test/*.proto)
$(PROTOC) \
--proto_path=test --proto_path=. \
"--proto_path=$(PROTOBUF_DIR)/src" \
--descriptor_set_out=$@ \
$(PROTOBUF_DIR)/src/google/protobuf/unittest.proto \
$(PROTOBUF_DIR)/src/google/protobuf/unittest_import.proto \
test/*.proto
unittest.proto.as3/protobuf_unittest: \
$(PROTOCDEPS) \
dist/protoc-gen-as3$(BAT) \
$(wildcard test/*.proto) \
| unittest.proto.as3
$(PROTOC) \
--plugin=protoc-gen-as3=$(PROTOC_GEN_AS3) \
--proto_path=test --proto_path=. \
"--proto_path=$(PROTOBUF_DIR)/src" \
--as3_out=unittest.proto.as3 \
$(PROTOBUF_DIR)/src/google/protobuf/unittest.proto \
$(PROTOBUF_DIR)/src/google/protobuf/unittest_import.proto \
test/*.proto
touch $@
install: release.zip
haxelib test $<
.PHONY: plugin all clean test doc install