-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
193 lines (158 loc) · 6.96 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
TOP_DIR = ../..
include $(TOP_DIR)/tools/Makefile.common
DEPLOY_RUNTIME ?= /kb/runtime
TARGET ?= /kb/deployment
SRC_PERL = $(wildcard scripts/*.pl)
BIN_PERL = $(addprefix $(BIN_DIR)/,$(basename $(notdir $(SRC_PERL))))
DEPLOY_PERL = $(addprefix $(TARGET)/bin/,$(basename $(notdir $(SRC_PERL))))
SRC_SERVICE_PERL = $(wildcard service-scripts/*.pl)
BIN_SERVICE_PERL = $(addprefix $(BIN_DIR)/,$(basename $(notdir $(SRC_SERVICE_PERL))))
DEPLOY_SERVICE_PERL = $(addprefix $(SERVICE_DIR)/bin/,$(basename $(notdir $(SRC_SERVICE_PERL))))
SERVER_MODULE = CDMI_API
SERVICE = cdmi_api
SERVICE_NAME = CDMI
SERVICE_NAME_PY = cdmi
SERVICE_PSGI_FILE = $(SERVICE_NAME).psgi
SERVICE_PORT = 7032
SERVICE_URL = http://kbase.us/services/$(SERVICE)
#SERVICE_URL = http://10.0.16.68:$(SERVICE_PORT)
CLIENT_TESTS = $(wildcard t/client-tests/*.t)
SERVER_TESTS = $(wildcard t/server-tests/*.t)
PROD_TESTS = $(wildcard t/prod-tests/*.t)
SPHINX_PORT = 7038
SPHINX_HOST = localhost
STARMAN_WORKERS = 8
STARMAN_MAX_REQUESTS = 100
TPAGE_ARGS = --define kb_top=$(TARGET) --define kb_runtime=$(DEPLOY_RUNTIME) --define kb_service_name=$(SERVICE) \
--define kb_service_port=$(SERVICE_PORT) --define kb_service_dir=$(SERVICE_DIR) \
--define kb_sphinx_port=$(SPHINX_PORT) --define kb_sphinx_host=$(SPHINX_HOST) \
--define kb_starman_workers=$(STARMAN_WORKERS) \
--define kb_starman_max_requests=$(STARMAN_MAX_REQUESTS)
JARFILE = $(PWD)/dist/lib/cdmi.jar
all: bin compile-typespec
#all: bin jar
SAPLING_XML = lib/KSaplingDBD.xml
bin: $(BIN_PERL) $(BIN_SERVICE_PERL)
build-erdb: lib/Bio/KBase/CDMI/CDMI_EntityAPIImpl.pm lib/CDMI-EntityAPI.spec
lib/CDMI-EntityAPI.spec lib/Bio/KBase/CDMI/CDMI_EntityAPIImpl.pm: $(SAPLING_XML)
compile_dbd_to_typespec CDMI_API CDMI_EntityAPI $(SAPLING_XML) CDMI-EntityAPI.spec \
lib/Bio/KBase/CDMI/CDMI_EntityAPIImpl.pm scripts
mv CDMI-EntityAPI.spec lib/CDMI-EntityAPI.spec
jar:
ant -Djar_file=$(JARFILE) -Dkb_top=$(KB_TOP) dist
deploy: deploy-all
deploy-all: deploy-client deploy-service
deploy-client: compile-typespec deploy-libs deploy-scripts deploy-docs
deploy-service: deploy-dir deploy-monit deploy-sphinx deploy-service-scripts
$(TPAGE) $(TPAGE_ARGS) service/start_service.tt > $(TARGET)/services/$(SERVICE)/start_service
chmod +x $(TARGET)/services/$(SERVICE)/start_service
$(TPAGE) $(TPAGE_ARGS) service/stop_service.tt > $(TARGET)/services/$(SERVICE)/stop_service
chmod +x $(TARGET)/services/$(SERVICE)/stop_service
deploy-service-scripts:
export KB_TOP=$(TARGET); \
export KB_RUNTIME=$(DEPLOY_RUNTIME); \
export KB_PERL_PATH=$(TARGET)/lib ; \
for src in $(SRC_SERVICE_PERL) ; do \
basefile=`basename $$src`; \
base=`basename $$src .pl`; \
echo install $$src $$base ; \
cp $$src $(TARGET)/plbin ; \
$(WRAP_PERL_SCRIPT) "$(TARGET)/plbin/$$basefile" $(TARGET)/services/$(SERVICE)/bin/$$base ; \
done
deploy-dir:
if [ ! -d $(SERVICE_DIR) ] ; then mkdir $(SERVICE_DIR) ; fi
if [ ! -d $(SERVICE_DIR)/webroot ] ; then mkdir $(SERVICE_DIR)/webroot ; fi
if [ ! -d $(SERVICE_DIR)/bin ] ; then mkdir $(SERVICE_DIR)/bin ; fi
if [ ! -d $(SERVICE_DIR)/sphinx ] ; then mkdir $(SERVICE_DIR)/sphinx ; fi
deploy-sphinx:
$(TPAGE) $(TPAGE_ARGS) service/reindex_sphinx.tt > $(TARGET)/services/$(SERVICE)/reindex_sphinx
chmod +x $(TARGET)/services/$(SERVICE)/reindex_sphinx
$(TPAGE) $(TPAGE_ARGS) service/start_sphinx.tt > $(TARGET)/services/$(SERVICE)/start_sphinx
chmod +x $(TARGET)/services/$(SERVICE)/start_sphinx
$(TPAGE) $(TPAGE_ARGS) service/stop_sphinx.tt > $(TARGET)/services/$(SERVICE)/stop_sphinx
chmod +x $(TARGET)/services/$(SERVICE)/stop_sphinx
$(DEPLOY_RUNTIME)/bin/perl service-scripts/gen_cdmi_sphinx_conf.pl $(SAPLING_XML) lib/sphinx.conf.tt $(TPAGE_ARGS) > $(TARGET)/services/$(SERVICE)/sphinx.conf
deploy-monit:
$(TPAGE) $(TPAGE_ARGS) service/process.$(SERVICE).tt > $(TARGET)/services/$(SERVICE)/process.$(SERVICE)
deploy-docs: deploy-dir
$(DEPLOY_RUNTIME)/bin/pod2html -t "Central Store Application API" lib/Bio/KBase/CDMI/CDMI_APIImpl.pm > doc/application_api.html
$(DEPLOY_RUNTIME)/bin/pod2html -t "Central Store Entity/Relationship API" lib/Bio/KBase/CDMI/CDMI_EntityAPIImpl.pm > doc/er_api.html
cp doc/*html $(SERVICE_DIR)/webroot/.
compile-typespec: Makefile
mkdir -p lib/biokbase/$(SERVICE_NAME_PY)
touch lib/biokbase/__init__.py #do not include code in biokbase/__init__.py
touch lib/biokbase/$(SERVICE_NAME_PY)/__init__.py
mkdir -p lib/javascript/$(SERVICE_NAME)
#-psgi $(SERVICE_PSGI_FILE) \ #psgi compilation for the cdmi_api doesn't work quite right at the moment, just use the old one
compile_typespec \
--impl Bio::KBase::$(SERVICE_NAME)::%sImpl \
--service Bio::KBase::$(SERVICE_NAME)::Service \
--client Bio::KBase::$(SERVICE_NAME)::Client \
--py biokbase/$(SERVICE_NAME_PY)/client \
--js javascript/$(SERVICE_NAME)/Client \
--url $(SERVICE_URL) \
lib/$(SERVICE_NAME)-API.spec lib/$(SERVICE_NAME)-EntityAPI.spec lib
-rm -r lib/$(SERVER_MODULE)Server.py
-rm -r lib/$(SERVER_MODULE)Impl.py
-rm -r lib/CDMI_EntityAPIImpl.py
java-client: java.out/built_flag
java.out/built_flag: lib/CDMI-API.spec lib/CDMI-EntityAPI.spec
rm -rf java.out
mkdir java.out
gen_java_client lib/CDMI-API.spec lib/CDMI-EntityAPI.spec us.kbase.CDMI_API java.out
#
# Ugh. Until we fix the XML or the compiler, patch the subsystem class to remove the reserved word
#
perl -pi.bak -e 's/private/m_private/' java.out/us/kbase/CDMI_API/fields_Subsystem.java
cd java.out; find us -type f -name \*.java -print > tmp.files
cd java.out; $(JAVAC) $(JAVAC_FLAGS) @tmp.files
cd java.out; find us -type f -name \*.class -print > tmp.files
cd java.out; $(JAR) cf cdmi.jar @tmp.files
touch java.out/built_flag
test: test-client
echo "running client and script tests"
# What does it mean to test a client. This is a test of a client
# library. If it is a client-server module, then it should be
# run against a running server. You can say that this also tests
# the server, and I agree. You can add a test-server dependancy
# to the test-client target if it makes sense to you. This test
# example assumes there is already a tested running server.
test-client:
# run each client test
for t in $(CLIENT_TESTS) ; do \
if [ -f $$t ] ; then \
$(DEPLOY_RUNTIME)/bin/perl $$t ; \
if [ $$? -ne 0 ] ; then \
exit 1 ; \
fi \
fi \
done
test-server:
# run each server test
for t in $(SERVER_TESTS) ; do \
if [ -f $$t ] ; then \
echo Running $$t ; \
$(DEPLOY_RUNTIME)/bin/perl $$t ; \
if [ $$? -ne 0 ] ; then \
exit 1 ; \
fi \
fi \
done
test-prod-server:
# run each prod test
for t in $(PROD_TESTS) ; do \
if [ -f $$t ] ; then \
echo Running $$t ; \
$(DEPLOY_RUNTIME)/bin/perl $$t ; \
if [ $$? -ne 0 ] ; then \
exit 1 ; \
fi \
fi \
done
clean:
ant clean
$(BIN_DIR)/%: service-scripts/%.pl $(TOP_DIR)/user-env.sh
$(WRAP_PERL_SCRIPT) '$$KB_TOP/modules/$(CURRENT_DIR)/$<' $@
$(BIN_DIR)/%: service-scripts/%.py $(TOP_DIR)/user-env.sh
$(WRAP_PYTHON_SCRIPT) '$$KB_TOP/modules/$(CURRENT_DIR)/$<' $@
include $(TOP_DIR)/tools/Makefile.common.rules