forked from TritonDataCenter/sdc-napi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
157 lines (132 loc) · 4.05 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
151
152
153
154
155
156
157
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
#
# Copyright 2017, Joyent, Inc.
#
#
# NAPI Makefile
#
#
# Tools
#
ISTANBUL := node_modules/.bin/istanbul
FAUCET := node_modules/.bin/faucet
#
# Files
#
RESTDOWN_FLAGS = --brand-dir=deps/restdown-brand-remora
EXTRA_DOC_DEPS = deps/restdown-brand-remora/.git
DOC_FILES = index.md
JS_FILES := $(shell ls *.js) $(shell find lib test -name '*.js') \
bin/ip2num bin/num2ip bin/mac2num bin/num2mac
JSL_CONF_NODE = tools/jsl.node.conf
JSL_FILES_NODE = $(JS_FILES)
JSSTYLE_FILES = $(JS_FILES)
JSSTYLE_FLAGS = -o indent=4,doxygen,unparenthesized-return=0
ESLINT = ./node_modules/.bin/eslint
ESLINT_CONF = tools/eslint.node.conf
ESLINT_FILES = $(JS_FILES)
SMF_MANIFESTS_IN = smf/manifests/napi.xml.in
BASH_FILES := sbin/napid bin/napictl
JSON_FILES := package.json config.json.sample
ifeq ($(shell uname -s),SunOS)
# Allow building on a SmartOS image other than sdc-smartos/1.6.3.
NODE_PREBUILT_IMAGE=fd2cc906-8938-11e3-beab-4359c665ac99
NODE_PREBUILT_VERSION=v0.10.32
NODE_PREBUILT_TAG := zone
endif
include ./tools/mk/Makefile.defs
ifeq ($(shell uname -s),SunOS)
include ./tools/mk/Makefile.node_prebuilt.defs
else
NPM_EXEC :=
NPM = npm
endif
include ./tools/mk/Makefile.smf.defs
TOP := $(shell pwd)
RELEASE_TARBALL := napi-pkg-$(STAMP).tar.bz2
PKGDIR := $(TOP)/$(BUILD)/pkg
INSTDIR := $(PKGDIR)/root/opt/smartdc/napi
#
# Repo-specific targets
#
.PHONY: all
all: $(SMF_MANIFESTS) | $(NPM_EXEC) $(REPO_DEPS) sdc-scripts
$(NPM) install --production
$(ESLINT): | $(NPM_EXEC)
$(NPM) install \
eslint@`json -f package.json devDependencies.eslint` \
eslint-plugin-joyent@`json -f package.json devDependencies.eslint-plugin-joyent`
$(ISTANBUL): | $(NPM_EXEC)
$(NPM) install
$(FAUCET): | $(NPM_EXEC)
$(NPM) install
CLEAN_FILES += ./node_modules/tape
.PHONY: test
test: $(ISTANBUL) $(FAUCET)
$(ISTANBUL) cover --print none test/unit/run.js | $(FAUCET)
#
# Packaging targets
#
.PHONY: release
release: $(RELEASE_TARBALL)
.PHONY: pkg
pkg: all $(SMF_MANIFESTS)
@echo "Building $(RELEASE_TARBALL)"
@rm -rf $(PKGDIR)
@mkdir -p $(PKGDIR)/site
@mkdir -p $(INSTDIR)/smf/manifests
@mkdir -p $(INSTDIR)/test/integration
@mkdir $(INSTDIR)/test/lib
@touch $(PKGDIR)/site/.do-not-delete-me
cp -r $(TOP)/server.js \
$(TOP)/bin \
$(TOP)/lib \
$(TOP)/node_modules \
$(TOP)/package.json \
$(TOP)/sapi_manifests \
$(TOP)/sbin \
$(INSTDIR)/
cp smf/manifests/*.xml $(INSTDIR)/smf/manifests
cp $(TOP)/test/config.json $(INSTDIR)/test/
cp $(TOP)/test/runtest $(INSTDIR)/test/
cp $(TOP)/test/runtests $(INSTDIR)/test/
cp -r $(TOP)/test/integration/* $(INSTDIR)/test/integration/
cp -r $(TOP)/test/lib/* $(INSTDIR)/test/lib/
cp -PR $(NODE_INSTALL) $(INSTDIR)/node
mkdir -p $(PKGDIR)/root/opt/smartdc/boot
cp -R $(TOP)/deps/sdc-scripts/* $(PKGDIR)/root/opt/smartdc/boot/
cp -R $(TOP)/boot/* $(PKGDIR)/root/opt/smartdc/boot/
# Clean up some dev / build bits
find $(INSTDIR) -name "*.pyc" | xargs rm -f
find $(INSTDIR) -name "*.o" | xargs rm -f
find $(INSTDIR) -name c4che | xargs rm -rf # waf build file
find $(INSTDIR) -name .wafpickle* | xargs rm -rf # waf build file
find $(INSTDIR) -name .lock-wscript | xargs rm -rf # waf build file
find $(INSTDIR) -name config.log | xargs rm -rf # waf build file
$(RELEASE_TARBALL): pkg
(cd $(PKGDIR) && $(TAR) -jcf $(TOP)/$(RELEASE_TARBALL) root site)
.PHONY: publish
publish: release
@if [[ -z "$(BITS_DIR)" ]]; then \
echo "error: 'BITS_DIR' must be set for 'publish' target"; \
exit 1; \
fi
mkdir -p $(BITS_DIR)/napi
cp $(TOP)/$(RELEASE_TARBALL) $(BITS_DIR)/napi/$(RELEASE_TARBALL)
.PHONY: check
check:: $(ESLINT)
$(ESLINT) -c $(ESLINT_CONF) $(ESLINT_FILES)
#
# Includes
#
include ./tools/mk/Makefile.deps
ifeq ($(shell uname -s),SunOS)
include ./tools/mk/Makefile.node_prebuilt.targ
endif
include ./tools/mk/Makefile.smf.targ
include ./tools/mk/Makefile.targ
sdc-scripts: deps/sdc-scripts/.git