summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli/generate
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
parentf634fddd344a456c3eff8014d9d58a2d764d7a8c (diff)
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')
-rwxr-xr-xlib/python/qmk/cli/generate/config_h.py9
-rwxr-xr-xlib/python/qmk/cli/generate/rules_mk.py4
2 files changed, 10 insertions, 3 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)
diff --git a/lib/python/qmk/cli/generate/rules_mk.py b/lib/python/qmk/cli/generate/rules_mk.py
index ce824f6378..a1b10cc945 100755
--- a/lib/python/qmk/cli/generate/rules_mk.py
+++ b/lib/python/qmk/cli/generate/rules_mk.py
@@ -19,7 +19,7 @@ def process_mapping_rule(kb_info_json, rules_key, info_dict):
return None
info_key = info_dict['info_key']
- key_type = info_dict.get('value_type', 'str')
+ key_type = info_dict.get('value_type', 'raw')
try:
rules_value = kb_info_json[info_key]
@@ -32,6 +32,8 @@ def process_mapping_rule(kb_info_json, rules_key, info_dict):
return f'{rules_key} ?= {"yes" if rules_value else "no"}'
elif key_type == 'mapping':
return '\n'.join([f'{key} ?= {value}' for key, value in rules_value.items()])
+ elif key_type == 'str':
+ return f'{rules_key} ?= "{rules_value}"'
return f'{rules_key} ?= {rules_value}'