forked from killmag10/nodeschnaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
150 lines (121 loc) · 3.38 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
NODESCHNAPS_DEPPENDENCY_NODE_DIST_URL ?= http://nodejs.org/dist/
NODESCHNAPS_DEPPENDENCY_NODE_VERSION := 0.12.17
# Paths
PATH_TEST := test
PATH_DEPS := deps
PATH_NODE_MODULES := node_modules
PATH_DOCS := docs
PATH_RHINO_JAR := $(shell readlink -f $(PATH_DEPS)/rhino/lib/rhino-1.7.7.1.jar)
NODESCHNAPS_PATH := $(shell readlink -f lib)
# A test value for env tests
TEST_VAR := 123 test -
TEST_TEMP_PATH := $(shell readlink -f temp)
TEST_RESOURCE_PATH := $(shell readlink -f test/resource)
export TEST_VAR
export TEST_TEMP_PATH
export TEST_RESOURCE_PATH
TEST_DIRS := test/lib
TEST_FILES := $(shell find $(TEST_DIRS) -type f -name '*.js')
# Macros
EXISTS_DOCS = $(shell $(TEST) -d $(PATH_DOCS)/html && printf '1')
# Commands
CD := cd
MV := mv
NPM := npm
WGET := wget
TAR := tar
NODE := node
TEST := test
MKDIR := mkdir
JAVA := java
JAVA_RHINO := $(JAVA) \
-cp $(PATH_RHINO_JAR) \
-DNODESCHNAPS_PATH=$(NODESCHNAPS_PATH)
JAVA_NASHORN := jrunscript
.PHONY: \
all \
help \
install \
uninstall \
test \
.installDependencyNodeSource \
$(TEST_FILES)
all: help
help:
########################################
# Help:
# help Show the help.
# install Install the project.
# uninstall Uninstall the project.
# test Run the tests.
########################################
npmInstall: .installDependencyNodeSource .setupFolders
install: npmInstall
# Install npm packages
@$(NPM) install
npmUninstall:
# Remove $(PATH_DEPS)/node
@$(RM) -r $(PATH_DEPS)/node
uninstall: npmUninstall
# Remove $(PATH_NODE_MODULES)/
@$(RM) -r $(PATH_NODE_MODULES)/*
clean: distclean
distclean: .cleanHtml
test:
########################################
# START TESTING
# NODESCHNAPS_PATH: $(NODESCHNAPS_PATH)
########################################
@$(CD) $(PATH_TEST) \
&& $(JAVA_RHINO) \
org.mozilla.javascript.tools.shell.Main \
test.rhino.js
$(TEST_FILES):
@$(CD) $(PATH_TEST) \
&& $(JAVA_RHINO) \
-DTEST_FILE='$(subst test/,,$@)' \
org.mozilla.javascript.tools.shell.Main \
test.rhino.js
devTest:
########################################
# START DEVELOPMENT TESTING SCRIPT
# NODESCHNAPS_PATH: $(NODESCHNAPS_PATH)
########################################
@$(CD) $(PATH_TEST) \
&& $(JAVA_RHINO) \
org.mozilla.javascript.tools.shell.Main \
development.rhino.js
testNashorn:
########################################
# START TESTING
# NODESCHNAPS_PATH: $(NODESCHNAPS_PATH)
########################################
@$(CD) $(PATH_TEST) \
&& $(JAVA_NASHORN) test.nashorn.js
testNode:
########################################
# START TESTING in Node
########################################
@$(CD) $(PATH_TEST) \
&& $(NODE) test.node.js
html: .cleanHtml
# Create html docs under docs/html/api
@$(PATH_NODE_MODULES)/.bin/jsdoc \
--destination $(PATH_DOCS)/html/api \
--recurse \
lib/
.cleanHtml:
ifeq ($(EXISTS_DOCS),1)
# Remove html docs
@$(TEST) ! -d $(PATH_DOCS)/html || $(RM) -r $(PATH_DOCS)/html
endif
.setupFolders:
# Create test temp directory.
@$(TEST) -d "$$TEST_TEMP_PATH" || $(MKDIR) "$$TEST_TEMP_PATH"
.installDependencyNodeSource: $(PATH_DEPS)/node
# Paths
$(PATH_DEPS)/node:
# Install nodejs source
@$(WGET) -O - '$(NODESCHNAPS_DEPPENDENCY_NODE_DIST_URL)v$(NODESCHNAPS_DEPPENDENCY_NODE_VERSION)/node-v$(NODESCHNAPS_DEPPENDENCY_NODE_VERSION).tar.gz' \
| $(TAR) -xz -C $(PATH_DEPS)/
@$(MV) $(PATH_DEPS)/node-v$(NODESCHNAPS_DEPPENDENCY_NODE_VERSION) $(PATH_DEPS)/node