forked from chmorgan/libesphttpd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
component.mk
59 lines (46 loc) · 2.44 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
#
# Component Makefile (for esp-idf)
#
# This Makefile should, at the very least, just include $(SDK_PATH)/make/component.mk. By default,
# this will take the sources in this directory, compile them and link them into
# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
# please read the SDK documents if you need to do this.
#
ifdef CONFIG_ESPHTTPD_ENABLED
COMPONENT_SRCDIRS := core espfs util
COMPONENT_ADD_INCLUDEDIRS := core espfs util include
COMPONENT_ADD_LDFLAGS := -lwebpages-espfs -llibesphttpd
COMPONENT_EXTRA_CLEAN := mkespfsimage/*
HTMLDIR := $(subst ",,$(CONFIG_ESPHTTPD_HTMLDIR))
JS_MINIFY_TOOL ?= uglifyjs
CFLAGS += -DFREERTOS -DESPFS_HEATSHRINK
USE_HEATSHRINK := "yes"
COMPONENT_ADD_INCLUDEDIRS += lib/heatshrink
USE_GZIP_COMPRESSION := "yes"
liblibesphttpd.a: libwebpages-espfs.a
# mkespfsimage will compress html, css, svg and js files with gzip by default if enabled
# override with -g cmdline parameter
webpages.espfs: $(PROJECT_PATH)/$(HTMLDIR) mkespfsimage/mkespfsimage
ifeq ("$(CONFIG_ESPHTTPD_USEUGLIFYJS)","y")
echo "Using uglifyjs"
rm -rf html_compressed;
cp -r $(PROJECT_PATH)/$(HTMLDIR) html_compressed;
echo "Compressing javascript assets with uglifyjs"
for file in `find html_compressed -type f -name "*.js"`; do $(JS_MINIFY_TOOL) $$file -c -m -o $$file; done
awk "BEGIN {printf \" compression ratio was: %.2f%%\\n\", (`du -b -s html_compressed/ | sed 's/\([0-9]*\).*/\1/'`/`du -b -s $(PROJECT_PATH)/$(HTMLDIR) | sed 's/\([0-9]*\).*/\1/'`)*100}"
cd html_compressed; find . | $(COMPONENT_BUILD_DIR)/mkespfsimage/mkespfsimage > $(COMPONENT_BUILD_DIR)/webpages.espfs; cd ..;
else
echo "Not using uglifyjs"
cd $(PROJECT_PATH)/$(HTMLDIR) && find . | $(COMPONENT_BUILD_DIR)/mkespfsimage/mkespfsimage > $(COMPONENT_BUILD_DIR)/webpages.espfs
endif
libwebpages-espfs.a: webpages.espfs
$(OBJCOPY) -I binary -O elf32-xtensa-le -B xtensa --rename-section .data=.rodata \
webpages.espfs webpages.espfs.o.tmp
$(CC) -nostdlib -Wl,-r webpages.espfs.o.tmp -o webpages.espfs.o -Wl,-T $(COMPONENT_PATH)/webpages.espfs.esp32.ld
$(AR) cru $@ webpages.espfs.o
mkespfsimage/mkespfsimage: $(COMPONENT_PATH)/espfs/mkespfsimage
mkdir -p $(COMPONENT_BUILD_DIR)/mkespfsimage
$(MAKE) -C $(COMPONENT_BUILD_DIR)/mkespfsimage -f $(COMPONENT_PATH)/espfs/mkespfsimage/Makefile \
USE_HEATSHRINK="$(USE_HEATSHRINK)" USE_GZIP_COMPRESSION="$(USE_GZIP_COMPRESSION)" BUILD_DIR=$(COMPONENT_BUILD_DIR)/mkespfsimage \
CC=$(HOSTCC)
endif