-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathpatch_library_conflicts.py
More file actions
63 lines (58 loc) · 1.79 KB
/
patch_library_conflicts.py
File metadata and controls
63 lines (58 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import os
import re
import glob
print("Patching library conflicts with ESP32 core...")
# List of conflicts: (file_pattern, search_pattern, replace_pattern)
conflicts = [
(
".pio/libdeps/*/ESP8266SAM/src/render.c",
r'static void yield\(\)',
'static void sam_yield()'
),
(
".pio/libdeps/*/ESP8266SAM/src/render.c",
r'\byield\(\);',
'sam_yield();'
),
(
".pio/libdeps/*/JPEGDecoder/src/picojpeg.c",
r'static uint8 init\(void\)',
'static uint8 picojpeg_init(void)'
),
(
".pio/libdeps/*/JPEGDecoder/src/picojpeg.c",
r'\binit\(\);',
'picojpeg_init();'
),
(
".pio/libdeps/*/ESP Amiibolink/src/amiibolink.h",
r'#include <NimBLEDevice.h>',
'#include <Arduino.h>\n#include <NimBLEDevice.h>'
),
(
".pio/libdeps/*/ESP Chameleon Ultra/src/chameleonUltra.h",
r'#include <NimBLEDevice.h>',
'#include <Arduino.h>\n#include <NimBLEDevice.h>'
),
(
".pio/libdeps/*/ESP PN32BLE/src/pn532_ble.h",
r'#include <NimBLEDevice.h>',
'#include <Arduino.h>\n#include <NimBLEDevice.h>'
),
]
for file_pattern, search, replace in conflicts:
files = glob.glob(file_pattern)
for file_path in files:
try:
with open(file_path, 'r') as f:
content = f.read()
if replace in content:
print(f"Already patched: {file_path}")
continue
new_content = re.sub(search, replace, content)
if new_content != content:
with open(file_path, 'w') as f:
f.write(new_content)
print(f"Patched: {file_path}")
except Exception as e:
print(f"Failed to patch {file_path}: {e}")