Skip to content

Commit b20e39e

Browse files
committed
more
1 parent 0150ba5 commit b20e39e

File tree

14 files changed

+43
-100
lines changed

14 files changed

+43
-100
lines changed

custom.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ LDLIBS := -lpthread -lm -lnsl
3434
CPPFLAGS ?= $(INCLUDES) -MMD -MP -std=gnu99 -DWINDOWS -DLINUX
3535

3636

37-
CFLAGS ?= -std=gnu99 -W -Wall -Wextra -g
38-
LDFLAGS ?=
37+
CFLAGS ?= -std=gnu99 -W -Wall -Wextra -g -Os -ffunction-sections -fdata-sections -fmerge-constants
38+
LDFLAGS ?= -Wl,--gc-sections
3939

4040
# Append ASAN flags if ASAN=1
4141
ifeq ($(ASAN),1)

platforms/BL602/bouffalo.mk

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,20 @@
11
# Component Makefile
22
#
33
## These include paths would be exported to project level
4-
COMPONENT_ADD_INCLUDEDIRS += src/ src/httpserver/ src/httpclient/ src/cmnds/ src/logging/ src/hal/bl602/ src/mqtt/ src/cJSON src/base64 src/driver src/devicegroups src/bitmessage src/littlefs src/libraries/obktime/ include/
5-
6-
ifndef OBK_ENABLE_BERRY_BUILD
7-
ifeq ($(OBK_VARIANT),1)
8-
OBK_ENABLE_BERRY_BUILD := 1
9-
else
10-
OBK_ENABLE_BERRY_BUILD := 0
11-
endif
12-
endif
13-
14-
ifeq ($(OBK_ENABLE_BERRY_BUILD),1)
15-
COMPONENT_ADD_INCLUDEDIRS += libraries/berry/src
16-
endif
4+
COMPONENT_ADD_INCLUDEDIRS += src/ src/httpserver/ src/httpclient/ src/cmnds/ src/logging/ src/hal/bl602/ src/mqtt/ src/cJSON src/base64 src/driver src/devicegroups src/bitmessage src/littlefs libraries/berry/src src/libraries/obktime/ include/
175

186
## not be exported to project level
197
COMPONENT_PRIV_INCLUDEDIRS :=
208

21-
CPPFLAGS += -DOBK_VARIANT=${OBK_VARIANT} -Wno-undef
22-
CXXFLAGS += -Wno-delete-non-virtual-dtor -Wno-error=format
9+
CPPFLAGS += -DOBK_VARIANT=${OBK_VARIANT} -Wno-undef -Os -ffunction-sections -fdata-sections -fmerge-constants
10+
CXXFLAGS += -Wno-delete-non-virtual-dtor -Wno-error=format -Os -ffunction-sections -fdata-sections -fmerge-constants
2311

2412
## This component's src
2513
COMPONENT_SRCS :=
2614

2715
COMPONENT_OBJS := $(patsubst %.c,%.o, $(COMPONENT_SRCS))
2816
COMPONENT_OBJS := $(patsubst %.S,%.o, $(COMPONENT_OBJS))
2917

30-
COMPONENT_SRCDIRS := src/ src/jsmn src/httpserver src/httpclient src/cmnds src/logging src/hal/bl602 src/mqtt src/i2c src/cJSON src/base64 src/driver src/devicegroups src/bitmessage src/littlefs src/hal/generic src/libraries/obktime src/libraries/IRremoteESP8266/src
31-
32-
ifeq ($(OBK_ENABLE_BERRY_BUILD),1)
33-
COMPONENT_SRCDIRS += libraries/berry/src src/berry src/berry/modules
34-
endif
18+
COMPONENT_SRCDIRS := src/ src/jsmn src/httpserver src/httpclient src/cmnds src/logging src/hal/bl602 src/mqtt src/i2c src/cJSON src/base64 src/driver src/devicegroups src/bitmessage src/littlefs src/hal/generic libraries/berry/src src/berry src/berry/modules src/libraries/obktime src/libraries/IRremoteESP8266/src
3519

36-
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
20+
COMPONENT_ADD_LDFLAGS = -Wl,--gc-sections -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive

platforms/ESP-IDF/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ include_directories("$ENV{IDF_PATH}/../../include")
2222
project(OpenBeken)
2323
idf_build_set_property(COMPILE_OPTIONS "-Wno-error=format-truncation" APPEND)
2424
idf_build_set_property(COMPILE_OPTIONS "-Wno-error=incompatible-pointer-types" APPEND)
25+
idf_build_set_property(COMPILE_OPTIONS "-ffunction-sections" APPEND)
26+
idf_build_set_property(COMPILE_OPTIONS "-fdata-sections" APPEND)
27+
idf_build_set_property(COMPILE_OPTIONS "-fmerge-constants" APPEND)
28+
target_link_libraries(${project_elf} "-Wl,--gc-sections")

platforms/ESP8266/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ idf_build_set_property(COMPILE_OPTIONS "-Wno-error=incompatible-pointer-types" A
1616
idf_build_set_property(COMPILE_OPTIONS "-Wno-error=pointer-sign" APPEND)
1717
idf_build_set_property(COMPILE_OPTIONS "-Wno-error=main" APPEND)
1818
idf_build_set_property(COMPILE_OPTIONS "-ffile-prefix-map=$ENV{IDF_PATH}/=" APPEND)
19-
target_link_libraries(${project_elf} "-Wl,--print-memory-usage -u _printf_float -u _scanf_float")
19+
idf_build_set_property(COMPILE_OPTIONS "-ffunction-sections" APPEND)
20+
idf_build_set_property(COMPILE_OPTIONS "-fdata-sections" APPEND)
21+
idf_build_set_property(COMPILE_OPTIONS "-fmerge-constants" APPEND)
22+
target_link_libraries(${project_elf} "-Wl,--print-memory-usage -Wl,--gc-sections -u _printf_float")

platforms/LN8825/CMakeLists.txt

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,6 @@ include_directories(${BERRY_SRCPATH})
2626
include_directories(app/include)
2727
include(app/libraries/berry.cmake)
2828

29-
if(DEFINED ENV{OBK_ENABLE_BERRY_BUILD})
30-
set(OBK_ENABLE_BERRY_BUILD "$ENV{OBK_ENABLE_BERRY_BUILD}")
31-
else()
32-
set(OBK_ENABLE_BERRY_BUILD "0")
33-
endif()
34-
35-
set(OBK_BERRY_SRC)
36-
if(OBK_ENABLE_BERRY_BUILD)
37-
list(APPEND OBK_BERRY_SRC ${BERRY_SRC_C})
38-
endif()
39-
4029
set(PROJ_ALL_SRC
4130
${OBK_SRCS}hal/ln882h/hal_adc_ln882h.c
4231
${OBK_SRCS}hal/ln882h/hal_flashConfig_ln882h.c
@@ -49,7 +38,7 @@ set(PROJ_ALL_SRC
4938
${OBK_SRCS}hal/ln882h/hal_ota_ln882h.c
5039
${OBKM_SRC}
5140
${OBKM_SRC_CXX}
52-
${OBK_BERRY_SRC}
41+
${BERRY_SRC_C}
5342
${PRO_DIR}/main.c
5443
${PRO_DIR}/bsp/serial_hw.c
5544
${PRO_DIR}/bsp/drv_adc_measure.c
@@ -66,6 +55,8 @@ set(pro_executable_target ${TARGET_ELF_NAME})
6655

6756
add_executable(${pro_executable_target} ${PROJ_ALL_SRC})
6857

58+
target_compile_options(${pro_executable_target} PRIVATE ${OBK_SIZE_COMPILE_OPTIONS})
59+
6960
set(COMP_DHCPD_SUPPORT ON PARENT_SCOPE)
7061
set(COMP_LWIP_SUPPORT ON PARENT_SCOPE)
7162

@@ -90,6 +81,7 @@ target_link_libraries(${pro_executable_target}
9081
PRIVATE
9182
-T${LINKER_SCRIPT}
9283
${EXTRA_LINK_FLAGS}
84+
${OBK_SIZE_LINK_OPTIONS}
9385
)
9486

9587
target_include_directories(${pro_executable_target}

platforms/LN882H/CMakeLists.txt

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,10 @@ include_directories(${BERRY_SRCPATH})
1414
include_directories(app/platforms/LN882H)
1515
include(app/libraries/berry.cmake)
1616

17-
if(DEFINED ENV{OBK_ENABLE_BERRY_BUILD})
18-
set(OBK_ENABLE_BERRY_BUILD "$ENV{OBK_ENABLE_BERRY_BUILD}")
19-
else()
20-
set(OBK_ENABLE_BERRY_BUILD "0")
21-
endif()
22-
23-
set(OBK_BERRY_SRC)
24-
if(OBK_ENABLE_BERRY_BUILD)
25-
list(APPEND OBK_BERRY_SRC ${BERRY_SRC_C})
26-
endif()
27-
2817
set(PROJ_ALL_SRC
2918
${OBKM_SRC_CXX}
3019
${OBKM_SRC}
31-
${OBK_BERRY_SRC}
20+
${BERRY_SRC_C}
3221
${OBK_SRCS}hal/ln882h/hal_adc_ln882h.c
3322
${OBK_SRCS}hal/ln882h/hal_flashConfig_ln882h.c
3423
${OBK_SRCS}hal/ln882h/hal_flashVars_ln882h.c
@@ -110,6 +99,8 @@ set(TARGET_ELF_NAME ${USER_PROJECT})
11099
set(pro_executable_target ${TARGET_ELF_NAME}.elf)
111100
add_executable(${pro_executable_target} ${PROJ_ALL_SRC})
112101

102+
target_compile_options(${pro_executable_target} PRIVATE ${OBK_SIZE_COMPILE_OPTIONS})
103+
113104
target_link_libraries(${pro_executable_target}
114105
PUBLIC
115106
ln::dhcpd
@@ -121,6 +112,7 @@ target_link_libraries(${pro_executable_target}
121112
PRIVATE
122113
-T${LINKER_SCRIPT}
123114
${EXTRA_LINK_FLAGS}
115+
${OBK_SIZE_LINK_OPTIONS}
124116
)
125117

126118
target_link_directories(${pro_executable_target}

platforms/RDA5981/OpenBeken.mk

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ OBK_DIR = ../../..
33
CC_FLAGS += -DPLATFORM_RDA5981=1 -DMBED_HEAP_STATS_ENABLED -DWRAP_PRINTF
44
CPPC_FLAGS += -DPLATFORM_RDA5981=1 -DMBED_HEAP_STATS_ENABLED -DWRAP_PRINTF
55

6-
ifndef OBK_ENABLE_BERRY_BUILD
7-
OBK_ENABLE_BERRY_BUILD := 0
8-
endif
9-
106
INCLUDE_PATHS += -I$(OBK_DIR)/libraries/easyflash/inc
117

128
SRC_C += $(OBK_DIR)/src/hal/rda5981/hal_flashConfig_rda5981.c
@@ -36,18 +32,15 @@ SRC_C += $(OBK_DIR)/libraries/easyflash/src/ef_iap.c
3632
SRC_C += $(OBK_DIR)/libraries/easyflash/src/ef_log.c
3733
SRC_C += $(OBK_DIR)/libraries/easyflash/src/ef_utils.c
3834

39-
INCLUDE_PATHS += -I$(OBK_DIR)/include
40-
ifeq ($(OBK_ENABLE_BERRY_BUILD),1)
41-
INCLUDE_PATHS += -I$(OBK_DIR)/libraries/berry/src
35+
INCLUDE_PATHS += -I$(OBK_DIR)/include -I$(OBK_DIR)/libraries/berry/src
4236
BERRY_MODULEPATH = $(OBK_DIR)/src/berry/modules
4337
BERRY_SRCPATH = $(OBK_DIR)/libraries/berry/src
4438

4539
include $(OBK_DIR)/libraries/berry.mk
4640

4741
SRC_C += $(BERRY_SRC_C)
48-
endif
4942

5043
OBJECTS += $(SRC_C:.c=.o)
5144
OBJECTS += $(SRC_CPP:.cpp=.o)
5245

53-
LD_FLAGS += -Wl,--wrap,vsnprintf -Wl,--wrap,snprintf -Wl,--wrap,sprintf -Wl,--wrap,vsprintf
46+
LD_FLAGS += -Wl,--gc-sections -Wl,--wrap,vsnprintf -Wl,--wrap,snprintf -Wl,--wrap,sprintf -Wl,--wrap,vsprintf

platforms/RTL8710A/OpenBeken.mk

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ OBK_DIR = ../../../../..
33
CFLAGS += -DPLATFORM_RTL8710A -DPLATFORM_REALTEK
44
CXXFLAGS += -DPLATFORM_RTL8710A -DPLATFORM_REALTEK
55

6-
ifndef OBK_ENABLE_BERRY_BUILD
7-
OBK_ENABLE_BERRY_BUILD := 0
8-
endif
9-
106
INCLUDES += -I$(OBK_DIR)/libraries/easyflash/inc
117

128
SRC_C += $(OBK_DIR)/platforms/RTL8710A/main.c
@@ -29,6 +25,7 @@ include $(OBK_DIR)/platforms/obk_main.mk
2925
SRC_C += $(OBKM_SRC)
3026
SRC_CPP += $(OBKM_SRC_CXX)
3127
CFLAGS += $(OBK_CFLAGS)
28+
CXXFLAGS += $(OBK_CFLAGS)
3229

3330
SRC_C += $(OBK_DIR)/libraries/easyflash/ports/ef_port.c
3431
SRC_C += $(OBK_DIR)/libraries/easyflash/src/easyflash.c
@@ -41,11 +38,9 @@ SRC_C += $(OBK_DIR)/libraries/easyflash/src/ef_log.c
4138
SRC_C += $(OBK_DIR)/libraries/easyflash/src/ef_utils.c
4239

4340
INCLUDES += -I$(OBK_DIR)/include
44-
ifeq ($(OBK_ENABLE_BERRY_BUILD),1)
4541
BERRY_MODULEPATH = $(OBK_DIR)/src/berry/modules
4642
BERRY_SRCPATH = $(OBK_DIR)/libraries/berry/src
4743

4844
include $(OBK_DIR)/libraries/berry.mk
4945

5046
SRC_C += $(BERRY_SRC_C)
51-
endif

platforms/RTL8710B/OpenBeken.mk

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ OBK_DIR = ../../../../..
33
CFLAGS += -DPLATFORM_RTL8710B -DPLATFORM_REALTEK
44
CXXFLAGS += -DPLATFORM_RTL8710B -DPLATFORM_REALTEK
55

6-
ifndef OBK_ENABLE_BERRY_BUILD
7-
OBK_ENABLE_BERRY_BUILD := 0
8-
endif
9-
106
INCLUDES += -I$(OBK_DIR)/libraries/easyflash/inc
117

128
#gcc wrap
@@ -33,6 +29,7 @@ include $(OBK_DIR)/platforms/obk_main.mk
3329
SRC_C += $(OBKM_SRC)
3430
SRC_CPP += $(OBKM_SRC_CXX)
3531
CFLAGS += $(OBK_CFLAGS)
32+
CXXFLAGS += $(OBK_CFLAGS)
3633

3734
SRC_C += $(OBK_DIR)/libraries/easyflash/ports/ef_port.c
3835
SRC_C += $(OBK_DIR)/libraries/easyflash/src/easyflash.c
@@ -45,11 +42,9 @@ SRC_C += $(OBK_DIR)/libraries/easyflash/src/ef_log.c
4542
SRC_C += $(OBK_DIR)/libraries/easyflash/src/ef_utils.c
4643

4744
INCLUDES += -I$(OBK_DIR)/include
48-
ifeq ($(OBK_ENABLE_BERRY_BUILD),1)
4945
BERRY_MODULEPATH = $(OBK_DIR)/src/berry/modules
5046
BERRY_SRCPATH = $(OBK_DIR)/libraries/berry/src
5147

5248
include $(OBK_DIR)/libraries/berry.mk
5349

5450
SRC_C += $(BERRY_SRC_C)
55-
endif

platforms/RTL8720E/CMakeLists.txt

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,6 @@ set(BERRY_MODULEPATH "${OBK_SRCS}berry/modules")
1010
include(../obk_main.cmake)
1111
include(../../libraries/berry.cmake)
1212

13-
if(DEFINED ENV{OBK_ENABLE_BERRY_BUILD})
14-
set(OBK_ENABLE_BERRY_BUILD "$ENV{OBK_ENABLE_BERRY_BUILD}")
15-
else()
16-
set(OBK_ENABLE_BERRY_BUILD "0")
17-
endif()
18-
19-
set(OBK_BERRY_SRC)
20-
if(OBK_ENABLE_BERRY_BUILD)
21-
list(APPEND OBK_BERRY_SRC ${BERRY_SRC_C})
22-
endif()
23-
2413
ameba_list_append(public_definitions LWIP_NETIF_HOSTNAME=1 TCP_MSL=1000)
2514
ameba_global_define(${public_definitions})
2615

@@ -45,6 +34,7 @@ target_compile_options(
4534
-Wno-implicit-fallthrough
4635
-Wno-missing-field-initializers
4736
-Wno-error
37+
${OBK_SIZE_COMPILE_OPTIONS}
4838
"$<$<COMPILE_LANGUAGE:C>:-Wno-strict-prototypes>"
4939
)
5040

@@ -71,6 +61,6 @@ target_sources(
7161

7262
${OBKM_SRC}
7363
${OBKM_SRC_CXX}
74-
${OBK_BERRY_SRC}
64+
${BERRY_SRC_C}
7565
../../libraries/mqtt_patched.c
7666
)

0 commit comments

Comments
 (0)