summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli/generate/config_h.py
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2022-03-05 00:25:24 +1100
committerGitHub <noreply@github.com>2022-03-04 13:25:24 +0000
commitace0603f4f060783ea91c224c0caec6c1b799f15 (patch)
treee97bc1c3e37d11e7daa0c4a1e5db0dacb5f01475 /lib/python/qmk/cli/generate/config_h.py
parentf634fddd344a456c3eff8014d9d58a2d764d7a8c (diff)
downloadqmk_firmware-ace0603f4f060783ea91c224c0caec6c1b799f15.tar.gz
qmk_firmware-ace0603f4f060783ea91c224c0caec6c1b799f15.zip
Change data driven "str" type to represent a quoted string literal (#16516)
* Change data driven "str" type to represent a quoted string literal * Update docs
Diffstat (limited to 'lib/python/qmk/cli/generate/config_h.py')
-rwxr-xr-xlib/python/qmk/cli/generate/config_h.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py
index 24bbbdf517..340ed10436 100755
--- a/lib/python/qmk/cli/generate/config_h.py
+++ b/lib/python/qmk/cli/generate/config_h.py
@@ -82,7 +82,7 @@ def generate_config_items(kb_info_json, config_h_lines):
for config_key, info_dict in info_config_map.items():
info_key = info_dict['info_key']
- key_type = info_dict.get('value_type', 'str')
+ key_type = info_dict.get('value_type', 'raw')
to_config = info_dict.get('to_config', True)
if not to_config:
@@ -110,6 +110,11 @@ def generate_config_items(kb_info_json, config_h_lines):
config_h_lines.append(f'#ifndef {key}')
config_h_lines.append(f'# define {key} {value}')
config_h_lines.append(f'#endif // {key}')
+ elif key_type == 'str':
+ config_h_lines.append('')
+ config_h_lines.append(f'#ifndef {config_key}')
+ config_h_lines.append(f'# define {config_key} "{config_value}"')
+ config_h_lines.append(f'#endif // {config_key}')
elif key_type == 'bcd_version':
(major, minor, revision) = config_value.split('.')
config_h_lines.append('')
@@ -200,7 +205,7 @@ def generate_config_h(cli):
cli.args.output.parent.mkdir(parents=True, exist_ok=True)
if cli.args.output.exists():
cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
- cli.args.output.write_text(config_h)
+ cli.args.output.write_text(config_h, encoding='utf-8')
if not cli.args.quiet:
cli.log.info('Wrote info_config.h to %s.', cli.args.output)