Skip to content

Commit ebab66d

Browse files
committed
v1.0.2: improved way to get include files
1 parent 6579e33 commit ebab66d

File tree

4 files changed

+99
-83
lines changed

4 files changed

+99
-83
lines changed

Develop.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@ export PATH=$PATH:/mingw32/bin to add python and cmake to path.
3636

3737
### To do
3838

39+
* Important! add Directives in build.cmake (-DARDUINO), to get prerpocessor the definitions that use esp32 and arduino libraries for esp32 core!, you can get that in esp32/platform.txt. It was needded to use ArduinoJSON library!.
40+
3941
* get_include_files.py think in better way to don't looking for files in examples test ect... subidrectories
4042

41-
* test if internal libraries are include well in sktech cmakelist if it is ok, remove Internal libraries from arduino cmakeList in arduinoCore
43+
* test if internal libraries are include well in sktech cmakelist if it is ok, remove Internal libraries from arduino cmakeList in arduinoCore -- ok!
4244

43-
* think if looking for in external libraries if <> is not matchet in internal libraries.
45+
* think if looking for in external libraries if <> is not matchet in internal librarie, bad idea, it looking for all system headers in external libraries!, bad use. -- finished
4446

4547
### Done
48+
49+
---
50+
4651
# V1.0.1
4752

4853
### To do

components/arduino/CMakeLists.txt

+50-50
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ set(LIBRARY_SRCS
5454
#${LIBRARIES_DIR}/BluetoothSerial/src/BTAddress.cpp
5555
#${LIBRARIES_DIR}/BluetoothSerial/src/BTAdvertisedDeviceSet.cpp
5656
#${LIBRARIES_DIR}/BluetoothSerial/src/BTScanResultsSet.cpp
57-
${LIBRARIES_DIR}/DNSServer/src/DNSServer.cpp
57+
#${LIBRARIES_DIR}/DNSServer/src/DNSServer.cpp
5858
#${LIBRARIES_DIR}/EEPROM/src/EEPROM.cpp
59-
${LIBRARIES_DIR}/ESPmDNS/src/ESPmDNS.cpp
59+
#${LIBRARIES_DIR}/ESPmDNS/src/ESPmDNS.cpp
6060
#${LIBRARIES_DIR}/Ethernet/src/ETH.cpp
6161
#${LIBRARIES_DIR}/FFat/src/FFat.cpp
6262
${LIBRARIES_DIR}/FS/src/FS.cpp
6363
${LIBRARIES_DIR}/FS/src/vfs_api.cpp
64-
${LIBRARIES_DIR}/HTTPClient/src/HTTPClient.cpp
64+
#${LIBRARIES_DIR}/HTTPClient/src/HTTPClient.cpp
6565
#${LIBRARIES_DIR}/HTTPUpdate/src/HTTPUpdate.cpp
6666
#${LIBRARIES_DIR}/LittleFS/src/LittleFS.cpp
6767
#${LIBRARIES_DIR}/Insights/src/Insights.cpp
@@ -93,46 +93,46 @@ set(LIBRARY_SRCS
9393
#${LIBRARIES_DIR}/USB/src/USBHIDSystemControl.cpp
9494
#${LIBRARIES_DIR}/USB/src/USBHIDVendor.cpp
9595
#${LIBRARIES_DIR}/USB/src/USBVendor.cpp
96-
${LIBRARIES_DIR}/WebServer/src/WebServer.cpp
97-
${LIBRARIES_DIR}/WebServer/src/Parsing.cpp
98-
${LIBRARIES_DIR}/WebServer/src/detail/mimetable.cpp
99-
${LIBRARIES_DIR}/WiFiClientSecure/src/ssl_client.cpp
96+
#${LIBRARIES_DIR}/WebServer/src/WebServer.cpp
97+
#${LIBRARIES_DIR}/WebServer/src/Parsing.cpp
98+
#${LIBRARIES_DIR}/WebServer/src/detail/mimetable.cpp
99+
#${LIBRARIES_DIR}/WiFiClientSecure/src/ssl_client.cpp
100100
#${LIBRARIES_DIR}/WiFiClientSecure/src/esp_crt_bundle.c
101-
${LIBRARIES_DIR}/WiFiClientSecure/src/WiFiClientSecure.cpp
102-
${LIBRARIES_DIR}/WiFi/src/WiFiAP.cpp
103-
${LIBRARIES_DIR}/WiFi/src/WiFiClient.cpp
104-
${LIBRARIES_DIR}/WiFi/src/WiFi.cpp
105-
${LIBRARIES_DIR}/WiFi/src/WiFiGeneric.cpp
106-
${LIBRARIES_DIR}/WiFi/src/WiFiMulti.cpp
107-
${LIBRARIES_DIR}/WiFi/src/WiFiScan.cpp
108-
${LIBRARIES_DIR}/WiFi/src/WiFiServer.cpp
109-
${LIBRARIES_DIR}/WiFi/src/WiFiSTA.cpp
110-
${LIBRARIES_DIR}/WiFi/src/WiFiUdp.cpp
111-
${LIBRARIES_DIR}/WiFiProv/src/WiFiProv.cpp
101+
#${LIBRARIES_DIR}/WiFiClientSecure/src/WiFiClientSecure.cpp
102+
#${LIBRARIES_DIR}/WiFi/src/WiFiAP.cpp
103+
#${LIBRARIES_DIR}/WiFi/src/WiFiClient.cpp
104+
#${LIBRARIES_DIR}/WiFi/src/WiFi.cpp
105+
#${LIBRARIES_DIR}/WiFi/src/WiFiGeneric.cpp
106+
#${LIBRARIES_DIR}/WiFi/src/WiFiMulti.cpp
107+
#${LIBRARIES_DIR}/WiFi/src/WiFiScan.cpp
108+
#${LIBRARIES_DIR}/WiFi/src/WiFiServer.cpp
109+
#${LIBRARIES_DIR}/WiFi/src/WiFiSTA.cpp
110+
#${LIBRARIES_DIR}/WiFi/src/WiFiUdp.cpp
111+
#${LIBRARIES_DIR}/WiFiProv/src/WiFiProv.cpp
112112
#${LIBRARIES_DIR}/Wire/src/Wire.cpp
113-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttBroker/MqttBroker.cpp
114-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttClient/MqttClient.cpp
115-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttMessages/SubscribeMqttMessage.cpp
116-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttMessages/AckConnectMqttMessage.cpp
117-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttMessages/MqttMessage.cpp
118-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttMessages/PublishMqttMessage.cpp
119-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttMessages/ReaderMqttPacket.cpp
120-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttMessages/ConnectMqttMessage.cpp
121-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttMessages/UnsubscribeMqttMessage.cpp
122-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttMessages/FactoryMqttMessage.cpp
123-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/TopicTree/NodeTrie.cpp
124-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/TopicTree/Trie.cpp
125-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/ConcurrentTasks/FreeMqttClientTask.cpp
126-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/ConcurrentTasks/NewClientListenerTask.cpp
127-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/ConcurrentTasks/TCPListenerTask.cpp
128-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/Actions/PublishAction.cpp
129-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/Actions/ActionFactory.cpp
130-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/Actions/DisconnectAction.cpp
131-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/Actions/NoAction.cpp
132-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/Actions/UnSubscribeAction.cpp
133-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/Actions/PingResAction.cpp
134-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src/Actions/SubscribeAction.cpp
135-
${LIBRARIES_DIR}/WrapperFreeRTOS/src/Task.cpp
113+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttBroker/MqttBroker.cpp
114+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttClient/MqttClient.cpp
115+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttMessages/SubscribeMqttMessage.cpp
116+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttMessages/AckConnectMqttMessage.cpp
117+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttMessages/MqttMessage.cpp
118+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttMessages/PublishMqttMessage.cpp
119+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttMessages/ReaderMqttPacket.cpp
120+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttMessages/ConnectMqttMessage.cpp
121+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttMessages/UnsubscribeMqttMessage.cpp
122+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/MqttMessages/FactoryMqttMessage.cpp
123+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/TopicTree/NodeTrie.cpp
124+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/TopicTree/Trie.cpp
125+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/ConcurrentTasks/FreeMqttClientTask.cpp
126+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/ConcurrentTasks/NewClientListenerTask.cpp
127+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/ConcurrentTasks/TCPListenerTask.cpp
128+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/Actions/PublishAction.cpp
129+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/Actions/ActionFactory.cpp
130+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/Actions/DisconnectAction.cpp
131+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/Actions/NoAction.cpp
132+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/Actions/UnSubscribeAction.cpp
133+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/Actions/PingResAction.cpp
134+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src/Actions/SubscribeAction.cpp
135+
#${LIBRARIES_DIR}/WrapperFreeRTOS/src/Task.cpp
136136
)
137137

138138

@@ -143,14 +143,14 @@ set(includedirs
143143
#${LIBRARIES_DIR}/AsyncUDP/src
144144
#${LIBRARIES_DIR}/BLE/src
145145
#${LIBRARIES_DIR}/BluetoothSerial/src
146-
${LIBRARIES_DIR}/DNSServer/src
146+
#${LIBRARIES_DIR}/DNSServer/src
147147
#${LIBRARIES_DIR}/EEPROM/src
148148
#${LIBRARIES_DIR}/ESP32/src
149-
${LIBRARIES_DIR}/ESPmDNS/src
149+
#${LIBRARIES_DIR}/ESPmDNS/src
150150
#${LIBRARIES_DIR}/Ethernet/src
151151
#${LIBRARIES_DIR}/FFat/src
152152
${LIBRARIES_DIR}/FS/src
153-
${LIBRARIES_DIR}/HTTPClient/src
153+
#${LIBRARIES_DIR}/HTTPClient/src
154154
#${LIBRARIES_DIR}/HTTPUpdate/src
155155
#${LIBRARIES_DIR}/LittleFS/src
156156
#${LIBRARIES_DIR}/Insights/src
@@ -166,13 +166,13 @@ set(includedirs
166166
#${LIBRARIES_DIR}/Ticker/src
167167
#${LIBRARIES_DIR}/Update/src
168168
#${LIBRARIES_DIR}/USB/src
169-
${LIBRARIES_DIR}/WebServer/src
170-
${LIBRARIES_DIR}/WiFiClientSecure/src
171-
${LIBRARIES_DIR}/WiFi/src
172-
${LIBRARIES_DIR}/WiFiProv/src
169+
#${LIBRARIES_DIR}/WebServer/src
170+
#${LIBRARIES_DIR}/WiFiClientSecure/src
171+
#${LIBRARIES_DIR}/WiFi/src
172+
#${LIBRARIES_DIR}/WiFiProv/src
173173
#${LIBRARIES_DIR}/Wire/src
174-
${LIBRARIES_DIR}/EmbeddedMqttBroker/src
175-
${LIBRARIES_DIR}/WrapperFreeRTOS/src
174+
#${LIBRARIES_DIR}/EmbeddedMqttBroker/src
175+
#${LIBRARIES_DIR}/WrapperFreeRTOS/src
176176
)
177177

178178
set(srcs ${CORE_SRCS} ${LIBRARY_SRCS})

tools/cmake/build.cmake

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ function(__build_set_default_build_specifications)
9191
unset(c_compile_options)
9292
unset(cxx_compile_options)
9393

94-
list(APPEND compile_definitions "-D_GNU_SOURCE")
94+
list(APPEND compile_definitions "-D_GNU_SOURCE"
95+
"-DARDUINO")
9596

9697
list(APPEND compile_options "-ffunction-sections"
9798
"-fdata-sections"

tools/get_include_files.py

+40-30
Original file line numberDiff line numberDiff line change
@@ -23,53 +23,59 @@
2323

2424
files_h_hpp = set()
2525
files_c_cpp = set()
26-
26+
excluded_dirs = ["build", "extras", "example", "examples", "tests", "test"]
2727
def parse_file(file, internal_path, external_path):
2828

2929

3030
with open(file, 'r') as f:
31+
#print(f"file: {f}",file=sys.stderr)
3132
for line in f:
3233
# Buscar líneas de inclusión
3334
match = re.search(r'#include\s+"([^"]+)"|#include\s+<([^>]+)>', line)
3435
if match:
35-
if match.group(1):
36-
path = find_absolute_paths(external_path, match.group(1))
37-
if (path is not None) and ("build" not in path) and ("extras" not in path) and ("example" not in path) and ("examples" not in path) and ("tests" not in path) and ("test" not in path):
38-
39-
print(f"math1: {path} {external_path}",file=sys.stderr)
40-
#print(f'match {match.group(1)}, en fichero {file}')
41-
if path is not None:
42-
if path not in libreriasExternas:
43-
libreriasExternas.add(path)
44-
includes_to_proccess.put(path)
45-
#parse_file(path,externPath)
46-
else:
47-
path = find_absolute_paths(internal_path,match.group(1))
48-
if path is not None and path not in libreriasInternas:
49-
libreriasInternas.add(path)
50-
includes_to_proccess.put(path)
51-
elif match.group(2):
52-
path = find_absolute_paths(internal_path, match.group(2))
53-
print(f"math1: {match.group(2)}",file=sys.stderr)
54-
#print(f'match: {match.group(2)}, en fichero {file}')
55-
if path is not None and path not in libreriasInternas:
56-
libreriasInternas.add(path)
57-
includes_to_proccess.put(path)
58-
#parse_file(path,externPath,internalPath)
59-
36+
if match.group(1) is not None:
37+
#print(f'match 1: {match.group(1)}: ',file=sys.stderr)
38+
if not process_path(match.group(1), external_path, libreriasExternas):
39+
process_path(match.group(1), internal_path, libreriasInternas)
40+
41+
elif match.group(2) is not None:
42+
if not process_path(match.group(2), internal_path,libreriasInternas):
43+
process_path(match.group(2), external_path,libreriasExternas)
44+
6045
files_proccessed.add(file)
6146

6247
if file.endswith(('.c', '.cpp')):
6348
files_c_cpp.add(file)
6449
elif file.endswith(('.h', '.hpp')):
6550
files_h_hpp.add(file)
6651

52+
53+
54+
def process_path(match_group, path_type, libraries):
55+
path = find_absolute_paths(path_type, match_group)
56+
if path is not None:
57+
#print(f'path: {path}',file=sys.stderr)
58+
if not is_path_excluded(path) and path not in libraries:
59+
libraries.add(path)
60+
includes_to_proccess.put(path)
61+
return True
62+
63+
return False
64+
65+
def is_path_excluded(path):
66+
return any(excluded in path for excluded in excluded_dirs)
67+
68+
69+
6770
def looking_for_files(path, extensiones):
71+
#print(f"dir lookingfor: {path}",file=sys.stderr)
6872
for root, dirs, files in os.walk(path):
6973
for file in files:
7074
if file.endswith(tuple(extensiones)):
7175
absolute_path = os.path.abspath(os.path.join(root, file))
72-
files_to_proccess.put(absolute_path)
76+
if not is_path_excluded(absolute_path):
77+
#print(f" file: {absolute_path}",file=sys.stderr)
78+
files_to_proccess.put(absolute_path)
7379

7480

7581

@@ -79,8 +85,8 @@ def looking_for_files(path, extensiones):
7985
def find_absolute_paths(path, lib):
8086
for root, _, files in os.walk(path):
8187
for filename in files:
82-
filepath = os.path.join(root, filename)
83-
if lib in filepath:
88+
if lib == filename:
89+
filepath = os.path.join(root, filename)
8490
return os.path.abspath(filepath)
8591

8692

@@ -152,8 +158,12 @@ def main():
152158

153159

154160
# Uso de la función
161+
print(f"files_h_hpp: {files_h_hpp}",file=sys.stderr)
155162
includedirs = get_include_dirs(files_h_hpp)
156-
print(f"includedirs: {includedirs}",file=sys.stderr)
163+
#includedirs.remove('/home/alex/Arduino/libraries/ArduinoJson')
164+
#includedirs.add('/home/alex/Arduino/libraries/ArduinoJson/src/')
165+
#print(f"includedirs: {includedirs}",file=sys.stderr)
166+
#print(f"includecpp: {files_c_cpp}",file=sys.stderr)
157167
#print(includedirs)
158168

159169

0 commit comments

Comments
 (0)