forked from jkent/frogfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponent.mk
85 lines (71 loc) · 2.77 KB
/
component.mk
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
COMPONENT_ADD_INCLUDEDIRS := include
COMPONENT_PRIV_INCLUDEDIRS := src heatshrink/src heatshrink/include
COMPONENT_SRCDIRS := src heatshrink/src
COMPONENT_OBJS := src/espfs.o src/espfs_vfs.o heatshrink/src/heatshrink_decoder.o
COMPONENT_EXTRA_CLEAN := mkespfsimage/*
IMAGEROOTDIR := $(subst ",,$(CONFIG_ESPFS_IMAGEROOTDIR))
BINEXT :=
ifeq ($(OS),WindowsNT)
BINEXT := .exe
endif
MKESPFSIMAGE := mkespfsimage$(BINEXT)
FILES := $(shell find $(PROJECT_PATH)/$(IMAGEROOTDIR) | sed -E 's/([[:space:]])/\\\1/g')
COMPONENT_EXTRA_CLEAN += $(IMAGEROOTDIR)/*
ifeq ("$(CONFIG_ESPFS_LINK_BINARY)","y")
COMPONENT_OBJS += src/espfs_image.o
endif
ifeq ("$(CONFIG_ESPFS_USE_HEATSHRINK)","y")
USE_HEATSHRINK := "yes"
CFLAGS += -DESPFS_HEATSHRINK
COMPONENT_ADD_INCLUDEDIRS += lib/heatshrink
else
USE_HEATSHRINK := "no"
endif
ifeq ("$(CONFIG_ESPFS_USE_GZIP)","y")
USE_GZIP_COMPRESSION := "yes"
else
USE_GZIP_COMPRESSION := "no"
endif
ifeq ("$(CONFIG_ESPFS_PREPROCESS_FILES)","y")
npm_PACKAGES :=
ifeq ("$(CONFIG_ESPFS_USE_BABEL)","y")
npm_PACKAGES += @babel/core @babel/cli @babel/preset-env babel-preset-minify
endif
ifeq ("$(CONFIG_ESPFS_USE_HTMLMINIFIER)","y")
npm_PACKAGES += html-minifier
endif
ifeq ("$(CONFIG_ESPFS_USE_UGLIFYCSS)","y")
npm_PACKAGES += uglifycss
endif
ifeq ("$(CONFIG_ESPFS_USE_UGLIFYJS)","y")
npm_PACKAGES += uglify-js
endif
node_modules:
npm install --save-dev $(npm_PACKAGES)
else
node_modules:
endif
espfs_image.bin: $(FILES) node_modules mkespfsimage/$(MKESPFSIMAGE)
BUILD_DIR="$(shell pwd)" \
CONFIG_ESPFS_PREPROCESS_FILES=$(CONFIG_ESPFS_PREPROCESS_FILES) \
CONFIG_ESPFS_CSS_MINIFY_UGLIFYCSS=$(CONFIG_ESPFS_CSS_MINIFY_UGLIFYCSS) \
CONFIG_ESPFS_HTML_MINIFY_HTMLMINIFIER=$(CONFIG_ESPFS_HTML_MINIFY_HTMLMINIFIER) \
CONFIG_ESPFS_JS_CONVERT_BABEL=$(CONFIG_ESPFS_JS_CONVERT_BABEL) \
CONFIG_ESPFS_JS_MINIFY_BABEL=$(CONFIG_ESPFS_JS_MINIFY_BABEL) \
CONFIG_ESPFS_JS_MINIFY_UGLIFYJS=$(CONFIG_ESPFS_JS_MINIFY_UGLIFYJS) \
CONFIG_ESPFS_UGLIFYCSS_PATH=$(CONFIG_ESPFS_UGLIFYCSS_PATH) \
CONFIG_ESPFS_HTMLMINIFIER_PATH=$(CONFIG_ESPFS_HTMLMINIFIER_PATH) \
CONFIG_ESPFS_BABEL_PATH=$(CONFIG_ESPFS_BABEL_PATH) \
CONFIG_ESPFS_UGLIFYJS_PATH=$(CONFIG_ESPFS_UGLIFYJS_PATH) \
$(COMPONENT_PATH)/tools/build-image.py "$(PROJECT_PATH)/$(CONFIG_ESPFS_IMAGEROOTDIR)"
src/espfs_image.o: src/espfs_image.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
src/espfs_image.c: espfs_image.bin
mkdir -p src
xxd -i $< $@
sed -i '1s;^;const __attribute__((aligned(4))); ' $@
mkespfsimage/$(MKESPFSIMAGE): $(COMPONENT_PATH)/mkespfsimage
mkdir -p $(COMPONENT_BUILD_DIR)/mkespfsimage
$(MAKE) -C $(COMPONENT_BUILD_DIR)/mkespfsimage -f $(COMPONENT_PATH)/mkespfsimage/Makefile \
USE_HEATSHRINK="$(USE_HEATSHRINK)" USE_GZIP_COMPRESSION="$(USE_GZIP_COMPRESSION)" BUILD_DIR=$(COMPONENT_BUILD_DIR)/mkespfsimage \
CC=$(HOSTCC) clean mkespfsimage