Skip to content

Commit ff2f1a0

Browse files
authored
Merge pull request #422 from gojimmypi/pr-espressif-component-example-update
Improve cmake duplicate component check
2 parents 704d638 + 6a47b0e commit ff2f1a0

File tree

6 files changed

+113
-36
lines changed

6 files changed

+113
-36
lines changed

IDE/Espressif/ESP-IDF/examples/AWS_IoT_MQTT/CMakeLists.txt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,38 @@ function(CHECK_DUPLICATE_LIBRARIES RESULT_VAR KEYWORD)
6868
"${CMAKE_CURRENT_LIST_DIR}/components/my${KEYWORD}"
6969
"${CMAKE_CURRENT_LIST_DIR}/managed_components/wolfssl__${KEYWORD}"
7070
"${CMAKE_CURRENT_LIST_DIR}/managed_components/gojimmypi__my${KEYWORD}"
71+
# Add any other known user "my[component] here"
7172
"${CMAKE_CURRENT_LIST_DIR}/managed_components/${THIS_USER}__my${KEYWORD}"
7273
"$ENV{IDF_PATH}/components/${KEYWORD}/"
7374
"$ENV{IDF_PATH}/components/esp-${KEYWORD}/"
7475
)
7576

7677
set(EXISTING_COUNT 0)
7778
set(MATCHING_DIRS "") # List to store found directories
79+
set(SEEN_DIRS "") # To store unique normalized existing paths
7880

7981
foreach(DIR ${DIR_LIST})
8082
file(TO_CMAKE_PATH "${DIR}" DIR) # Normalize paths
8183
message(STATUS "Checking for ${KEYWORD} in ${DIR}")
84+
8285
if(EXISTS "${DIR}")
83-
math(EXPR EXISTING_COUNT "${EXISTING_COUNT} + 1")
86+
# Check if DIR already seen
87+
list(FIND SEEN_DIRS "${DIR}" IDX)
88+
89+
if(IDX EQUAL -1)
90+
# Not seen before
91+
list(APPEND SEEN_DIRS "${DIR}")
92+
list(APPEND MATCHING_DIRS "${DIR}")
93+
math(EXPR EXISTING_COUNT "${EXISTING_COUNT} + 1")
94+
message(STATUS "Found: ${DIR}")
95+
else()
96+
message(STATUS "Already counted: ${DIR}")
97+
endif()
98+
8499
list(APPEND MATCHING_DIRS "${DIR}")
85100
message(STATUS "Found: ${DIR}")
86-
endif()
87-
endforeach()
101+
endif() # EXISTS "${DIR}"
102+
endforeach() # DIR ${DIR_LIST}
88103

89104
if(EXISTING_COUNT GREATER_EQUAL 2)
90105
set(${RESULT_VAR} TRUE PARENT_SCOPE)

IDE/Espressif/ESP-IDF/examples/AWS_IoT_MQTT/components/wolfmqtt/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# wolfMQTT for Espressif ESP-IDF
22

3-
[wolfMQTT](https://www.wolfMQTT.com) provides commercial-grade, world-class encryption libraries to secure connections
4-
from tiny embedded devices to the largest cloud and super computing platforms.
3+
[wolfMQTT](https://www.wolfMQTT.com) provides commercial-grade, world-class encryption libraries to secure connections
4+
from tiny embedded devices to the largest cloud and super computing platforms.
55

6-
Makers and students can use these libraries free of charge, as long as they abide by abide by the terms of GPLV2 licensing.
6+
Makers and students can use these libraries free of charge, as long as they abide by abide by the terms of GPLV2 licensing.
77

8-
Commercial customers are invited to contact wolfSSL for licensing options.
9-
Visit [wolfSSL.com/Espressif/](https://www.wolfSSL.com/Espressif/) to learn
8+
Commercial customers are invited to contact wolfSSL for licensing options.
9+
Visit [wolfSSL.com/Espressif/](https://www.wolfSSL.com/Espressif/) to learn
1010
more about Espressif-specific development efforts for wolfSSL, wolfMQTT, wolfSSH, and more.
1111

1212
## Getting Started
1313

1414
The easiest way to get started is by using the Espressif Managed Component Registry
15-
at
15+
at [wolfssl/wolfmqtt](https://components.espressif.com/components/wolfssl/wolfmqtt)
1616

17-
The latest experimental development version can be found at the staging site:
18-
[gojimmypi/mywolfmqtt](https://components-staging.espressif.com/components/gojimmypi/mywolfmqtt/versions/1.0.14-test?language=en).
17+
The latest experimental development version can be found at the staging site:
18+
[gojimmypi/mywolfmqtt](https://components-staging.espressif.com/components/gojimmypi/mywolfmqtt/versions/1.18.0).
1919

2020
```
2121
#!/bin/bash
@@ -25,7 +25,7 @@ The latest experimental development version can be found at the staging site:
2525
# Needed for Staging site:
2626
export IDF_COMPONENT_REGISTRY_URL=https://components-staging.espressif.com
2727
28-
idf.py create-project-from-example "gojimmypi/mywolfmqtt^1.0.14-test:AWS_IoT_MQTT"
28+
idf.py create-project-from-example "gojimmypi/mywolfmqtt^1.18.0:AWS_IoT_MQTT"
2929
3030
cd AWS_IoT_MQTT
3131

IDE/Espressif/ESP-IDF/examples/AWS_IoT_MQTT/main/CMakeLists.txt

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,50 @@ function(CHECK_DUPLICATE_LIBRARIES RESULT_VAR KEYWORD)
6464
"${CMAKE_HOME_DIRECTORY}/components/my${KEYWORD}"
6565
"${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__${KEYWORD}"
6666
"${CMAKE_HOME_DIRECTORY}/managed_components/gojimmypi__my${KEYWORD}"
67+
# Add any other known user "my[component] here"
6768
"${CMAKE_HOME_DIRECTORY}/managed_components/${THIS_USER}__my${KEYWORD}"
6869
"$ENV{IDF_PATH}/components/${KEYWORD}/"
6970
"$ENV{IDF_PATH}/components/esp-${KEYWORD}/"
7071
)
7172

7273
set(EXISTING_COUNT 0)
74+
set(MATCHING_DIRS "") # List to store found directories
75+
set(SEEN_DIRS "") # To store unique normalized existing paths
7376

7477
foreach(DIR ${DIR_LIST})
75-
message(STATUS "Checking ${DIR}")
7678
file(TO_CMAKE_PATH "${DIR}" DIR) # Normalize paths
77-
message(STATUS "Checking ${DIR}")
79+
message(STATUS "Checking for ${KEYWORD} in ${DIR}")
80+
7881
if(EXISTS "${DIR}")
79-
math(EXPR EXISTING_COUNT "${EXISTING_COUNT} + 1")
82+
# Check if DIR already seen
83+
list(FIND SEEN_DIRS "${DIR}" IDX)
84+
85+
if(IDX EQUAL -1)
86+
# Not seen before
87+
list(APPEND SEEN_DIRS "${DIR}")
88+
list(APPEND MATCHING_DIRS "${DIR}")
89+
math(EXPR EXISTING_COUNT "${EXISTING_COUNT} + 1")
90+
message(STATUS "Found: ${DIR}")
91+
else()
92+
message(STATUS "Already counted: ${DIR}")
93+
endif()
94+
95+
list(APPEND MATCHING_DIRS "${DIR}")
8096
message(STATUS "Found: ${DIR}")
81-
endif()
82-
endforeach()
97+
endif() # EXISTS "${DIR}"
98+
endforeach() # DIR ${DIR_LIST}
8399

84100
if(EXISTING_COUNT GREATER_EQUAL 2)
85101
set(${RESULT_VAR} TRUE PARENT_SCOPE)
86-
message(STATUS "WARNING: At least two '${KEYWORD}' component directories exist.")
102+
message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
103+
message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
104+
message(STATUS "WARNING: Found duplicate '${KEYWORD}' in")
105+
foreach(DUP_DIR ${MATCHING_DIRS})
106+
message(STATUS " - ${DUP_DIR}")
107+
endforeach()
108+
message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
109+
message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
110+
message(WARNING "WARNING: More than 1 '${KEYWORD}' component directories exist.")
87111

88112
# Append the warning flag to CMAKE_C_FLAGS and propagate it to the parent scope
89113
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D${KEYWORD}_MULTI_INSTALL_WARNING")

IDE/Espressif/ESP-IDF/examples/wolfmqtt_template/CMakeLists.txt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,38 @@ function(CHECK_DUPLICATE_LIBRARIES RESULT_VAR KEYWORD)
6868
"${CMAKE_CURRENT_LIST_DIR}/components/my${KEYWORD}"
6969
"${CMAKE_CURRENT_LIST_DIR}/managed_components/wolfssl__${KEYWORD}"
7070
"${CMAKE_CURRENT_LIST_DIR}/managed_components/gojimmypi__my${KEYWORD}"
71+
# Add any other known user "my[component] here"
7172
"${CMAKE_CURRENT_LIST_DIR}/managed_components/${THIS_USER}__my${KEYWORD}"
7273
"$ENV{IDF_PATH}/components/${KEYWORD}/"
7374
"$ENV{IDF_PATH}/components/esp-${KEYWORD}/"
7475
)
7576

7677
set(EXISTING_COUNT 0)
7778
set(MATCHING_DIRS "") # List to store found directories
79+
set(SEEN_DIRS "") # To store unique normalized existing paths
7880

7981
foreach(DIR ${DIR_LIST})
8082
file(TO_CMAKE_PATH "${DIR}" DIR) # Normalize paths
8183
message(STATUS "Checking for ${KEYWORD} in ${DIR}")
84+
8285
if(EXISTS "${DIR}")
83-
math(EXPR EXISTING_COUNT "${EXISTING_COUNT} + 1")
86+
# Check if DIR already seen
87+
list(FIND SEEN_DIRS "${DIR}" IDX)
88+
89+
if(IDX EQUAL -1)
90+
# Not seen before
91+
list(APPEND SEEN_DIRS "${DIR}")
92+
list(APPEND MATCHING_DIRS "${DIR}")
93+
math(EXPR EXISTING_COUNT "${EXISTING_COUNT} + 1")
94+
message(STATUS "Found: ${DIR}")
95+
else()
96+
message(STATUS "Already counted: ${DIR}")
97+
endif()
98+
8499
list(APPEND MATCHING_DIRS "${DIR}")
85100
message(STATUS "Found: ${DIR}")
86-
endif()
87-
endforeach()
101+
endif() # EXISTS "${DIR}"
102+
endforeach() # DIR ${DIR_LIST}
88103

89104
if(EXISTING_COUNT GREATER_EQUAL 2)
90105
set(${RESULT_VAR} TRUE PARENT_SCOPE)

IDE/Espressif/ESP-IDF/examples/wolfmqtt_template/components/wolfmqtt/README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
# wolfMQTT for Espressif ESP-IDF
22

3-
[wolfMQTT](https://www.wolfMQTT.com) provides commercial-grade, world-class encryption libraries to secure connections
4-
from tiny embedded devices to the largest cloud and super computing platforms.
3+
[wolfMQTT](https://www.wolfMQTT.com) provides commercial-grade, world-class encryption libraries to secure connections
4+
from tiny embedded devices to the largest cloud and super computing platforms.
55

6-
Makers and students can use these libraries free of charge, as long as they abide by abide by the terms of GPLV2 licensing.
6+
Makers and students can use these libraries free of charge, as long as they abide by abide by the terms of GPLV2 licensing.
77

8-
Commercial customers are invited to contact wolfSSL for licensing options.
9-
Visit [wolfSSL.com/Espressif/](https://www.wolfSSL.com/Espressif/) to learn
8+
Commercial customers are invited to contact wolfSSL for licensing options.
9+
Visit [wolfSSL.com/Espressif/](https://www.wolfSSL.com/Espressif/) to learn
1010
more about Espressif-specific development efforts for wolfSSL, wolfMQTT, wolfSSH, and more.
1111

1212
## Getting Started
1313

1414
The easiest way to get started is by using the Espressif Managed Component Registry
15-
at
15+
at: [wolfssl/wolfmqtt](https://components.espressif.com/components/wolfssl/wolfmqtt)
1616

17-
The latest experimental development version can be found at the staging site:
18-
[gojimmypi/mywolfmqtt](https://components-staging.espressif.com/components/gojimmypi/mywolfmqtt/versions/1.0.14-test?language=en).
17+
The latest experimental development version can be found at the staging site: [gojimmypi/mywolfmqtt](https://components-staging.espressif.com/components/gojimmypi/mywolfmqtt/versions/1.18.0-preview8a?language=en).
1918

2019
```
2120
#!/bin/bash
@@ -25,7 +24,7 @@ The latest experimental development version can be found at the staging site:
2524
# Needed for Staging site:
2625
export IDF_COMPONENT_REGISTRY_URL=https://components-staging.espressif.com
2726
28-
idf.py create-project-from-example "gojimmypi/mywolfmqtt^1.0.14-test:AWS_IoT_MQTT"
27+
idf.py create-project-from-example "gojimmypi/mywolfmqtt^1.18.0-preview8a::AWS_IoT_MQTT"
2928
3029
cd AWS_IoT_MQTT
3130

IDE/Espressif/ESP-IDF/examples/wolfmqtt_template/main/CMakeLists.txt

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,50 @@ function(CHECK_DUPLICATE_LIBRARIES RESULT_VAR KEYWORD)
6464
"${CMAKE_HOME_DIRECTORY}/components/my${KEYWORD}"
6565
"${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__${KEYWORD}"
6666
"${CMAKE_HOME_DIRECTORY}/managed_components/gojimmypi__my${KEYWORD}"
67+
# Add any other known user "my[component] here"
6768
"${CMAKE_HOME_DIRECTORY}/managed_components/${THIS_USER}__my${KEYWORD}"
6869
"$ENV{IDF_PATH}/components/${KEYWORD}/"
6970
"$ENV{IDF_PATH}/components/esp-${KEYWORD}/"
7071
)
7172

7273
set(EXISTING_COUNT 0)
74+
set(MATCHING_DIRS "") # List to store found directories
75+
set(SEEN_DIRS "") # To store unique normalized existing paths
7376

7477
foreach(DIR ${DIR_LIST})
75-
message(STATUS "Checking ${DIR}")
7678
file(TO_CMAKE_PATH "${DIR}" DIR) # Normalize paths
77-
message(STATUS "Checking ${DIR}")
79+
message(STATUS "Checking for ${KEYWORD} in ${DIR}")
80+
7881
if(EXISTS "${DIR}")
79-
math(EXPR EXISTING_COUNT "${EXISTING_COUNT} + 1")
82+
# Check if DIR already seen
83+
list(FIND SEEN_DIRS "${DIR}" IDX)
84+
85+
if(IDX EQUAL -1)
86+
# Not seen before
87+
list(APPEND SEEN_DIRS "${DIR}")
88+
list(APPEND MATCHING_DIRS "${DIR}")
89+
math(EXPR EXISTING_COUNT "${EXISTING_COUNT} + 1")
90+
message(STATUS "Found: ${DIR}")
91+
else()
92+
message(STATUS "Already counted: ${DIR}")
93+
endif()
94+
95+
list(APPEND MATCHING_DIRS "${DIR}")
8096
message(STATUS "Found: ${DIR}")
81-
endif()
82-
endforeach()
97+
endif() # EXISTS "${DIR}"
98+
endforeach() # DIR ${DIR_LIST}
8399

84100
if(EXISTING_COUNT GREATER_EQUAL 2)
85101
set(${RESULT_VAR} TRUE PARENT_SCOPE)
86-
message(STATUS "WARNING: At least two '${KEYWORD}' component directories exist.")
102+
message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
103+
message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
104+
message(STATUS "WARNING: Found duplicate '${KEYWORD}' in")
105+
foreach(DUP_DIR ${MATCHING_DIRS})
106+
message(STATUS " - ${DUP_DIR}")
107+
endforeach()
108+
message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
109+
message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
110+
message(WARNING "WARNING: More than 1 '${KEYWORD}' component directories exist.")
87111

88112
# Append the warning flag to CMAKE_C_FLAGS and propagate it to the parent scope
89113
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D${KEYWORD}_MULTI_INSTALL_WARNING")

0 commit comments

Comments
 (0)