-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (72 loc) 路 2.24 KB
/
Copy pathMakefile
File metadata and controls
86 lines (72 loc) 路 2.24 KB
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
################################################################################
# Cheddar Makefile
# Available Targets:
# default: Production build
# build : Development build
# %.node : Builds binding/%
# install: Installs to given path
#
# Phony targets:
# clean : Removed unecessary stuff from directory
# test : Performs tests
# bench : Performs benchmarks
#
################################################################################
PREFIX=./node_modules/.bin
SELF=$(lastword $(MAKEFILE_LIST))
## Compiler
# The compiler to use for the ES7 -> ES5 transformation
JC=$(PREFIX)/babel
# Location of files
SRC=src/
OUT=dist/
# The flags to pass to the compiler
JCFLAGS=$(SRC) -d $(OUT)
# The binary files to copy
BIN=cli/cheddar
EXE=cheddar
BIN_MAKE=$(foreach BIN_FILE,$(BIN),chmod 755 $(SRC)$(BIN_FILE) && cp $(SRC)$(BIN_FILE) $(OUT)$(BIN_FILE)${\n})
## Tests
TESTRUNNER=$(PREFIX)/babel-node
COVERAGE=$(PREFIX)/babel-istanbul
TEST=$(PREFIX)/_mocha
TFLAGS=cover $(TEST)
BENCHMARK=benchmark/
# Bindings
BINDING_SRC = $(wildcard bindings/*/binding.gyp)
BINDING_TARGETS = $(foreach B,$(patsubst bindings/%/binding.gyp, %, $(BINDING_SRC)),bindings/$B/build/Release/$B.node)
## Rules
all: default
# The binding task
# Compiles all gyp bingings
# from bingings/foo/binding.gyp
%.node:
node-gyp rebuild -C ./bindings/$(shell echo $* | cut -d "/" -f2)/
# The default task
# The **production** build
default: $(BINDING_TARGETS) $(JC)
NODE_ENV=production $(JC) $(JCFLAGS) --minified --compact true
$(BIN_MAKE)
# Development build task
# This builds and includes source maps
build: $(BINDING_TARGETS) $(JC)
$(JC) $(JCFLAGS) --source-maps
$(BIN_MAKE)
# Runs install with default method
# Perhaps pass args later?
install: ./bin/install
./bin/install --method=path
# Runs browser_repl build for web REPL
# Uses browserify to compiled babelified code
# browser_build: $(JC)
# $(PREFIX)/browserify dist/cli/browser_repl.js -o Cheddar.js
# Performs testing, including coverage
# At the moment uses mocha for testing
# and babel-istanbul for coverage
test: $(TESTRUNNER) $(COVERAGE) $(TEST)
$(TESTRUNNER) $(COVERAGE) $(TFLAGS)
bench: $(BENCHMARK) $(OUT)
node $(BENCHMARK)
clean: $(OUT)
rm -rf $(OUT)
.PHONY: test benchmark clean build default