-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
154 lines (134 loc) · 4.79 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
#
# 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 2019 Joyent, Inc.
# Copyright 2023 MNX Cloud, Inc.
#
#
# Makefile: basic Makefile for template API service
#
# This Makefile is a template for new repos. It contains only repo-specific
# logic and uses included makefiles to supply common targets (javascriptlint,
# jsstyle, restdown, etc.), which are used by other repos as well. You may well
# need to rewrite most of this file, but you shouldn't need to touch the
# included makefiles.
#
# If you find yourself adding support for new targets that could be useful for
# other projects too, you should add these to the original versions of the
# included Makefiles (in eng.git) so that other teams can use them too.
#
#
# Files
#
CLEAN_FILES += ./node_modules
DOC_FILES = index.md
JS_FILES := $(shell find lib test bin -name '*.js') \
bin/cmon-agent bin/collector-collect bin/collector-dump
JSSTYLE_FILES = $(JS_FILES)
JSSTYLE_FLAGS = -o indent=4,doxygen,unparenthesized-return=0
# Re-enable when updated to Node v6
# ESLINT_FILES = $(JS_FILES)
# The next line breaks the build due to a variable that eng.git sed expander
# doesn't know about (@@ENABLED@@)
# SMF_MANIFESTS_IN = smf/manifests/cmon-agent.xml.in
# Should be the same version as the platform's /usr/node/bin/node.
NODE_PREBUILT_VERSION = v6.17.1
NODE_PREBUILT_TAG = gz
ifeq ($(shell uname -s),SunOS)
NODE_PREBUILT_IMAGE = 5417ab20-3156-11ea-8b19-2b66f5e7a439
endif
# Included definitions
ENGBLD_REQUIRE := $(shell git submodule update --init deps/eng)
include ./deps/eng/tools/mk/Makefile.defs
TOP ?= $(error Unable to access eng.git submodule Makefiles.)
ifeq ($(shell uname -s),SunOS)
include ./deps/eng/tools/mk/Makefile.node_prebuilt.defs
else
NPM=npm
NODE=node
NPM_EXEC=$(shell which npm)
NODE_EXEC=$(shell which node)
endif
include ./deps/eng/tools/mk/Makefile.smf.defs
NAME := cmon-agent
RELEASE_TARBALL := $(NAME)-$(STAMP).tgz
RELEASE_MANIFEST := $(NAME)-$(STAMP).manifest
RELSTAGEDIR := /tmp/$(NAME)-$(STAMP)
TAPE = $(TOP)/node_modules/tape/bin/tape
#
# Due to the unfortunate nature of npm, the Node Package Manager, there appears
# to be no way to assemble our dependencies without running the lifecycle
# scripts. These lifecycle scripts should not be run except in the context of
# an agent installation or uninstallation, so we provide a magic environment
# varible to disable them here.
#
NPM_ENV = SDC_AGENT_SKIP_LIFECYCLE=yes
RUN_NPM_INSTALL = $(NPM_ENV) $(NPM) install
CLEAN_FILES += $(NAME)-*.tgz $(NAME)-*.manifest
#
# Repo-specific targets
#
.PHONY: all
all: $(SMF_MANIFESTS) | $(NPM_EXEC) $(REPO_DEPS)
$(RUN_NPM_INSTALL)
$(TAPE): | $(NPM_EXEC)
$(RUN_NPM_INSTALL)
.PHONY: test
test:
./test/runtests
.PHONY: test-coal
test-coal:
ssh $(COAL) /opt/smartdc/agents/lib/node_modules/cmon-agent/test/runtests
.PHONY: release
release: all deps $(SMF_MANIFESTS)
@echo "Building $(RELEASE_TARBALL)"
@echo "gonna do something with $(RELSTAGEDIR)/$(NAME)"
@echo "also gonna do something with $(TOP)"
@mkdir -p $(RELSTAGEDIR)/$(NAME)
cd $(TOP) && $(RUN_NPM_INSTALL)
cp -r \
$(TOP)/bin \
$(TOP)/build/node \
$(TOP)/lib \
$(TOP)/node_modules \
$(TOP)/npm \
$(TOP)/smf \
$(TOP)/test \
$(RELSTAGEDIR)/$(NAME)
ln -s node_modules/kstat/build $(RELSTAGEDIR)/$(NAME)
json -f $(TOP)/package.json -e 'this.version += "-$(STAMP)"' \
> $(RELSTAGEDIR)/$(NAME)/package.json
# Trim node
rm -rf \
$(RELSTAGEDIR)/$(NAME)/node/bin/npm \
$(RELSTAGEDIR)/$(NAME)/node/lib/node_modules \
$(RELSTAGEDIR)/$(NAME)/node/include \
$(RELSTAGEDIR)/$(NAME)/node/share
uuid -v4 >$(RELSTAGEDIR)/cmon-agent/image_uuid
cd $(RELSTAGEDIR) && $(TAR) -I pigz -cf $(TOP)/$(RELEASE_TARBALL) *
cat $(TOP)/manifest.tmpl | sed \
-e "s/UUID/$$(cat $(RELSTAGEDIR)/cmon-agent/image_uuid)/" \
-e "s/NAME/$$(json name < $(TOP)/package.json)/" \
-e "s/VERSION/$$(json version < $(TOP)/package.json)/" \
-e "s/DESCRIPTION/$$(json description < $(TOP)/package.json)/" \
-e "s/BUILDSTAMP/$(STAMP)/" \
-e "s/SIZE/$$(stat --printf="%s" $(TOP)/$(RELEASE_TARBALL))/" \
-e "s/SHA/$$(openssl sha1 $(TOP)/$(RELEASE_TARBALL) \
| cut -d ' ' -f2)/" \
> $(TOP)/$(RELEASE_MANIFEST)
@rm -rf $(RELSTAGEDIR)
.PHONY: publish
publish: release
mkdir -p $(ENGBLD_BITS_DIR)/$(NAME)
cp $(TOP)/$(RELEASE_TARBALL) $(ENGBLD_BITS_DIR)/$(NAME)/$(RELEASE_TARBALL)
cp $(TOP)/$(RELEASE_MANIFEST) $(ENGBLD_BITS_DIR)/$(NAME)/$(RELEASE_MANIFEST)
include ./deps/eng/tools/mk/Makefile.deps
ifeq ($(shell uname -s),SunOS)
include ./deps/eng/tools/mk/Makefile.node_prebuilt.targ
endif
include ./deps/eng/tools/mk/Makefile.smf.targ
include ./deps/eng/tools/mk/Makefile.targ