Skip to content

Commit

Permalink
Merge pull request #909 from llange/mongoose-dependencies-version
Browse files Browse the repository at this point in the history
mongoose: identify dependencies, and generate a version header
  • Loading branch information
llange committed Jun 6, 2023
2 parents 1de99a1 + a972723 commit cdccd61
Show file tree
Hide file tree
Showing 22 changed files with 120 additions and 14 deletions.
2 changes: 1 addition & 1 deletion vehicle/OVMS.V3/components/can/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# requirements can't depend on config
idf_component_register(SRCS "src/can.cpp" "src/canformat.cpp" "src/canformat_canswitch.cpp" "src/canformat_crtd.cpp" "src/canformat_gvret.cpp" "src/canformat_lawicel.cpp" "src/canformat_panda.cpp" "src/canformat_pcap.cpp" "src/canformat_raw.cpp" "src/canlog.cpp" "src/canlog_monitor.cpp" "src/canlog_tcpclient.cpp" "src/canlog_tcpserver.cpp" "src/canlog_udpclient.cpp" "src/canlog_udpserver.cpp" "src/canlog_vfs.cpp" "src/canplay.cpp" "src/canplay_vfs.cpp" "src/canutils.cpp"
INCLUDE_DIRS src
PRIV_REQUIRES "main" "pcp" "ovms_buffer"
PRIV_REQUIRES "main" "pcp" "ovms_buffer" "mongoose"
WHOLE_ARCHIVE)
3 changes: 2 additions & 1 deletion vehicle/OVMS.V3/components/can/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# please read the ESP-IDF documents if you need to do this.
#

COMPONENT_DEPENDS := mongoose
COMPONENT_ADD_INCLUDEDIRS:=src
COMPONENT_SRCDIRS:=src
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
2 changes: 1 addition & 1 deletion vehicle/OVMS.V3/components/console_ssh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ endif ()
# requirements can't depend on config
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS src
PRIV_REQUIRES "freertos" "main" "wolfssl"
PRIV_REQUIRES "freertos" "main" "wolfssl" "mongoose"
WHOLE_ARCHIVE)

if (CONFIG_OVMS_SC_GPL_MONGOOSE AND CONFIG_OVMS_SC_GPL_WOLF AND CONFIG_OVMS_COMP_SSH)
Expand Down
1 change: 1 addition & 0 deletions vehicle/OVMS.V3/components/console_ssh/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
ifdef CONFIG_OVMS_SC_GPL_MONGOOSE
ifdef CONFIG_OVMS_SC_GPL_WOLF
ifdef CONFIG_OVMS_COMP_SSH
COMPONENT_DEPENDS := mongoose
COMPONENT_ADD_INCLUDEDIRS:=src
COMPONENT_EXTRA_INCLUDES := ${IDF_PATH}/components/freertos/include/freertos
COMPONENT_SRCDIRS:=src
Expand Down
2 changes: 1 addition & 1 deletion vehicle/OVMS.V3/components/console_telnet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ endif ()
# requirements can't depend on config
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS src
PRIV_REQUIRES "main"
PRIV_REQUIRES "main" "mongoose"
WHOLE_ARCHIVE)

1 change: 1 addition & 0 deletions vehicle/OVMS.V3/components/console_telnet/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

ifdef CONFIG_OVMS_SC_GPL_MONGOOSE
ifdef CONFIG_OVMS_COMP_TELNET
COMPONENT_DEPENDS := mongoose
COMPONENT_ADD_INCLUDEDIRS:=src
COMPONENT_SRCDIRS:=src
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
Expand Down
48 changes: 44 additions & 4 deletions vehicle/OVMS.V3/components/mongoose/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,64 @@ if (CONFIG_OVMS_SC_GPL_MONGOOSE)
list(APPEND srcs "mongoose/mongoose.c")
list(APPEND include_dirs "include" "mongoose")

set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${srcs}" "mongoose/mongoose.h")

if (CONFIG_MG_SSL_IF_WOLFSSL)
list(APPEND priv_includedirs "../wolfssl" "../wolfssl/wolfssl")
list(APPEND priv_includedirs "../wolfssl/wolfssl" "../wolfssl/wolfssl/wolfssl")
endif ()

set(MG_VERSION_COMPONENTS)
execute_process(
COMMAND cat "${COMPONENT_DIR}/mongoose/mongoose.h"
COMMAND grep "#define MG_VERSION"
COMMAND cut "-d" " " "-f3"
COMMAND sed -e s/\"//g
OUTPUT_VARIABLE MG_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# include(CMakePrintHelpers)
# cmake_print_variables(MG_VERSION)
message(STATUS "Compiled Mongoose version: ${MG_VERSION}" )

string(REPLACE "." ";" MG_VERSION_COMPONENTS ${MG_VERSION})
# cmake_print_variables(MG_VERSION_COMPONENTS)

set(MG_VERSION_MAJOR 0)
set(MG_VERSION_MINOR 0)
set(MG_VERSION_PATCH 0)
list(LENGTH MG_VERSION_COMPONENTS MG_VERSION_COMPONENTS_LENGTH)
# cmake_print_variables(MG_VERSION_COMPONENTS_LENGTH)

if (MG_VERSION_COMPONENTS_LENGTH GREATER "0")
list(POP_FRONT MG_VERSION_COMPONENTS MG_VERSION_MAJOR)
if (MG_VERSION_COMPONENTS_LENGTH GREATER "1")
list(POP_FRONT MG_VERSION_COMPONENTS MG_VERSION_MINOR)
if (MG_VERSION_COMPONENTS_LENGTH GREATER "2")
list(POP_FRONT MG_VERSION_COMPONENTS MG_VERSION_PATCH)
endif ()
endif ()
endif ()
# cmake_print_variables(MG_VERSION_MAJOR MG_VERSION_MINOR MG_VERSION_PATCH)

configure_file("${COMPONENT_DIR}/mg_version.h.in" "${COMPONENT_DIR}/include/mg_version.h" @ONLY)

endif ()

# requirements can't depend on config
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${include_dirs}
REQUIRES "lwip" "mbedtls"
REQUIRES "lwip" "mbedtls" "wolfssl"
PRIV_REQUIRES "main" "freertos"
PRIV_INCLUDE_DIRS ${priv_includedirs}
# WHOLE_ARCHIVE
)

if (CONFIG_OVMS_SC_GPL_MONGOOSE)

component_compile_options("-mlongcalls")
component_compile_definitions("MG_LOCALS" "MG_ENABLE_MBEDTLS=1")
component_compile_definitions("MG_ARCH=MG_ARCH_FREERTOS" "MG_ENABLE_LINES=1" "MG_ENABLE_LWIP=1" "MG_ENABLE_IPV6=1" "MG_ENABLE_ASSERT=1")

if (CONFIG_MG_SSL_IF_MBEDTLS)
component_compile_definitions("MG_ENABLE_MBEDTLS=1")
endif ()

endif ()
24 changes: 24 additions & 0 deletions vehicle/OVMS.V3/components/mongoose/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,35 @@
#

ifdef CONFIG_OVMS_SC_GPL_MONGOOSE
COMPONENT_EXTRA_CLEAN := $(COMPONENT_PATH)/include/mg_version.h

mongoose/mongoose.o: $(COMPONENT_PATH)/include/mg_version.h

$(COMPONENT_PATH)/include/mg_version.h: SHELL := /bin/bash
$(COMPONENT_PATH)/include/mg_version.h: $(COMPONENT_PATH)/mongoose/mongoose.h
{ \
MG_VERSION=$$(cat "$(COMPONENT_PATH)/mongoose/mongoose.h" | \
grep "#define MG_VERSION" | \
cut "-d" " " "-f3" | \
sed -e s/\"//g); \
echo "Compiled Mongoose version: $${MG_VERSION}"; \
a=( $${MG_VERSION//./ } ); \
cat "$(COMPONENT_PATH)/mg_version.h.in" | \
sed -e "s/@MG_VERSION_MAJOR@/$${a[0]}/" \
-e "s/@MG_VERSION_MINOR@/$${a[1]}/" \
-e "s/@MG_VERSION_PATCH@/0/" \
> "$(COMPONENT_PATH)/include/mg_version.h"; \
}
COMPONENT_ADD_INCLUDEDIRS := include mongoose
CFLAGS += -DMG_ENABLE_LINES # Only for Mongoose >= 7.0
CFLAGS += -DMG_ENABLE_LWIP # Only for Mongoose >= 7.0
ifdef CONFIG_MG_SSL_IF_WOLFSSL
COMPONENT_PRIV_INCLUDEDIRS := ../wolfssl ../wolfssl/wolfssl
COMPONENT_EXTRA_INCLUDES := ${IDF_PATH}/components/freertos/include/freertos
endif
ifdef CONFIG_MG_SSL_IF_MBEDTLS
CFLAGS += -DMG_ENABLE_MBEDTLS=1 # Only for Mongoose >= 7.0
endif
COMPONENT_SRCDIRS := mongoose
COMPONENT_SUBMODULES := mongoose
#COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
Expand Down
1 change: 1 addition & 0 deletions vehicle/OVMS.V3/components/mongoose/include/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mg_version.h
24 changes: 24 additions & 0 deletions vehicle/OVMS.V3/components/mongoose/mg_version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* GENERATED FILE */

/** Major version number (X.x.x) */
#define MG_VERSION_MAJOR @MG_VERSION_MAJOR@
/** Minor version number (x.X.x) */
#define MG_VERSION_MINOR @MG_VERSION_MINOR@
/** Patch version number (x.x.X) */
#define MG_VERSION_PATCH @MG_VERSION_PATCH@

/**
* Macro to convert MG version number into an integer
*
* To be used in comparisons, such as MG_VERSION_NUMBER >= MG_VERSION_VAL(7, 0, 0)
*/
#define MG_VERSION_VAL(major, minor, patch) ((major << 16) | (minor << 8) | (patch))

/**
* Current MG version, as an integer
*
* To be used in comparisons, such as MG_VERSION_NUMBER >= MG_VERSION_VAL(4, 0, 0)
*/
#define MG_VERSION_NUMBER MG_VERSION_VAL(MG_VERSION_MAJOR, \
MG_VERSION_MINOR, \
MG_VERSION_PATCH)
8 changes: 8 additions & 0 deletions vehicle/OVMS.V3/components/mongoose/project_include.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This is the equivalent to `Makefile.projbuild` before CMAKE build system

if (CONFIG_OVMS_SC_GPL_MONGOOSE)

idf_build_set_property(COMPILE_OPTIONS "-mlongcalls" APPEND)
idf_build_set_property(COMPILE_OPTIONS "-DMG_LOCALS" APPEND)

endif ()
2 changes: 1 addition & 1 deletion vehicle/OVMS.V3/components/ovms_netlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ endif ()
# requirements can't depend on config
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${include_dirs}
PRIV_REQUIRES "main"
PRIV_REQUIRES "main" "mongoose"
WHOLE_ARCHIVE)
1 change: 1 addition & 0 deletions vehicle/OVMS.V3/components/ovms_netlib/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

ifdef CONFIG_OVMS_SC_GPL_MONGOOSE

COMPONENT_DEPENDS := mongoose
COMPONENT_ADD_INCLUDEDIRS:=src
COMPONENT_SRCDIRS:=src
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
Expand Down
2 changes: 1 addition & 1 deletion vehicle/OVMS.V3/components/ovms_script/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ endif ()
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${includes}
REQUIRES "ovms_tls"
PRIV_REQUIRES "main" "duktape"
PRIV_REQUIRES "main" "duktape" "mongoose"
EMBED_FILES ${embed}
WHOLE_ARCHIVE)
1 change: 1 addition & 0 deletions vehicle/OVMS.V3/components/ovms_script/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


ifdef CONFIG_OVMS_SC_JAVASCRIPT_DUKTAPE
COMPONENT_DEPENDS := mongoose
COMPONENT_SRCDIRS := src srcduk
COMPONENT_ADD_INCLUDEDIRS := src srcduk umm
# To get line numbers of internal modules in stack traces, embed the uncompressed sources:
Expand Down
2 changes: 1 addition & 1 deletion vehicle/OVMS.V3/components/ovms_server_v2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ endif ()
# requirements can't depend on config
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${include_dirs}
PRIV_REQUIRES "main"
PRIV_REQUIRES "main" "mongoose"
WHOLE_ARCHIVE)
1 change: 1 addition & 0 deletions vehicle/OVMS.V3/components/ovms_server_v2/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

ifdef CONFIG_OVMS_COMP_SERVER
ifdef CONFIG_OVMS_COMP_SERVER_V2
COMPONENT_DEPENDS := mongoose
COMPONENT_SRCDIRS := src
COMPONENT_ADD_INCLUDEDIRS := src
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
Expand Down
2 changes: 1 addition & 1 deletion vehicle/OVMS.V3/components/ovms_server_v3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ endif ()
# requirements can't depend on config
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${include_dirs}
PRIV_REQUIRES "main"
PRIV_REQUIRES "main" "mongoose"
WHOLE_ARCHIVE)
1 change: 1 addition & 0 deletions vehicle/OVMS.V3/components/ovms_server_v3/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

ifdef CONFIG_OVMS_COMP_SERVER
ifdef CONFIG_OVMS_COMP_SERVER_V3
COMPONENT_DEPENDS := mongoose
COMPONENT_SRCDIRS := src
COMPONENT_ADD_INCLUDEDIRS := src
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
Expand Down
4 changes: 2 additions & 2 deletions vehicle/OVMS.V3/components/ovms_webserver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ endif ()
# requirements can't depend on config
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${include_dirs}
REQUIRES "pushover" "mongoose"
PRIV_REQUIRES "main" "ovms_plugins"
REQUIRES "pushover" "mongoose" "ovms_plugins"
PRIV_REQUIRES "main"
EMBED_FILES ${embedded_files}
WHOLE_ARCHIVE)

Expand Down
1 change: 1 addition & 0 deletions vehicle/OVMS.V3/components/ovms_webserver/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
ifdef CONFIG_OVMS_SC_GPL_MONGOOSE
ifdef CONFIG_OVMS_COMP_WEBSERVER

COMPONENT_DEPENDS := mongoose
COMPONENT_ADD_INCLUDEDIRS:=src
COMPONENT_SRCDIRS:=src assets
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
Expand Down
1 change: 1 addition & 0 deletions vehicle/OVMS.V3/main/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)

COMPONENT_DEPENDS := mongoose
COMPONENT_ADD_INCLUDEDIRS := .
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive -T main/ovms_boot.ld

Expand Down

0 comments on commit cdccd61

Please sign in to comment.