1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 14:58:09 +00:00

feat(core/rust): create mako template for QSTR generation

This commit is contained in:
grdddj 2023-05-04 14:54:00 +02:00 committed by Martin Milata
parent 03913ebf1b
commit 0c0d74a501
2 changed files with 143 additions and 106 deletions

View File

@ -1,122 +1,127 @@
// generated from librust_qstr.h.mako
// (by running `make templates` in `core`)
// do not edit manually!
#pragma GCC diagnostic ignored "-Wunused-value"
#pragma GCC diagnostic ignored "-Wunused-function"
static void _librust_qstrs(void) {
// protobuf
MP_QSTR_CANCELLED;
MP_QSTR_CONFIRMED;
MP_QSTR_INFO;
MP_QSTR_Layout;
MP_QSTR_MESSAGE_NAME;
MP_QSTR_MESSAGE_WIRE_TYPE;
MP_QSTR_Msg;
MP_QSTR_MsgDef;
MP_QSTR_is_type_of;
MP_QSTR_MESSAGE_WIRE_TYPE;
MP_QSTR_MESSAGE_NAME;
// layout
MP_QSTR___dict__;
MP_QSTR___name__;
MP_QSTR_trezorui2;
MP_QSTR_Layout;
MP_QSTR_CONFIRMED;
MP_QSTR_CANCELLED;
MP_QSTR_INFO;
MP_QSTR_disable_animation;
MP_QSTR_jpeg_info;
MP_QSTR_jpeg_test;
MP_QSTR_confirm_action;
MP_QSTR_confirm_homescreen;
MP_QSTR_confirm_address;
MP_QSTR_confirm_blob;
MP_QSTR_confirm_properties;
MP_QSTR_confirm_coinjoin;
MP_QSTR_confirm_fido;
MP_QSTR_confirm_total;
MP_QSTR_confirm_modify_fee;
MP_QSTR_confirm_modify_output;
MP_QSTR_confirm_reset_device;
MP_QSTR_confirm_text;
MP_QSTR_confirm_value;
MP_QSTR_confirm_with_info;
MP_QSTR_confirm_more;
MP_QSTR_confirm_recovery;
MP_QSTR_show_checklist;
MP_QSTR_show_error;
MP_QSTR_show_qr;
MP_QSTR_show_success;
MP_QSTR_show_warning;
MP_QSTR_show_info;
MP_QSTR_show_mismatch;
MP_QSTR_show_simple;
MP_QSTR_request_number;
MP_QSTR_request_pin;
MP_QSTR_request_passphrase;
MP_QSTR_request_bip39;
MP_QSTR_request_slip39;
MP_QSTR_select_word;
MP_QSTR_select_word_count;
MP_QSTR_show_group_share_success;
MP_QSTR_show_homescreen;
MP_QSTR_show_lockscreen;
MP_QSTR_draw_welcome_screen;
MP_QSTR_show_remaining_shares;
MP_QSTR_show_share_words;
MP_QSTR_show_progress;
MP_QSTR_show_progress_coinjoin;
MP_QSTR_show_address_details;
MP_QSTR_show_spending_details;
MP_QSTR_attach_timer_fn;
MP_QSTR_touch_event;
MP_QSTR_button_event;
MP_QSTR_progress_event;
MP_QSTR_usb_event;
MP_QSTR_timer;
MP_QSTR_paint;
MP_QSTR_request_complete_repaint;
MP_QSTR_trace;
MP_QSTR_bounds;
MP_QSTR_page_count;
MP_QSTR_title;
MP_QSTR_subtitle;
MP_QSTR_action;
MP_QSTR_description;
MP_QSTR_extra;
MP_QSTR_verb;
MP_QSTR_verb_cancel;
MP_QSTR_hold;
MP_QSTR_hold_danger;
MP_QSTR_reverse;
MP_QSTR_prompt;
MP_QSTR_subprompt;
MP_QSTR_warning;
MP_QSTR_allow_cancel;
MP_QSTR_max_len;
MP_QSTR_amount_change;
MP_QSTR_amount_new;
MP_QSTR_ask_pagination;
MP_QSTR_case_sensitive;
MP_QSTR_coin_name;
MP_QSTR_max_feerate;
MP_QSTR_max_rounds;
MP_QSTR_total_fee_new;
MP_QSTR_user_fee_change;
MP_QSTR_fee_rate;
MP_QSTR_words;
MP_QSTR_pages;
MP_QSTR_count;
MP_QSTR_min_count;
MP_QSTR_max_count;
MP_QSTR_items;
MP_QSTR_image;
MP_QSTR_active;
MP_QSTR_info_button;
MP_QSTR_time_ms;
MP_QSTR_app_name;
MP_QSTR_icon_name;
MP_QSTR_account;
MP_QSTR_accounts;
MP_QSTR_action;
MP_QSTR_active;
MP_QSTR_address;
MP_QSTR_allow_cancel;
MP_QSTR_amount_change;
MP_QSTR_amount_new;
MP_QSTR_app_name;
MP_QSTR_attach_timer_fn;
MP_QSTR_bootscreen;
MP_QSTR_bounds;
MP_QSTR_button;
MP_QSTR_button_event;
MP_QSTR_case_sensitive;
MP_QSTR_confirm_action;
MP_QSTR_confirm_address;
MP_QSTR_confirm_blob;
MP_QSTR_confirm_coinjoin;
MP_QSTR_confirm_fido;
MP_QSTR_confirm_homescreen;
MP_QSTR_confirm_modify_fee;
MP_QSTR_confirm_modify_output;
MP_QSTR_confirm_more;
MP_QSTR_confirm_properties;
MP_QSTR_confirm_recovery;
MP_QSTR_confirm_reset_device;
MP_QSTR_confirm_text;
MP_QSTR_confirm_total;
MP_QSTR_confirm_value;
MP_QSTR_confirm_with_info;
MP_QSTR_count;
MP_QSTR_data;
MP_QSTR_description;
MP_QSTR_disable_animation;
MP_QSTR_draw_welcome_screen;
MP_QSTR_dry_run;
MP_QSTR_extra;
MP_QSTR_fee_rate;
MP_QSTR_fee_rate_amount;
MP_QSTR_hold;
MP_QSTR_hold_danger;
MP_QSTR_icon_name;
MP_QSTR_image;
MP_QSTR_indeterminate;
MP_QSTR_info_button;
MP_QSTR_is_type_of;
MP_QSTR_items;
MP_QSTR_jpeg_info;
MP_QSTR_jpeg_test;
MP_QSTR_label;
MP_QSTR_lines;
MP_QSTR_max_count;
MP_QSTR_max_feerate;
MP_QSTR_max_len;
MP_QSTR_max_rounds;
MP_QSTR_min_count;
MP_QSTR_notification;
MP_QSTR_notification_level;
MP_QSTR_bootscreen;
MP_QSTR_page_count;
MP_QSTR_pages;
MP_QSTR_paint;
MP_QSTR_path;
MP_QSTR_progress_event;
MP_QSTR_prompt;
MP_QSTR_request_bip39;
MP_QSTR_request_complete_repaint;
MP_QSTR_request_number;
MP_QSTR_request_passphrase;
MP_QSTR_request_pin;
MP_QSTR_request_slip39;
MP_QSTR_reverse;
MP_QSTR_select_word;
MP_QSTR_select_word_count;
MP_QSTR_show_address_details;
MP_QSTR_show_checklist;
MP_QSTR_show_error;
MP_QSTR_show_group_share_success;
MP_QSTR_show_homescreen;
MP_QSTR_show_info;
MP_QSTR_show_lockscreen;
MP_QSTR_show_mismatch;
MP_QSTR_show_progress;
MP_QSTR_show_progress_coinjoin;
MP_QSTR_show_remaining_shares;
MP_QSTR_show_share_words;
MP_QSTR_show_simple;
MP_QSTR_show_spending_details;
MP_QSTR_show_success;
MP_QSTR_show_warning;
MP_QSTR_sign;
MP_QSTR_skip_first_paint;
MP_QSTR_subprompt;
MP_QSTR_subtitle;
MP_QSTR_time_ms;
MP_QSTR_timer;
MP_QSTR_title;
MP_QSTR_total_fee_new;
MP_QSTR_touch_event;
MP_QSTR_trace;
MP_QSTR_trezorui2;
MP_QSTR_usb_event;
MP_QSTR_user_fee_change;
MP_QSTR_value;
MP_QSTR_verb;
MP_QSTR_verb_cancel;
MP_QSTR_words;
MP_QSTR_wrong_pin;
MP_QSTR_xpubs;
}

View File

@ -0,0 +1,32 @@
// generated from librust_qstr.h.mako
// (by running `make templates` in `core`)
// do not edit manually!
#pragma GCC diagnostic ignored "-Wunused-value"
#pragma GCC diagnostic ignored "-Wunused-function"
static void _librust_qstrs(void) {
<%
import subprocess
import sys
from pathlib import Path
from typing import Union, Set
THIS = Path(local.filename).resolve()
HERE = THIS.parent
RUST_SRC = HERE / "src"
def find_unique_patterns_in_dir(directory: Union[str, Path], pattern: str) -> Set[str]:
command = f"grep -ro '{pattern}' {directory}"
result = subprocess.run(command, stdout=subprocess.PIPE, text=True, shell=True)
output_lines = result.stdout.strip().split("\n")
return set([line.split(":", 1)[1] for line in output_lines if line])
pattern = r"\bMP_QSTR_\w*"
qstrings = find_unique_patterns_in_dir(RUST_SRC, pattern)
# sort result alphabetically
qstrings_sorted = sorted(qstrings)
%>\
% for qstr in qstrings_sorted:
${qstr};
% endfor
}