-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommons.mk
More file actions
121 lines (90 loc) · 2.79 KB
/
commons.mk
File metadata and controls
121 lines (90 loc) · 2.79 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
define install_node_package
echo "Installing $1 ..."
cd $1 || exit
npm install --link
endef
define _remove_file_if_exist
if [ -f $1 ] ; then \
echo "Remove $1"; \
rm -f $1; \
fi
endef
define _remove_directory_if_exist
if [ -d $1 ] ; then \
echo "Remove directory $1"; \
rm -Rf $1; \
fi
endef
define deepclean_node_package
echo "Deep cleaning $1 ..."
$(call _remove_file_if_exist,$1/package-lock.json)
$(call _remove_directory_if_exist,$1/node_modules)
endef
define _clean_pxt_static_build
echo "Clean static build"
$(call _remove_directory_if_exist,static)
endef
define _clean_pxt_steami
echo "Clean pxt-steami build"
if [ -x "$(PXT)" ]; then
echo "pxt found ! \n Automatic cleanning"
if [ -d pxt-steami/built ]; then
cd pxt-steami || exit
pxt clean
fi
else
echo "pxt not found ! \n Manual cleanning"
$(call _remove_directory_if_exist,pxt-steami/.pxt)
$(call _remove_directory_if_exist,pxt-steami/built)
$(call _remove_directory_if_exist,pxt-steami/projects)
$(call _remove_directory_if_exist,pxt-steami/libs/core/built)
$(call _remove_directory_if_exist,pxt-steami/libs/blocksprj/built)
$(call _remove_directory_if_exist,pxt-steami/libs/tsprj/built)
fi
endef
define _clean_pxt_core
echo "Clean pxt-core build"
$(call _remove_directory_if_exist,pxt/built)
endef
define _clean_pxt_common_packages
echo "Clean pxt-common-packages build"
$(call _remove_directory_if_exist,pxt-common-packages/built)
endef
define _clean_pxt_steami_backend_certificates
echo "Clean pxt-steami-backend certificates ..."
$(call _remove_file_if_exist,pxt-steami-backend/https/fastify.cert)
$(call _remove_file_if_exist,pxt-steami-backend/https/fastify.key)
$(call _remove_file_if_exist,pxt-steami-backend/https/rootCA.pem)
endef
define _clean
$(call _clean_pxt_static_build)
$(call _clean_pxt_steami)
endef
define _clean_all
$(call _clean_pxt_static_build)
$(call _clean_pxt_steami)
$(call _clean_pxt_common_packages)
$(call _clean_pxt_core)
endef
NODE_PACKAGES := pxt pxt-common-packages pxt-steami pxt-steami-backend .
define _deepclean_all_node_packages
$(foreach package,$(NODE_PACKAGES),$(call deepclean_node_package,$(package)))
endef
define _deepclean
$(call _clean_all)
$(call _deepclean_all_node_packages)
endef
define _generate_localcertificates
export CAROOT=$(PWD)/pxt-steami-backend/https
mkcert -install
mkcert -cert-file pxt-steami-backend/https/fastify.cert -key-file pxt-steami-backend/https/fastify.key 'makecode.local' localhost 127.0.0.1 ::1
endef
define _install_cert_for_local_dev
if [ -f /.dockerenv ]; then
echo "This rule work only for the host system"
else
sudo cp pxt-steami-backend/https/rootCA.pem /usr/local/share/ca-certificates/rootCA.crt
sudo update-ca-certificates
sudo sh -c "echo 127.0.0.1 makecode.local>>/etc/hosts"
fi
endef