aboutsummaryrefslogtreecommitdiff
path: root/scripts/style_api_gen.py
diff options
context:
space:
mode:
authorGabor Kiss-Vamosi <kisvegabor@gmail.com>2024-01-12 03:41:14 +0100
committerGitHub <noreply@github.com>2024-01-12 10:41:14 +0800
commit8df95aaf4b5b4fe0ed5dc089de38935417d25a45 (patch)
tree8136a2ed0b27b3570249ac3b3558aa117f1c981d /scripts/style_api_gen.py
parent236a2a2672e4d6fe79f3515f77d264d4a3186cd0 (diff)
downloadlvgl-8df95aaf4b5b4fe0ed5dc089de38935417d25a45.tar.gz
lvgl-8df95aaf4b5b4fe0ed5dc089de38935417d25a45.zip
fix(grid,flex): fix compile errors when grid or flex is disabled (#5289)
Diffstat (limited to 'scripts/style_api_gen.py')
-rwxr-xr-xscripts/style_api_gen.py38
1 files changed, 34 insertions, 4 deletions
diff --git a/scripts/style_api_gen.py b/scripts/style_api_gen.py
index 33120a2a2..037adec2c 100755
--- a/scripts/style_api_gen.py
+++ b/scripts/style_api_gen.py
@@ -390,8 +390,7 @@ props = [
'dsc': "Set the base direction of the object. The possible values are `LV_BIDI_DIR_LTR/RTL/AUTO`."},
-
-{'section': 'Flex', 'dsc':'Flex layout properties.' },
+{'section': 'Flex', 'dsc':'Flex layout properties.', 'guard':'LV_USE_FLEX'},
{'name': 'FLEX_FLOW',
@@ -419,7 +418,7 @@ props = [
-{'section': 'Grid', 'dsc':'Grid layout properties.' },
+{'section': 'Grid', 'dsc':'Grid layout properties.', 'guard':'LV_USE_GRID'},
{'name': 'GRID_COLUMN_DSC_ARRAY',
@@ -588,6 +587,20 @@ def docs(p):
print("<li " + li_style + "'><strong>Ext. draw</strong> " + e + "</li>")
print("</ul>")
+def guard_proc(p):
+ global guard
+ if 'section' in p:
+ if guard:
+ guard_close()
+ if 'guard' in p:
+ guard = p['guard']
+ print(f"#if {guard}\n")
+
+def guard_close():
+ global guard
+ if guard:
+ print(f"#endif /*{guard}*/\n")
+ guard = ""
base_dir = os.path.abspath(os.path.dirname(__file__))
sys.stdout = open(base_dir + '/../src/core/lv_obj_style_gen.h', 'w')
@@ -611,11 +624,17 @@ print("#include \"../misc/lv_area.h\"")
print("#include \"../misc/lv_style.h\"")
print("#include \"../core/lv_obj_style.h\"")
print()
+
+guard = ""
for p in props:
+ guard_proc(p)
obj_style_get(p)
+guard_close()
for p in props:
+ guard_proc(p)
local_style_set_h(p)
+guard_close()
print()
print('#endif /* LV_OBJ_STYLE_GEN_H */')
@@ -625,16 +644,22 @@ sys.stdout = open(base_dir + '/../src/core/lv_obj_style_gen.c', 'w')
print(HEADING)
print("#include \"lv_obj.h\"")
print()
+
for p in props:
+ guard_proc(p)
local_style_set_c(p)
+guard_close()
sys.stdout = open(base_dir + '/../src/misc/lv_style_gen.c', 'w')
print(HEADING)
print("#include \"lv_style.h\"")
print()
+
for p in props:
+ guard_proc(p)
style_set_c(p)
+guard_close()
sys.stdout = open(base_dir + '/../src/misc/lv_style_gen.h', 'w')
@@ -642,15 +667,20 @@ print(HEADING)
print('#ifndef LV_STYLE_GEN_H')
print('#define LV_STYLE_GEN_H')
print()
+
for p in props:
+ guard_proc(p)
style_set_h(p)
+guard_close()
for p in props:
+ guard_proc(p)
style_const_set(p)
+guard_close()
+
print()
print('#endif /* LV_STYLE_GEN_H */')
-
sys.stdout = open(base_dir + '/../docs/overview/style-props.md', 'w')
print('# Style properties')