1+ .DEFAULT_GOAL = build
2+
3+ default : build
4+ all : setup build
5+
16.ONESHELL : # Applies to every targets in the file!
27
38export PATH := $(shell pwd) /node_modules/.bin:$(PATH )
@@ -7,6 +12,34 @@ export PXT_RUNTIME_DEV := 1
712export PXT_ASMDEBUG := 1
813export PXT_NODOCKER := 1
914
15+ PXT_LIBRARIES := pxt pxt-common-packages pxt-steami pxt-steami-backend
16+ PXT_COMMANDS := add buildcss buildjres buildsimjs buildsprites buildtarget bump checkdocs checkpkgcfg ci console deploy extract help init install npminstallnative run serve staticpkg tag testghpkgs update usedblocks
17+ # Arguments par défaut pour chaque commande PXT
18+ PXT_ADD_ARGS ?=
19+ PXT_BUILDCSS_ARGS ?=
20+ PXT_BUILDJRES_ARGS ?=
21+ PXT_BUILDSIMJS_ARGS ?=
22+ PXT_BUILDSPRITES_ARGS ?=
23+ PXT_BUILDTARGET_ARGS ?= --localbuild --force
24+ PXT_BUMP_ARGS ?=
25+ PXT_CHECKDOCS_ARGS ?=
26+ PXT_CHECKPKGCFG_ARGS ?=
27+ PXT_CI_ARGS ?=
28+ PXT_CONSOLE_ARGS ?=
29+ PXT_DEPLOY_ARGS ?=
30+ PXT_EXTRACT_ARGS ?=
31+ PXT_HELP_ARGS ?=
32+ PXT_INIT_ARGS ?=
33+ PXT_INSTALL_ARGS ?=
34+ PXT_NPMINSTALLNATIVE_ARGS ?=
35+ PXT_RUN_ARGS ?=
36+ PXT_SERVE_ARGS ?= --localbuild --rebundle --noauth --no-browser --no-serial -h '0.0.0.0'
37+ PXT_STATICPKG_ARGS ?= -o ../static/ --localbuild
38+ PXT_TAG_ARGS ?=
39+ PXT_TESTGHPKGS_ARGS ?=
40+ PXT_UPDATE_ARGS ?=
41+ PXT_USEDBLOCKS_ARGS ?=
42+
1043PXT ="/workspaces/makecode-steami/node_modules/.bin/pxt"
1144
1245define install_node_package
@@ -117,76 +150,58 @@ define _install_cert_for_local_dev
117150 fi
118151endef
119152
120- .PHONY : all
121- all : setup
122-
123- .PHONY : setup
124- setup : | prepare _deepclean install-makecode-steami install-pxt install-pxt-common-packages install-pxt-steami install-pxt-steami-backend
125-
126153.PHONY : prepare
127154prepare :
128155 @echo " Install Git hooks"
129156 git config core.hooksPath .hooks
130157
131- .PHONY : install-makecode-steami
132- install-makecode-steami : node_modules/.package-lock.json package-lock.json
133-
134- .PHONY : install-pxt
135- install-pxt : pxt/node_modules/.package-lock.json pxt/package-lock.json
136-
137- .PHONY : install-pxt-common-packages
138- install-pxt-common-packages : pxt-common-packages/node_modules/.package-lock.json pxt-common-packages/package-lock.json
158+ .PHONY : setup
159+ setup : prepare clean $(PXT ) install-makecode-steami $(addprefix install-,$(PXT_LIBRARIES ) )
139160
140- .PHONY : install-pxt-steami
141- install-pxt-steami : pxt-steami/node_modules/.package-lock.json pxt-steami/package-lock.json
161+ .PHONY : clean
162+ clean : ;@ $( call _clean)
142163
143- .PHONY : install-pxt-steami-backend
144- install-pxt-steami-backend : pxt-steami-backend/node_modules/.package-lock.json pxt-steami-backend/package-lock.json
164+ .PHONY : deepclean
165+ deepclean : ;@ $( call _deepclean)
145166
146- $(PXT ) : pxt/built/target.json pxt-common-packages/node_modules/.package-lock.json node_modules/.package-lock.json
167+ # Création des cibles de build pour chaque package pxt
168+ define _install_node_package_template
169+ .PHONY: install-$1
170+ install-$1: $2/node_modules/.package-lock.json $2/package-lock.json
147171
148- node_modules/.package-lock.json package-lock.json : package.json
149- @$(call install_node_package,$(<D ) )
172+ $2/ node_modules/.package-lock.json $2/ package-lock.json: $2/ package.json
173+ @$$ (call install_node_package,$ $(<D ) )
150174
151- pxt/node_modules/.package-lock.json pxt/package-lock.json : pxt/package.json
152- @$(call install_node_package,$(<D ) )
175+ endef
153176
154- pxt-common-packages/node_modules/.package-lock.json pxt-common-packages/package-lock.json : pxt-common-packages/package.json pxt/built/ target.json
155- @ $( call install_node_package, $( <D ) )
177+ # Création de la target install-makecode-steami
178+ $(eval $(call _install_node_package_template,makecode-steami,. ))
156179
157- pxt-steami/node_modules/.package-lock.json pxt-steami/package-lock.json : pxt-steami/package.json pxt/built/target.json
158- @ $( call install_node_package ,$(<D ) )
180+ # Création des targets install- pxt-XXX
181+ $(foreach target,$(PXT_LIBRARIES),$(eval $( call _install_node_package_template ,$(target),$(target)) ))
159182
160- pxt-steami-backend/node_modules/.package-lock.json pxt-steami-backend/package-lock.json : pxt-steami-backend/package.json
161- @$(call install_node_package,$(<D ) )
183+ $(PXT ) : pxt/built/target.json pxt-common-packages/node_modules/.package-lock.json node_modules/.package-lock.json
162184
163185pxt/built/target.json : pxt/node_modules/.package-lock.json
164186 cd pxt || exit
165187 npm run build
166188
167- .PHONY : clean
168- clean : ;@$(call _clean)
169-
170- .PHONY : _deepclean
171- _deepclean : ;@$(call _deepclean)
189+ define _call_pxt_command_template
190+ .PHONY: $1
191+ $1: $3
192+ @$$(call pxt_command,$2 $$(PXT_$(shell echo $2 | tr '[:lower:]' '[:upper:]') _ARGS ) )
172193
173- .PHONY : build
174- build : $(PXT )
175- @$(call pxt_command,buildtarget)
194+ endef
176195
177- .PHONY : ci
178- ci : $(PXT )
179- @$(call pxt_command,ci)
196+ $(eval $(call _call_pxt_command_template,build,buildtarget,$(PXT)))
180197
181- .PHONY : serve
182- serve : $(PXT )
183- @$(call pxt_command,serve --no-browser --no-serial -h '0.0.0.0')
198+ $(foreach command,$(PXT_COMMANDS),$(eval $(call _call_pxt_command_template,$(command),$(command),$(PXT))))
184199
185200.PHONY : package
186201package : static/target.json
187202
188203static/target.json : $(PXT )
189- @$(call pxt_command,staticpkg -o ../static/ )
204+ @$(call pxt_command,staticpkg $( PXT_STATICPKG_ARGS ) )
190205
191206.PHONY : staticserve
192207staticserve : static/target.json pxt-steami-backend/https/fastify.cert pxt-steami-backend/https/fastify.key pxt-steami-backend/node_modules/.package-lock.json
@@ -210,4 +225,10 @@ install_cert_for_local_dev : pxt-steami-backend/https/rootCA.pem
210225printvars :
211226 @$(foreach V,$(sort $(.VARIABLES ) ) , \
212227 $(if $(filter-out environment% default automatic, \
213- $(origin $V ) ),$(warning $V=$($V ) ($(value $V) ) )))
228+ $(origin $V ) ),$(warning $V=$($V ) ($(value $V) ) )))
229+
230+ # Affiche toutes les cibles disponibles dans le Makefile
231+ .PHONY : list
232+ list :
233+ @LC_ALL=C $(MAKE ) -pRrq -f $(firstword $(MAKEFILE_LIST ) ) : 2> /dev/null | awk -v RS= -F: ' /(^|\n)# Files(\n|$$)/,/(^|\n)# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | grep -E -v -e ' ^[^[:alnum:]]' -e ' ^$@$$'
234+
0 commit comments