-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
133 lines (111 loc) · 3.38 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
#
# 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 (c) 2019, Joyent, Inc.
# Copyright 2022 MNX Cloud, Inc.
#
#
# Makefile: builds Services API
#
NAME = sapi
#
# Tools
#
NODEUNIT := ./node_modules/.bin/nodeunit
#
# Files
#
DOC_FILES = index.md
RESTDOWN_FLAGS = --brand-dir=deps/restdown-brand-remora
EXTRA_DOC_DEPS += deps/restdown-brand-remora/.git
JS_FILES := $(shell ls *.js) $(shell find lib test tools -name '*.js')
ESLINT_FILES = $(JS_FILES)
JSSTYLE_FILES = $(JS_FILES)
JSSTYLE_FLAGS = -o indent=4,doxygen,unparenthesized-return=0
SMF_MANIFESTS = smf/manifests/sapi.xml
NODE_PREBUILT_VERSION=v6.17.1
ifeq ($(shell uname -s),SunOS)
NODE_PREBUILT_TAG=zone64
NODE_PREBUILT_IMAGE=a7199134-7e94-11ec-be67-db6f482136c2
endif
ENGBLD_USE_BUILDIMAGE = true
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.)
BUILD_PLATFORM = 20210826T002459Z
ifeq ($(shell uname -s),SunOS)
include ./deps/eng/tools/mk/Makefile.node_prebuilt.defs
include ./deps/eng/tools/mk/Makefile.agent_prebuilt.defs
else
NPM := $(shell which npm)
NPM_EXEC=$(NPM)
endif
include ./deps/eng/tools/mk/Makefile.smf.defs
#
# Repo-specific targets
#
.PHONY: all
all: $(SMF_MANIFESTS) | $(NODEUNIT) sdc-scripts
$(NPM) install
$(NODEUNIT): | $(NPM_EXEC)
$(NPM) install
CLEAN_FILES += ./node_modules
#
# Packaging targets
#
SVC_TARBALL := $(NAME)-pkg-$(STAMP).tar.gz
SVC_PKGDIR := $(TOP)/$(BUILD)/service
SVC_INSTDIR := $(SVC_PKGDIR)/root/opt/smartdc/sapi
# our base image is triton-origin-x86_64-21.4.0
BASE_IMAGE_UUID = 502eeef2-8267-489f-b19c-a206906f57ef
BUILDIMAGE_NAME = $(NAME)
BUILDIMAGE_DESC = SDC SAPI
BUILDIMAGE_PKG = $(PWD)/$(SVC_TARBALL)
AGENTS = amon config registrar
.PHONY: release
release: $(SVC_TARBALL)
.PHONY: service
service: all $(SMF_MANIFESTS)
@echo "Building $(SVC_TARBALL)"
@rm -rf $(SVC_PKGDIR)
@mkdir -p $(SVC_PKGDIR)/site
@mkdir -p $(SVC_INSTDIR)/build
@mkdir -p $(SVC_INSTDIR)/smf/manifests
@mkdir -p $(SVC_INSTDIR)/test
@mkdir -p $(SVC_INSTDIR)/tools
@touch $(SVC_PKGDIR)/site/.do-not-delete-me
cp -r $(TOP)/server.js \
$(TOP)/lib \
$(TOP)/node_modules \
$(TOP)/package.json \
$(SVC_INSTDIR)/
cp -r $(TOP)/lib/common \
$(TOP)/lib/server \
$(SVC_INSTDIR)/lib
mkdir -p $(TOP)/build/service/root/opt/smartdc/boot
cp -R $(TOP)/deps/sdc-scripts/* \
$(TOP)/build/service/root/opt/smartdc/boot/
cp -R $(TOP)/boot/* \
$(TOP)/build/service/root/opt/smartdc/boot/
cp smf/manifests/sapi.xml $(SVC_INSTDIR)/smf/manifests
cp -r $(TOP)/sapi_manifests $(SVC_INSTDIR)/
cp -r $(TOP)/test $(SVC_INSTDIR)/
cp -PR $(NODE_INSTALL) $(SVC_INSTDIR)/build/node
$(SVC_TARBALL): service
(cd $(SVC_PKGDIR) && $(TAR) -I pigz -cf $(TOP)/$(SVC_TARBALL) root site)
.PHONY: publish
publish: release
mkdir -p $(ENGBLD_BITS_DIR)/sapi
cp $(TOP)/$(SVC_TARBALL) $(ENGBLD_BITS_DIR)/sapi/$(SVC_TARBALL)
include ./deps/eng/tools/mk/Makefile.deps
ifeq ($(shell uname -s),SunOS)
include ./deps/eng/tools/mk/Makefile.node_prebuilt.targ
include ./deps/eng/tools/mk/Makefile.agent_prebuilt.targ
endif
include ./deps/eng/tools/mk/Makefile.smf.targ
include ./deps/eng/tools/mk/Makefile.targ
sdc-scripts: deps/sdc-scripts/.git