forked from sirikata/katajs
/
Makefile
73 lines (53 loc) · 1.92 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
### PBJ Vars
PBJDIR=externals/protojs
PBJBIN=$(PBJDIR)/pbj
INPUTDIR=externals/sirikata-protocol
OUTPUTDIR=katajs/oh/plugins/sirikata/impl
THESE_PBJ=$(wildcard $(INPUTDIR)/*.pbj)
THESE_PBJJS=$(patsubst $(INPUTDIR)/%,$(OUTPUTDIR)/%.js,$(THESE_PBJ))
ALL_PBJJS += $(THESE_PBJJS)
### Closure Vars
CLOSURESRCS=katajs/core/Core.js \
externals/protojs/protobuf.js externals/protojs/pbj.js \
externals/GLGE/glge_math.js externals/GLGE/glge.js externals/GLGE/glge_collada.js \
katajs/gfx/WebGLCompat.js katajs/gfx/glgegfx.js katajs/gfx/TextGraphics.js
CLOSURESRCS+=$(shell find katajs/core katajs/oh katajs/network katajs/space -name '*.js' -and -not -name 'Core.js' -and -not -name 'GenericWorker.js' )
CLOSUREOUT=katajs.compiled.js
CLOSURE=java -jar externals/GLGE/closure/compiler.jar
CLOSUREARGS=--js $$before
CLOSUREARGS+=$(patsubst %,--js %,$(CLOSURESRCS))
CLOSUREARGS+=--js $$after
CLOSUREARGS+=--externs contrib/closure_preinclude.js
CLOSUREARGS+=--formatting pretty_print
CLOSUREARGS+=--compilation_level SIMPLE_OPTIMIZATIONS
CLOSUREARGS+= --js_output_file $(CLOSUREOUT)
COMMA=,
#CLOSURE=python makeclosure.py
#CLOSUREARGS=$(CLOSURESRCS)
#CLOSUREARGS+= > $(CLOSUREOUT)
### Rules
all : pbj $(ALL_PBJJS) test_pbj
### PBJ Rules
pbj : $(PBJBIN)
$(PBJBIN) :
cd $(PBJDIR) && \
./bootstrap.sh && \
$(MAKE)
test_pbj : tests/pbj/Test.pbj
$(MAKE) -C tests/pbj
$(OUTPUTDIR)/%.pbj.js: $(INPUTDIR)/%.pbj
@mkdir $(OUTPUTDIR) 2>/dev/null || true
$(PBJBIN) $< $@
### Closure Rules
closure : $(CLOSUREOUT)
depends:
git submodule init
git submodule update
$(CLOSUREOUT) : $(CLOSURESRCS)
before=`mktemp` && \
after=`mktemp` && \
echo "if(typeof(Kata)=='undefined')Kata={};Kata.closureIncluded={'katajs/core/Core.js':true $(patsubst %,$(COMMA) '%':true,$(CLOSURESRCS))};" > $$before && \
echo "(function(){for(var i in Kata.closureIncluded){Kata.setIncluded(i);}})();" > $$after && \
$(CLOSURE) $(CLOSUREARGS) || \
rm -f "$@"
.PHONY: test_pbj closure all