diff --git a/release/build.sh b/release/build.sh index abf0f11..a0f5808 100755 --- a/release/build.sh +++ b/release/build.sh @@ -1,11 +1,22 @@ #!/bin/bash cd "$(dirname "$0")" echo "=== RTU_ALL_AI Build ===" + +# 删除 config 同级目录下的旧 RTU (即项目根目录) +rm -f ../RTU + if [ "$1" = "arm" ]; then echo "ARM cross-compile..." make CROSS=arm clean && make CROSS=arm + cp arm/exe/RTU ../RTU +elif [ "$1" = "debug" ]; then + echo "x86 DEBUG build (-O0 -g)..." + make clean && make DEBUG=1 + cp x86/exe/RTU ../RTU else - echo "x86 local build..." + echo "x86 release build (-O2 -g)..." make clean && make + cp x86/exe/RTU ../RTU fi -echo "=== Done ===" + +echo "=== Done === RTU copied to $(dirname "$0")/../RTU" diff --git a/release/copy_headers.sh b/release/copy_headers.sh index 63555d3..3a21903 100755 --- a/release/copy_headers.sh +++ b/release/copy_headers.sh @@ -108,8 +108,7 @@ copy_proto_module "libicp67" "myIcp67.h" # 系统模块(system/) # ================================================================ copy_sys_header "mySystem.h" -copy_sys_module "libweb_server" "web_server.h" -copy_sys_module "libself_ptl" "self_ptl.h" -copy_sys_module "libcom_router" "com_router.h" +copy_sys_header "app_modules.h" +copy_sys_header "app_msg_queue.h" echo "=== done ===" diff --git a/release/inc/.gitignore b/release/inc/.gitignore index dbdb7c8..20be700 100644 --- a/release/inc/.gitignore +++ b/release/inc/.gitignore @@ -1,6 +1,6 @@ # release/inc/ 目录下仅 myBase.h 纳入版本管理 # 其他头文件由 release/copy_headers.sh 在编译前生成 * -!iec61850_inc +!iec61850_inc/ !myBase.h !.gitignore diff --git a/release/linux.mk b/release/linux.mk index 2c33ebb..658fbb5 100644 --- a/release/linux.mk +++ b/release/linux.mk @@ -31,6 +31,17 @@ REL_INC := -I$(ROOT_DIR)/release/inc # ------ 编译选项 ------ C_FLAGS := $(REL_INC) -Wall -g CXX_FLAGS := $(REL_INC) -std=c++11 -Wall -g + +# ------ Debug 编译 (make DEBUG=1) ------ +ifeq ($(DEBUG), 1) +$(info ===> DEBUG mode: -O0) +C_FLAGS += -O0 -DDEBUG +CXX_FLAGS += -O0 -DDEBUG +else +C_FLAGS += -O2 +CXX_FLAGS += -O2 +endif + ifeq ($(CROSS), arm) C_FLAGS += -DRK356x -mno-outline-atomics CXX_FLAGS += -DRK356x -mno-outline-atomics -fno-threadsafe-statics diff --git a/release/src/protocol/lib60870/makefile b/release/src/protocol/lib60870/makefile index afb96f7..b21b613 100644 --- a/release/src/protocol/lib60870/makefile +++ b/release/src/protocol/lib60870/makefile @@ -10,6 +10,8 @@ OBJS := $(patsubst $(S)/%.c, $(B)/%.o, $(SRCS)) F := $(C_FLAGS) $(I) F += -include cbb_compat.h F += -Wno-implicit-function-declaration +F += -Wno-unused-variable +F += -Wno-unused-function .PHONY: all all: diff --git a/release/src/protocol/libicp67/makefile b/release/src/protocol/libicp67/makefile index 5456f5e..2f36d69 100644 --- a/release/src/protocol/libicp67/makefile +++ b/release/src/protocol/libicp67/makefile @@ -7,7 +7,7 @@ I := -I$(SRC_ROOT_DIR)/$(L)/libicp67/inc -I$(SRC_ROOT_DIR)/public/liblog/inc B := $(CURDIR)/$(M)/obj SRCS := $(wildcard $(S)/*.c) OBJS := $(patsubst $(S)/%.c, $(B)/%.o, $(SRCS)) -F := $(C_FLAGS) $(I) +F := $(C_FLAGS) $(I) -Wno-unused-variable .PHONY: all all: diff --git a/release/src/system/RTU/makefile b/release/src/system/RTU/makefile index 0c93b92..5781644 100644 --- a/release/src/system/RTU/makefile +++ b/release/src/system/RTU/makefile @@ -16,9 +16,13 @@ INC_PATH := -I$(ROOT)/release/inc \ -I$(ROOT)/src/protocol/libmongoose/inc LIBS := -L$(ROOT)/release/$(BUILD_TYPE)/lib \ - -lweb_server -lmodbus_m -lself_ptl -lcom_router -liec -licp67 -lmodbus -l60870 \ - -lmongoose -ldatacenter -lxml -lcmd -ltask \ + -Wl,--whole-archive \ + -lweb_server -lmodbus_m -lself_ptl -lcom_router -liec -lplc -licp67 \ + -ldatacenter -lxml -lcmd -ltask \ -llog -lfunc -lmy_xxhash -lcJSON -lmd5 -lcomm \ + -Wl,--no-whole-archive \ + -lmodbus -l60870 \ + -lmongoose \ -lpthread -lstdc++ O := $(ROOT)/release/$(BUILD_TYPE)/exe/RTU diff --git a/release/src/system/libiec/makefile b/release/src/system/libiec/makefile index 64dc103..432b990 100644 --- a/release/src/system/libiec/makefile +++ b/release/src/system/libiec/makefile @@ -5,6 +5,7 @@ M := libiec O := $(LIB_REL)/$(M).a S := $(SRC_ROOT_DIR)/$(L)/libiec/src I := -I$(SRC_ROOT_DIR)/$(L)/libiec/inc \ + -I$(SRC_ROOT_DIR)/$(L)/inc \ -I$(SRC_ROOT_DIR)/protocol/lib60870/inc \ -I$(SRC_ROOT_DIR)/public/libdatacenter/inc \ -I$(SRC_ROOT_DIR)/public/liblog/inc \ diff --git a/release/src/system/libplc/makefile b/release/src/system/libplc/makefile index 58d83cb..0fd02fb 100644 --- a/release/src/system/libplc/makefile +++ b/release/src/system/libplc/makefile @@ -11,7 +11,7 @@ I := -I$(SRC_ROOT_DIR)/$(L)/libplc/inc -I$(SRC_ROOT_DIR)/$(L)/inc \ B := $(CURDIR)/$(M)/obj SRCS := $(wildcard $(S)/*.cpp) $(wildcard $(S)/*.c) OBJS := $(patsubst $(S)/%.cpp, $(B)/%.o, $(patsubst $(S)/%.c, $(B)/%.o, $(SRCS))) -F := $(CXX_FLAGS) $(I) +F := $(CXX_FLAGS) $(I) -Wno-unused-variable .PHONY: all all: diff --git a/release/src/system/libself_ptl/makefile b/release/src/system/libself_ptl/makefile index 882af8b..a6b2aad 100644 --- a/release/src/system/libself_ptl/makefile +++ b/release/src/system/libself_ptl/makefile @@ -10,7 +10,7 @@ I := -I$(SRC_ROOT_DIR)/$(L)/libself_ptl/inc -I$(SRC_ROOT_DIR)/$(L)/inc \ B := $(CURDIR)/$(M)/obj SRCS := $(wildcard $(S)/*.cpp) $(wildcard $(S)/*.c) OBJS := $(patsubst $(S)/%.cpp, $(B)/%.o, $(patsubst $(S)/%.c, $(B)/%.o, $(SRCS))) -F := $(CXX_FLAGS) $(I) +F := $(CXX_FLAGS) $(I) -Wno-unused-but-set-variable .PHONY: all all: