-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathMakefile
More file actions
143 lines (122 loc) · 4.41 KB
/
Makefile
File metadata and controls
143 lines (122 loc) · 4.41 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
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
# http://stackoverflow.com/questions/3774568/makefile-issue-smart-way-to-scan-directory-tree-for-c-files
recursive_wildcard = $(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call recursive_wildcard,$d/,$2))
#
# build
#
CMD_BABEL=node node_modules/.bin/babel
CMD_WEBPACK=node node_modules/.bin/webpack
SOURCES_JS=$(call recursive_wildcard,src/,*.js)
COMPILED_JS=$(SOURCES_JS:src/%.js=lib/%.js)
BUNDLE_JS=dist/lightstep-tracer.js dist/lightstep-tracer.min.js
.PHONY: build
build: node_modules build-node build-browser
.PHONY: node_modules
node_modules:
npm install
.PHONY: build-browser
build-browser: $(BUNDLE_JS)
$(BUNDLE_JS): $(SOURCES_JS) webpack.config.js package.json
NODE_ENV=development $(CMD_WEBPACK)
NODE_ENV=production $(CMD_WEBPACK)
.PHONY: build-node
build-node: $(COMPILED_JS)
lib/%.js: src/%.js
@mkdir -p $(@D)
$(CMD_BABEL) --presets=@babel/preset-env --plugins add-module-exports,@babel/proposal-object-rest-spread,@babel/transform-spread,@babel/syntax-object-rest-spread $< -o $@ --source-maps
.PHONY: clean
clean:
rm -rf dist
rm -rf lib
rm -rf coverage
#
# release
#
# NOTE: `npm version` automatically creates a git commit and git tag for the
# incremented version
.PHONY: release
release: test test-all coverage
@if [ $(shell git symbolic-ref --short -q HEAD) = "master" ]; then exit 0; else \
echo "Current git branch does not appear to be 'master'. Refusing to publish."; exit 1; \
fi
npm version $(RELEASE_TYPE)
npm run release:prepare
@echo
@echo "Version and tag created. The publish will be done automatically from circleCI."
@echo
# NOTE: the benchmark package is *not* part of package.json as it relies on a
# native module -- that does not compile on all systems. Until/unless that is
# resolved, it gets "manually" installed here when the benchmarks are run
#
# NOTE: the --max-old-space-size=4000 works around what appears to be a defect
# in Node 6.x
.PHONY: benchmark
benchmark: build node_modules/sc-benchmark
node --max-old-space-size=4000 benchmarks/benchmark.js
node_modules/sc-benchmark:
npm install sc-benchmark@0.1.11
#
# test
#
test: build test-node test-browser lint
# The "_mocha" in the below is important:
# https://github.com/gotwarlost/istanbul/issues/262
.PHONY: coverage
coverage: build
rm -f test/results/*.json
node node_modules/nyc/bin/nyc --reporter=lcov --reporter=html node_modules/mocha/bin/_mocha -- -c test/unittest_node.js
@echo
@echo "Coverage is currently run against the compiled code. Numbers are not fully accurate."
@echo "Open coverage/lcov-report/index.html for details."
.PHONY: test-node
test-node:
npm test
.PHONY: test-browser
test-browser:
cp dist/lightstep-tracer.js test/dist
cd test && node ../node_modules/webpack/bin/webpack.js ./unittest_browser.js -o dist/unittest_browser.bundle.js
cd test && open unittest.html
# Note: versions < 6.2 are *not* supported. The 'beforeExit' event has
# different behavior that does not work with the current implementation.
.PHONY: test-all
test-all: build
scripts/docker_test.sh latest
scripts/docker_test.sh 16
scripts/docker_test.sh 14
scripts/docker_test.sh 12
#
# lint
#
.PHONY: lint
lint:
node node_modules/eslint/bin/eslint.js --color --fix src
#
# watch
#
# Dev convenience for automatically rebuilding on file changes
.PHONY: watch
watch: build
node node_modules/watch-trigger/index.js watch-trigger.config.json
.PHONY: example-browser
example-browser: build
cd examples/browser && bash run.sh
# LightStep internal target
.PHONY: thrift
thrift: thrift-compile thrift-postprocess
.PHONY: thrift-compile
thrift-compile:
docker run -v "$(LIGHTSTEP_REPO_ROOT)/go/src/github.com/lightstep/common-go/:/data" -v "$(PWD):/out" --rm thrift:0.9.2 \
thrift -r -gen js:node -out /out/src/imp/platform/node/thrift_api /data/crouton.thrift
docker run -v "$(LIGHTSTEP_REPO_ROOT)/go/src/github.com/lightstep/common-go/:/data" -v "$(PWD):/out" --rm thrift:0.9.2 \
thrift -r -gen js -out /out/src/imp/platform/browser/thrift_api /data/crouton.thrift
rm src/imp/platform/browser/thrift_api/ReportingService.js
rm src/imp/platform/node/thrift_api/ReportingService.js
.PHONY: thrift-postprocess
thrift-postprocess:
node ./scripts/build_browser_thrift_lib.js
node ./scripts/build_node_thrift_lib.js
# LightStep internal target
.PHONY: proto
proto:
protoc -I"$(PWD)/../googleapis/:$(PWD)/../lightstep-tracer-common/" \
--js_out=import_style=commonjs,binary:src/imp/generated_proto \
collector.proto google/api/annotations.proto google/api/http.proto