forked from decentraland/kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
225 lines (165 loc) · 8.54 KB
/
Copy pathMakefile
File metadata and controls
225 lines (165 loc) · 8.54 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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# General setup
NODE = node
COMPILER = $(NODE) --max-old-space-size=4096 node_modules/.bin/decentraland-compiler
BUILD_ECS = $(NODE) --max-old-space-size=4096 node_modules/.bin/build-ecs
CONCURRENTLY = node_modules/.bin/concurrently
CWD = $(shell pwd)
# Remove default Makefile rules
.SUFFIXES:
# SDK Files
SOURCE_SUPPORT_TS_FILES := $(wildcard scripts/*.ts)
COMPILED_SUPPORT_JS_FILES := $(subst .ts,.js,$(SOURCE_SUPPORT_TS_FILES))
SCENE_SYSTEM_SOURCES := $(wildcard static/systems/**/*.ts)
SCENE_SYSTEM := static/systems/scene.system.js
DECENTRALAND_LOADER := static/loader/lifecycle/worker.js
GIF_PROCESSOR := static/gif-processor/worker.js
INTERNAL_SCENES := static/systems/decentraland-ui.scene.js
VOICE_CHAT_CODEC_WORKER := static/voice-chat-codec/worker.js static/voice-chat-codec/audioWorkletProcessors.js
EMPTY_SCENES := public/empty-scenes/xmas
scripts/%.js: $(SOURCE_SUPPORT_TS_FILES) scripts/tsconfig.json
@node_modules/.bin/tsc --build scripts/tsconfig.json
static/loader/lifecycle/worker.js: packages/decentraland-loader/**/*.ts
@$(COMPILER) targets/engine/loader.json
static/gif-processor/worker.js: packages/gif-processor/*.ts
@$(COMPILER) targets/engine/gif-processor.json
static/voice-chat-codec/worker.js: packages/voice-chat-codec/*.ts
@$(COMPILER) targets/engine/voice-chat-codec.json
static/default-profile/contents:
@node ./static/default-profile/download_all.js
static/systems/scene.system.js: $(SCENE_SYSTEM_SOURCES) packages/scene-system/scene.system.ts
@$(COMPILER) targets/engine/scene-system.json
static/systems/decentraland-ui.scene.js: $(SCENE_SYSTEM) packages/ui/tsconfig.json packages/ui/decentraland-ui.scene.ts
@$(COMPILER) targets/engine/internal-scenes.json
empty-parcels:
cd public/empty-scenes/common && node generate_all.js
mkdir -p static/loader/empty-scenes || true
rm -rf static/loader/empty-scenes/*
cp $(EMPTY_SCENES)/mappings.json static/loader/empty-scenes/mappings.json
cp -R $(EMPTY_SCENES)/contents static/loader/empty-scenes/contents
build-essentials: $(COMPILED_SUPPORT_JS_FILES) $(SCENE_SYSTEM) $(INTERNAL_SCENES) $(DECENTRALAND_LOADER) $(GIF_PROCESSOR) $(VOICE_CHAT_CODEC_WORKER) empty-parcels generate-mocks ## Build the basic required files for the explorer
# Hellmap scenes
HELLMAP_SOURCE_FILES := $(wildcard public/hell-map/*/game.ts)
HELLMAP_GAMEJS_FILES := $(subst .ts,.js,$(HELLMAP_SOURCE_FILES))
public/hell-map/%/game.js: $(SCENE_SYSTEM) public/hell-map/%/game.ts
@$(COMPILER) targets/scenes/hell-map.json
# Test scenes
TEST_SCENES_SOURCE_FILES := $(wildcard public/test-scenes/*/game.ts)
TEST_SCENES_GAMEJS_FILES := $(subst .ts,.js,$(TEST_SCENES_SOURCE_FILES))
public/test-scenes/%/game.js: $(SCENE_SYSTEM) public/test-scenes/%/game.ts
@$(COMPILER) targets/scenes/test-scenes.json
TEST_ECS_SCENE_SOURCES := $(wildcard public/ecs-scenes/*/game.ts)
TEST_ECS_SCENE_GAMEJS_FILES := $(subst .ts,.js,$(TEST_ECS_SCENE_SOURCES))
watch-only-test-scenes:
@$(COMPILER) targets/scenes/test-scenes.json --watch
# ECS scenes
ECS_LIBRARY := public/ecs-scenes/-200.-30-libraries/node_modules/eth-wrapper/eth-wrapper.js
public/ecs-scenes/-200.-30-libraries/node_modules/eth-wrapper/eth-wrapper.js: public/ecs-scenes/-200.-30-libraries/node_modules/eth-wrapper/eth-wrapper.ts $(BUILD_ECS)
$(BUILD_ECS) -p public/ecs-scenes/-200.-30-libraries/node_modules/eth-wrapper
public/ecs-scenes/%/game.js: $(ECS_LIBRARY) $(SCENE_SYSTEM) public/ecs-scenes/%/game.ts
@node scripts/buildECSprojects.js
# All scenes together
ecs-scenes: $(TEST_ECS_SCENE_GAMEJS_FILES)
$(MAKE) generate-mocks
test-scenes: $(TEST_SCENES_GAMEJS_FILES) $(HELLMAP_GAMEJS_FILES) $(TEST_ECS_SCENE_GAMEJS_FILES) ## Build the test scenes
$(MAKE) generate-mocks
# Entry points
static/%.js: build-essentials packages/entryPoints/%.ts
@$(COMPILER) $(word 2,$^)
# Release
DIST_ENTRYPOINTS := static/editor.js static/index.js
DIST_STATIC_FILES := static/export.html static/preview.html static/default-profile/contents
build-deploy: $(DIST_ENTRYPOINTS) $(DIST_STATIC_FILES) $(SCENE_SYSTEM) $(INTERNAL_SCENES) ## Build all the entrypoints needed for a deployment
build-release: $(DIST_ENTRYPOINTS) $(DIST_STATIC_FILES) $(DIST_PACKAGE_JSON) ## Build all the entrypoints and run the `scripts/prepareDist` script
@node ./scripts/prepareDist.js
# Testing
TEST_SOURCE_FILES := $(wildcard test/**/*.ts)
test/out/index.js: build-essentials $(TEST_SOURCE_FILES)
@$(COMPILER) ./targets/test.json
test: build-essentials test/out/index.js ## Run all the tests
$(MAKE) generate-mocks
@node scripts/runTestServer.js
test-docker: ## Run all the tests using a docker container
@docker run \
-it \
--rm \
--name node \
-v "$(PWD):/usr/src/app" \
-w /usr/src/app \
-e SINGLE_RUN=true \
-p 8080:8080 \
circleci/node:10-browsers \
make test
test-ci: # Run the tests (for use in the continuous integration environment)
@SINGLE_RUN=true NODE_ENV=production $(MAKE) test
@node_modules/.bin/nyc report --temp-directory ./test/tmp --reporter=html --reporter=lcov --reporter=text
generate-images: ## Generate the screenshots to run the visual diff validation tests
@docker run \
-it \
--rm \
--name node \
-v "$(PWD):/usr/src/app" \
-w /usr/src/app \
-e SINGLE_RUN=true \
-e GENERATE_NEW_IMAGES=true \
circleci/node:10-browsers \
make test
public/local-ipfs/mappings:
@rm -rf ./public/local-ipfs
@node ./scripts/createMockJson.js
generate-mocks: ./scripts/createMockJson.js public/local-ipfs/mappings ## Build a fake "IPFS" index of all the test scene mappings
@rm -rf ./public/local-ipfs
@node ./scripts/createMockJson.js
PARCEL_SCENE_JSONS := $(wildcard public/test-scenes/*/scene.json)
ECS_SCENE_JSONS := $(wildcard public/ecs-scenes/*/scene.json)
HELLMAP_SCENE_JSONS := $(wildcard public/hell-map/*/scene.json)
SCENE_JSONS := $(PARCEL_SCENE_JSONS) $(ECS_SCENE_JSONS) $(HELLMAP_SCENE_JSONS)
# CLI
npm-link: build-essentials static/editor.js ## Run `npm link` to develop local scenes against this project
cd static; npm link
watch-builder: build-essentials static/editor.js ## Watch the files required for hacking with the builder
@$(CONCURRENTLY) \
-n "scene-system,internal-scenes,loader,builder,server" \
"$(COMPILER) targets/engine/scene-system.json --watch" \
"$(COMPILER) targets/engine/internal-scenes.json --watch" \
"$(COMPILER) targets/engine/loader.json --watch" \
"$(COMPILER) targets/entryPoints/editor.json --watch" \
"node ./scripts/runTestServer.js --keep-open"
watch-cli: build-essentials ## Watch the files required for building the CLI
@$(CONCURRENTLY) \
-n "scene-system,internal-scenes,loader,kernel,server" \
"$(COMPILER) targets/engine/scene-system.json --watch" \
"$(COMPILER) targets/engine/internal-scenes.json --watch" \
"$(COMPILER) targets/engine/loader.json --watch" \
"$(COMPILER) targets/entryPoints/index.json --watch" \
"node ./scripts/runTestServer.js --keep-open"
# Aesthetics
lint: ## Validate correct formatting and circular dependencies
@node_modules/.bin/madge packages/entryPoints/index.ts --circular --warning
@node_modules/.bin/madge packages --orphans --extensions ts --exclude '.+\.d.ts|.+/dist\/.+'
@node_modules/.bin/eslint . --ext .ts
lint-fix: ## Fix bad formatting on all .ts and .tsx files
@node_modules/.bin/eslint . --ext .ts --fix
# Development
watch: $(SOME_MAPPINGS) build-essentials static/index.js ## Watch the files required for hacking the explorer
@NODE_ENV=development $(CONCURRENTLY) \
-n "scene-system,internal-scenes,loader,basic-scenes,kernel,test,simulator,server" \
"$(COMPILER) targets/engine/scene-system.json --watch" \
"$(COMPILER) targets/engine/internal-scenes.json --watch" \
"$(COMPILER) targets/engine/loader.json --watch" \
"$(COMPILER) targets/scenes/basic-scenes.json --watch" \
"$(COMPILER) targets/entryPoints/index.json --watch" \
"$(COMPILER) targets/test.json --watch" \
"node ./scripts/runPathSimulator.js" \
"node ./scripts/runTestServer.js --keep-open"
fetchSceneContents: scripts/fetchSceneContents.js
@node ./scripts/fetchSceneContents.js
clean: ## Clean all generated files
@$(COMPILER) targets/clean.json
update-renderer: ## Update the renderer
npm install @dcl/unity-renderer@latest
# Makefile
.PHONY: help docs clean watch watch-builder watch-cli lint lint-fix generate-images test-ci test-docker update build-essentials build-deploy build-release update-renderer
.DEFAULT_GOAL := help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
@echo "\nYou probably want to run 'make watch' or 'make test-scenes watch' to build all the test scenes and run the local comms server."