esp-modbus:add make support

This commit is contained in:
aleks
2022-03-18 10:37:40 +01:00
parent 6b5430a18f
commit ed7d923184
13 changed files with 122 additions and 10 deletions

View File

@ -80,6 +80,8 @@ build_idf_latest:
variables:
EXAMPLE_TARGETS: "esp32 esp32s2 esp32s3 esp32c3"
TEST_TARGETS: "esp32 esp32s3"
# GNU Make based build system is not supported starting from IDF v5.0
SKIP_GNU_MAKE_BUILD: 1
push_master_to_github:
stage: deploy

View File

@ -13,12 +13,18 @@ then
set -x # Activate the expand mode if DEBUG is anything but empty.
fi
if [[ -z "${TEST_TARGETS}" ]]
if [[ -z "${EXAMPLE_TARGETS}" || -z "${TEST_TARGETS}" ]]
then
echo "TEST_TARGETS environment variable must be set before calling this script"
echo "EXAMPLE_TARGETS and TEST_TARGETS environment variables must be set before calling this script"
exit 1
fi
if [[ -z "${SKIP_GNU_MAKE_BUILD}" ]]
then
echo "SKIP_GNU_MAKE_BUILD not set, will build with GNU Make based build system as well."
export SKIP_GNU_MAKE_BUILD=0
fi
set -o errexit # Exit if command failed.
set -o pipefail # Exit if pipe failed.
set -o nounset # Exit if variable not set.
@ -41,9 +47,23 @@ function build_for_targets
for IDF_TARGET in ${target_list}
do
export IDF_TARGET
if [[ "${IDF_TARGET}" = "esp32" ]] && [[ "${SKIP_GNU_MAKE_BUILD}" = "0" ]]
then
echo "${STARS}"
echo "Building in $PWD with Make"
# -j option will be set via MAKEFLAGS in .gitlab-ci.yml
# shellcheck disable=SC2015
make defconfig && make || die "Make build in ${PWD} has failed"
rm -rf build
fi
echo "${STARS}"
echo "Building in $PWD with CMake for ${IDF_TARGET}"
idf.py set-target "${IDF_TARGET}"
if [[ ${IDF_TARGET} != "esp32" ]]
then
# IDF 4.0 doesn't support idf.py set-target, and only supports esp32.
idf.py set-target "${IDF_TARGET}"
fi
idf.py build || die "CMake build in ${PWD} has failed for ${IDF_TARGET}"
idf.py fullclean
done
@ -56,7 +76,7 @@ function build_folders
for NAME in ${EXAMPLES}
do
cd "${NAME}"
build_for_targets "${TEST_TARGETS}"
build_for_targets "$2"
cd ..
done
popd
@ -64,9 +84,9 @@ function build_folders
echo "${STARS}"
# Build the tests
build_folders test/serial
build_folders test/serial "${TEST_TARGETS}"
echo "${STARS}"
# Build the tests
build_folders test/tcp
build_folders test/tcp "${TEST_TARGETS}"
echo "${STARS}"

29
component.mk Normal file
View File

@ -0,0 +1,29 @@
INCLUDEDIRS := common/include
PRIV_INCLUDEDIRS := common port modbus modbus/ascii modbus/functions
PRIV_INCLUDEDIRS += modbus/rtu modbus/tcp modbus/include
PRIV_INCLUDEDIRS += serial_slave/port serial_slave/modbus_controller
PRIV_INCLUDEDIRS += serial_master/port serial_master/modbus_controller
PRIV_INCLUDEDIRS += tcp_slave/port tcp_slave/modbus_controller
PRIV_INCLUDEDIRS += tcp_master/port tcp_master/modbus_controller
SRCDIRS := common
SRCDIRS += modbus modbus/ascii modbus/functions modbus/rtu modbus/tcp
SRCDIRS += serial_slave/port serial_slave/modbus_controller
SRCDIRS += serial_master/port serial_master/modbus_controller
SRCDIRS += tcp_slave/port tcp_slave/modbus_controller
SRCDIRS += tcp_master/port tcp_master/modbus_controller
SRCDIRS += port
COMPONENT_PRIV_INCLUDEDIRS = $(addprefix freemodbus/, \
$(PRIV_INCLUDEDIRS) \
)
COMPONENT_SRCDIRS = $(addprefix freemodbus/, \
$(SRCDIRS) \
)
COMPONENT_ADD_INCLUDEDIRS = $(addprefix freemodbus/, \
$(INCLUDEDIRS) \
)

View File

@ -0,0 +1,12 @@
#
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
# project subdirectory.
#
PROJECT_NAME := modbus_master
EXTRA_COMPONENT_DIRS := ../../../
EXTRA_COMPONENT_DIRS += ../../mb_example_common
EXCLUDE_COMPONENTS := examples test freemodbus
include $(IDF_PATH)/make/project.mk

View File

@ -0,0 +1,4 @@
#
# "main" pseudo-component makefile.
#
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)

View File

@ -0,0 +1,12 @@
#
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
# project subdirectory.
#
PROJECT_NAME := modbus_slave
EXTRA_COMPONENT_DIRS := ../../../
EXTRA_COMPONENT_DIRS += ../../mb_example_common
EXCLUDE_COMPONENTS := examples test freemodbus
include $(IDF_PATH)/make/project.mk

View File

@ -0,0 +1,4 @@
#
# "main" pseudo-component makefile.
#
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)

View File

@ -0,0 +1,13 @@
#
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
# project subdirectory.
#
PROJECT_NAME := modbus_tcp_master
EXTRA_COMPONENT_DIRS := ../../../
EXTRA_COMPONENT_DIRS += ../../mb_example_common
EXTRA_COMPONENT_DIRS += $(IDF_PATH)/examples/common_components/protocol_examples_common
EXCLUDE_COMPONENTS := test freemodbus
include $(IDF_PATH)/make/project.mk

View File

@ -0,0 +1,4 @@
#
# "main" pseudo-component makefile.
#
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)

View File

@ -11,8 +11,6 @@ CONFIG_FMB_COMM_MODE_ASCII_EN=n
CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND=2000
CONFIG_FMB_MASTER_DELAY_MS_CONVERT=300
CONFIG_FMB_TIMER_PORT_ENABLED=y
CONFIG_FMB_TIMER_GROUP=0
CONFIG_FMB_TIMER_INDEX=0
CONFIG_FMB_TIMER_ISR_IN_IRAM=y
CONFIG_MB_MDNS_IP_RESOLVER=n
CONFIG_MB_SLAVE_IP_FROM_STDIN=y

View File

@ -0,0 +1,12 @@
#
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
# project subdirectory.
#
PROJECT_NAME := modbus_tcp_slave
EXTRA_COMPONENT_DIRS := ../../../
EXTRA_COMPONENT_DIRS += ../../mb_example_common
EXTRA_COMPONENT_DIRS += $(IDF_PATH)/examples/common_components/protocol_examples_common
EXCLUDE_COMPONENTS := test freemodbus
include $(IDF_PATH)/make/project.mk

View File

@ -0,0 +1,4 @@
#
# "main" pseudo-component makefile.
#
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)

View File

@ -11,8 +11,6 @@ CONFIG_FMB_COMM_MODE_ASCII_EN=n
CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND=1000
CONFIG_FMB_MASTER_DELAY_MS_CONVERT=300
CONFIG_FMB_TIMER_PORT_ENABLED=y
CONFIG_FMB_TIMER_GROUP=0
CONFIG_FMB_TIMER_INDEX=0
CONFIG_FMB_TIMER_ISR_IN_IRAM=y
CONFIG_MB_MDNS_IP_RESOLVER=n
CONFIG_MB_SLAVE_IP_FROM_STDIN=y