From 9704216ef7472873f2ede82275ba9f8009281fef Mon Sep 17 00:00:00 2001 From: "Shane F. Carr" Date: Fri, 29 Mar 2019 11:55:58 -0400 Subject: [PATCH] ICU-20529 Generate res_index on partial resource trees. --- icu4c/source/data/BUILDRULES.py | 27 ++++++------------- icu4c/source/data/buildtool/request_types.py | 28 +++++++++++++++----- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/icu4c/source/data/BUILDRULES.py b/icu4c/source/data/BUILDRULES.py index 696c7b8c30c..2442f4e3ff6 100644 --- a/icu4c/source/data/BUILDRULES.py +++ b/icu4c/source/data/BUILDRULES.py @@ -516,7 +516,7 @@ def generate_tree( ) ] - # Generate index txt file + # Generate res_index file synthetic_locales = set() deprecates_xml_path = os.path.join(os.path.dirname(__file__), xml_filename) deprecates_xml = ET.parse(deprecates_xml_path) @@ -540,30 +540,19 @@ def generate_tree( IN_SUB_DIR = sub_dir, **common_vars )) - index_file_target_name = "%s_index_txt" % sub_dir - requests += [ - IndexTxtRequest( - name = index_file_target_name, - category = category, - input_files = index_input_files, - output_file = index_file_txt, - cldr_version = cldr_version - ) - ] - - # Generate index res file index_res_file = OutFile("{OUT_PREFIX}{INDEX_NAME}.res".format( OUT_PREFIX = out_prefix, **common_vars )) + index_file_target_name = "%s_index_txt" % sub_dir requests += [ - SingleExecutionRequest( - name = "%s_index_res" % sub_dir, + IndexRequest( + name = index_file_target_name, category = category, - dep_targets = [DepTarget(index_file_target_name)], - input_files = [], - output_files = [index_res_file], - tool = IcuTool("genrb"), + input_files = index_input_files, + txt_file = index_file_txt, + output_file = index_res_file, + cldr_version = cldr_version, args = "-s {TMP_DIR}/{IN_SUB_DIR} -d {OUT_DIR}/{OUT_PREFIX} -i {OUT_DIR} " "-k " "{INDEX_NAME}.txt", diff --git a/icu4c/source/data/buildtool/request_types.py b/icu4c/source/data/buildtool/request_types.py index 0de028513ed..72b3991fbae 100644 --- a/icu4c/source/data/buildtool/request_types.py +++ b/icu4c/source/data/buildtool/request_types.py @@ -284,12 +284,15 @@ class ListRequest(AbstractRequest): return [self.output_file] -class IndexTxtRequest(AbstractRequest): +class IndexRequest(AbstractRequest): def __init__(self, **kwargs): self.input_files = [] + self.txt_file = None self.output_file = None self.cldr_version = "" - super(IndexTxtRequest, self).__init__(**kwargs) + self.args = "" + self.format_with = {} + super(IndexRequest, self).__init__(**kwargs) def apply_file_filter(self, filter): i = 0 @@ -301,11 +304,22 @@ class IndexTxtRequest(AbstractRequest): return i > 0 def flatten(self, config, all_requests, common_vars): - return PrintFileRequest( - name = self.name, - output_file = self.output_file, - content = self._generate_index_file(common_vars) - ).flatten(config, all_requests, common_vars) + return ( + PrintFileRequest( + name = self.name, + output_file = self.txt_file, + content = self._generate_index_file(common_vars) + ).flatten(config, all_requests, common_vars) + + SingleExecutionRequest( + name = "%s_res" % self.name, + category = self.category, + input_files = [self.txt_file], + output_files = [self.output_file], + tool = IcuTool("genrb"), + args = self.args, + format_with = self.format_with + ).flatten(config, all_requests, common_vars) + ) def _generate_index_file(self, common_vars): locales = [f.filename[f.filename.rfind("/")+1:-4] for f in self.input_files] -- 2.40.0