-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
114 lines (88 loc) · 2.65 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
CWD := $(shell pwd)
BIN := node_modules/.bin
export BABEL := $(BIN)/babel
export BROWSERIFY := $(BIN)/browserify
export BUDO := $(BIN)/budo
export COLORTAPE = $(BIN)/colortape
export DEREQUIRE = $(BIN)/derequire
export DEVTOOL := $(BIN)/devtool
export ESDOC := $(BIN)/esdoc
export STANDARD := $(BIN)/standard
export UGLIFYJS = $(BIN)/uglifyjs
SRC += $(wildcard src/*/*/*/*.js)
SRC += $(wildcard src/*/*/*.js)
SRC += $(wildcard src/*/*.js)
SRC += $(wildcard src/*.js)
SRC += $(wildcard src/core/glsl/*/*/*/*.glsl)
SRC += $(wildcard src/core/glsl/*/*/*.glsl)
SRC += $(wildcard src/core/glsl/*/*.glsl)
SRC += $(wildcard src/core/glsl/*.glsl)
TESTS += $(wildcard test/*/*/*/*)
TESTS += $(wildcard test/*/*/*)
TESTS += $(wildcard test/*/*)
TESTS += $(wildcard test/*)
SRC_MAIN = src/index.js
LIB_MAIN = lib/index.js
PROJECT_NAME = axis3d
BABEL_ENV ?= commonjs
DEVTOOL_FLAGS += -hqc -t 1000 -r babel-register
YARN_OR_NPM := $(shell which yarn npm | head -1)
BROWSERIFY_FLAGS += -t babelify
BROWSERIFY_FLAGS_DIST += -t rollupify
BROWSERIFY_FLAGS_DIST += -g babelify
BROWSERIFY_FLAGS_DIST += -s $(PROJECT_NAME)
BROWSERIFY_FLAGS_DIST_MIN += -g rollupify
BROWSERIFY_FLAGS_DIST_MIN += -g babelify
BROWSERIFY_FLAGS_DIST_MIN += -t uglifyify
BROWSERIFY_FLAGS_DIST_MIN += -s $(PROJECT_NAME)
ifeq ($(YARN_OR_NPM),)
$(error Missing package manager. Please install yarn or npm)
endif
define BUILD_PARENT_DIRECTORY
mkdir -p $(dir $@)
endef
define RUN_TEST
$(BROWSERIFY) $(1) $(BROWSERIFY_FLAGS) \
| $(DEVTOOL) $(DEVTOOL_FLAGS) $(1) \
| $(COLORTAPE)
endef
all: lib dist
lib: $(SRC) | node_modules README.md
rm -rf lib
BABEL_ENV=$(BABEL_ENV) $(BABEL) $(BABEL_FLAGS) $(CWD)/src --out-dir $@ --source-maps inline
cp package.json $@
cp README.md $@
dist: dist/$(PROJECT_NAME).js dist/$(PROJECT_NAME).min.js
dist/$(PROJECT_NAME).js: node_modules lib
$(BUILD_PARENT_DIRECTORY)
$(BROWSERIFY) $(BROWSERIFY_FLAGS_DIST) $(LIB_MAIN) \
| $(DEREQUIRE) > $@
dist/$(PROJECT_NAME).min.js: node_modules lib
$(BUILD_PARENT_DIRECTORY)
$(BROWSERIFY) $(BROWSERIFY_FLAGS_DIST_MIN) $(LIB_MAIN) \
| $(DEREQUIRE) \
| $(UGLIFYJS) -c -m > $@
node_modules: package.json
$(YARN_OR_NPM) install
esdoc: node_modules esdoc.json $(SRC)
./scripts/esdoc.sh esdoc.json
.PHONY: example/*
example/*: NODE_PATH="$(NODE_PATH):$(CWD)/example/"
example/*:
$(BUDO) $@/index.js -p 3000 --dir $@ --dir public --live --verbose $(BUDO_FLAGS) -- $(BROWSERIFY_FLAGS) --debug
.PHONY: clean
clean:
rm -rf lib
rm -rf dist
.PHONY: lint
lint: node_modules
$(STANDARD)
.PHONY: link
link: lib
cd lib && $(YARN_OR_NPM) link
.PHONY: test
test: node_modules
$(call RUN_TEST, $@)
.PHONY: $(TESTS)
$(TESTS):
$(call RUN_TEST, $@)