-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathMakefile
125 lines (95 loc) · 3.62 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
GITCOMMIT := $(shell git rev-parse --short HEAD)
VER := $(GITCOMMIT)
EPOCH := $(shell date +%s)
#EXT_KIDL_JAR = kbase-kidl-parser-$(EPOCH)-$(VER).jar
TAGS := $(shell git tag --contains $(GITCOMMIT))
TOP_DIR = $(shell python -c "import os.path as p; print(p.abspath('../..'))")
TOP_DIR_NAME = $(shell basename $(TOP_DIR))
DIR = $(shell pwd)
ANT ?= ant
ANT_OPTIONS =
KBASE_COMMON_JAR = kbase/common/kbase-common-0.0.23.jar
QUOTE = '\''
# make sure our make test works
.PHONY : test test-python
default: compile
ifeq ($(TOP_DIR_NAME), dev_container)
##############################
#### INSIDE DEV CONTAINER ####
##############################
#include $(TOP_DIR)/tools/Makefile.common
#include $(TOP_DIR)/tools/Makefile.common.rules
DEPLOY_RUNTIME ?= /kb/runtime
JAVA_HOME ?= $(DEPLOY_RUNTIME)/java
TARGET ?= /kb/deployment
# inside dev_container, we build and copy to dev_container/bin
compile:
$(ANT) -DEXT_KIDL_JAR=$(EXT_KIDL_JAR) -DKBASE_COMMON_JAR=$(KBASE_COMMON_JAR)
$(ANT) copy_local_bin -DBIN_TARGET=$(TOP_DIR)/bin
prepare-bin:
$(ANT) prepare_bin -DEXT_KIDL_JAR=$(EXT_KIDL_JAR) -DKBASE_COMMON_JAR=$(KBASE_COMMON_JAR)
else
###############################
#### OUTSIDE DEV CONTAINER ####
###############################
compile: jars-submodule-init
$(ANT) -Djardir=submodules/jars/lib/jars/ -DKBASE_COMMON_JAR=$(KBASE_COMMON_JAR)
prepare-bin:
$(ANT) prepare_bin -Djardir=submodules/jars/lib/jars/ -DKBASE_COMMON_JAR=$(KBASE_COMMON_JAR)
endif
bin: jars-submodule-init
mkdir -p bin
echo '#!/bin/bash' > bin/kb-sdk
echo 'DIR=$(DIR)' >> bin/kb-sdk
echo 'KBASE_JARS_DIR=$$DIR/submodules/jars/lib/jars' >> bin/kb-sdk
@# Next command processes links in JAR_DEPS_BIN file and has 5 parts (one on each line):
@# (1) removing comments
@# (2) trimming each line (picking first word actually)
@# (3) skipping empty lines
@# (4) joining lines into one with colon separator
@# (5) adding variable name prefix followed by equal character
echo 'cat ./JAR_DEPS_BIN | sed "/^[[:blank:]]*#/d;s/#.*//" \
| awk $(QUOTE){print $$1}$(QUOTE) \
| grep -v "^$$" \
| awk $(QUOTE){print "$$KBASE_JARS_DIR/"$$1":"}$(QUOTE) ORS="" \
| awk $(QUOTE){print "CLASS_PATH_PREFIX="$$1}$(QUOTE) >> bin/kb-sdk' > bin/temp-script
bash bin/temp-script
rm bin/temp-script
echo 'java -cp $$CLASS_PATH_PREFIX$$KBASE_JARS_DIR/$(KBASE_COMMON_JAR):$$DIR/lib/kbase_module_builder2.jar \
us.kbase.mobu.ModuleBuilder $$@' >> bin/kb-sdk
chmod +x bin/kb-sdk
submodule-init:
git submodule init
git submodule update
cp submodules_hacks/AuthConstants.pm submodules/auth/Bio-KBase-Auth/lib/Bio/KBase/
jars-submodule-init:
git submodule update --init submodules/jars
deploy: deploy-client deploy-service deploy-scripts
undeploy:
@echo "Nothing to undeploy"
deploy-client:
@echo "No clients to deploy"
deploy-service:
@echo "No service to deploy"
deploy-scripts:
if [ "$(TARGET)" = "" ]; \
then \
echo "Error makefile variable TARGET must be defined to deploy-scripts"; \
exit 1; \
fi;
$(ANT) deploy_bin -DBIN_TARGET=$(TARGET)/bin -DBIN_LIB_TARGET=$(TARGET)/lib -DKBASE_COMMON_JAR=$(KBASE_COMMON_JAR)
test: submodule-init
@echo "Running unit tests"
make test-python
@# todo: remove perl typecomp tests and add it as a separate target
$(ANT) test -DKBASE_COMMON_JAR=$(KBASE_COMMON_JAR)
test-python:
python -m nose2 -s test_scripts/py_module_tests -t src/java/us/kbase/templates
test-client:
@echo "No tests for client - this kbase module is not a service, and has no clients"
test-service:
@echo "No tests for service - this kbase module is not a service"
test-scripts:
@echo "No direct tests for scripts - run unit tests with test target instead"
clean:
$(ANT) clean