зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1662254 - Emit input filename in files generated for static prefs to make it easier to track backwards to a pref via searchfox r=KrisWright
Differential Revision: https://phabricator.services.mozilla.com/D94794
This commit is contained in:
Родитель
41f7925056
Коммит
c2db797cc7
|
@ -57,7 +57,7 @@ RUST_TYPES = {
|
|||
"float": "f32",
|
||||
}
|
||||
|
||||
FIRST_LINE = "// This file was generated by generate_static_pref_list.py. DO NOT EDIT."
|
||||
HEADER_LINE = "// This file was generated by generate_static_pref_list.py from {input_filename}. DO NOT EDIT."
|
||||
|
||||
MIRROR_TEMPLATES = {
|
||||
"never": """\
|
||||
|
@ -222,19 +222,21 @@ def check_pref_list(pref_list):
|
|||
prev_pref = pref
|
||||
|
||||
|
||||
def generate_code(pref_list):
|
||||
def generate_code(pref_list, input_filename):
|
||||
check_pref_list(pref_list)
|
||||
|
||||
first_line = HEADER_LINE.format(input_filename=input_filename)
|
||||
|
||||
# The required includes for StaticPrefs_<group>.h.
|
||||
includes = defaultdict(set)
|
||||
|
||||
# StaticPrefList_<group>.h contains all the pref definitions for this
|
||||
# group.
|
||||
static_pref_list_group_h = defaultdict(lambda: [FIRST_LINE, ""])
|
||||
static_pref_list_group_h = defaultdict(lambda: [first_line, ""])
|
||||
|
||||
# StaticPrefsCGetters.cpp contains C getters for all the mirrored prefs,
|
||||
# for use by Rust code.
|
||||
static_prefs_c_getters_cpp = [FIRST_LINE, ""]
|
||||
static_prefs_c_getters_cpp = [first_line, ""]
|
||||
|
||||
# static_prefs.rs contains C getter declarations and a macro.
|
||||
static_prefs_rs_decls = []
|
||||
|
@ -310,7 +312,7 @@ def generate_code(pref_list):
|
|||
|
||||
# StaticPrefListAll.h contains one `#include "mozilla/StaticPrefList_X.h`
|
||||
# line per pref group.
|
||||
static_pref_list_all_h = [FIRST_LINE, ""]
|
||||
static_pref_list_all_h = [first_line, ""]
|
||||
static_pref_list_all_h.extend(
|
||||
'#include "mozilla/StaticPrefList_{}.h"'.format(group)
|
||||
for group in sorted(static_pref_list_group_h)
|
||||
|
@ -319,7 +321,7 @@ def generate_code(pref_list):
|
|||
|
||||
# StaticPrefsAll.h contains one `#include "mozilla/StaticPrefs_X.h` line per
|
||||
# pref group.
|
||||
static_prefs_all_h = [FIRST_LINE, ""]
|
||||
static_prefs_all_h = [first_line, ""]
|
||||
static_prefs_all_h.extend(
|
||||
'#include "mozilla/StaticPrefs_{}.h"'.format(group)
|
||||
for group in sorted(static_pref_list_group_h)
|
||||
|
@ -330,7 +332,7 @@ def generate_code(pref_list):
|
|||
# used directly by application code.
|
||||
static_prefs_group_h = defaultdict(list)
|
||||
for group in sorted(static_pref_list_group_h):
|
||||
static_prefs_group_h[group] = [FIRST_LINE]
|
||||
static_prefs_group_h[group] = [first_line]
|
||||
static_prefs_group_h[group].append(
|
||||
STATIC_PREFS_GROUP_H_TEMPLATE1.format(group=group)
|
||||
)
|
||||
|
@ -344,7 +346,7 @@ def generate_code(pref_list):
|
|||
)
|
||||
|
||||
# static_prefs.rs contains the Rust macro getters.
|
||||
static_prefs_rs = [FIRST_LINE, "", 'extern "C" {']
|
||||
static_prefs_rs = [first_line, "", 'extern "C" {']
|
||||
static_prefs_rs.extend(static_prefs_rs_decls)
|
||||
static_prefs_rs.extend(["}", "", "#[macro_export]", "macro_rules! pref {"])
|
||||
static_prefs_rs.extend(static_prefs_rs_macro)
|
||||
|
@ -382,7 +384,8 @@ def emit_code(fd, pref_list_filename):
|
|||
|
||||
try:
|
||||
pref_list = yaml.safe_load(pp.out.getvalue())
|
||||
code = generate_code(pref_list)
|
||||
input_file = os.path.relpath(pref_list_filename, os.environ["TOPSRCDIR"])
|
||||
code = generate_code(pref_list, input_file)
|
||||
except (IOError, ValueError) as e:
|
||||
print("{}: error:\n {}\n".format(pref_list_filename, e))
|
||||
sys.exit(1)
|
||||
|
|
Загрузка…
Ссылка в новой задаче