-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_lvgl_esp32_drivers_kconfig.py
69 lines (52 loc) · 2.19 KB
/
run_lvgl_esp32_drivers_kconfig.py
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
64
65
66
67
68
69
Import("env")
import subprocess
import os
import os.path
import errno
if os.name == 'nt':
subprocess.run("pip3 -q install kconfiglib windows-curses")
else:
subprocess.run("pip3 -q install kconfiglib", shell=True)
# Taken from https://stackoverflow.com/a/600612/119527
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else: raise
def menuconfig_callback(*arg, **kwargs):
# save_settings = "include/lvgl.config";
# output_header_file = "include/lvgl.h"
comment_header = "Configured by Dror Gluska"
config_file = "lib/lvgl_esp32_drivers/Kconfig"
save_settings = env.GetProjectOption("custom_lvgl_esp32_drivers_kconfig_save_settings", "");
output_header_file = env.GetProjectOption("custom_lvgl_esp32_drivers_kconfig_output_header", "")
include_header = """
#ifndef SPI_HOST_MAX
#define SPI_HOST_MAX 4
#endif
"""
mkdir_p(os.path.dirname(save_settings))
mkdir_p(os.path.dirname(output_header_file))
comment = [line.strip() for line in comment_header.splitlines()]
comment = [line for line in comment if line]
print("Executing kconfig",config_file,save_settings, output_header_file )
envlist = dict(os.environ)
envlist["KCONFIG_CONFIG"] = save_settings
envlist["KCONFIG_CONFIG_HEADER"] = "#" + "\n#".join(comment) + "\n"
envlist["KCONFIG_AUTOHEADER"] = output_header_file
envlist["KCONFIG_AUTOHEADER_HEADER"] = "// " + "\n// ".join(comment) + "\n" + include_header + "\n"
if os.name == 'nt':
subprocess.call(["menuconfig", config_file], env=envlist, creationflags=subprocess.CREATE_NEW_CONSOLE)
else:
subprocess.call(["menuconfig", config_file], env=envlist)
genconfig_command = ["genconfig", "--header-path", output_header_file, config_file];
print(" ".join(genconfig_command))
subprocess.call(genconfig_command, env=envlist)
env.AddCustomTarget(
"lvgl-esp32-drivers-config",
None,
menuconfig_callback,
title="lvgl-esp32-drivers-config",
description="Executes lvgl esp32 drivers config")