Skip to content

Commit

Permalink
支持多个 proto_file 配置, 修复 global 里配置的默认 option 配置
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed Jul 9, 2023
1 parent 3f1a021 commit b9623ad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
3. 修订老式命令行接口的错误码
4. 优化忽略规则
5. 修订重复的自定义参数的问题
6. 支持多个 `proto_file` 配置
7. 修复 `global` 里配置的默认 `option` 配置

1.4.0
------
Expand Down
21 changes: 16 additions & 5 deletions xresconv_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def main():
"default_scheme": {},
"data_version": None,
"output_matrix": {"file_path": None, "outputs": []},
"protocol_files": {"file_path": None, "inputs": []},
}

# 默认双线程,实际测试过程中java的运行优化反而比多线程更能提升效率
Expand Down Expand Up @@ -260,7 +261,16 @@ def load_global_options(gns):
xconv_options["output_matrix"]["outputs"].append(output_rule)

elif tag_name == "proto_file":
xconv_options["args"]["-f"] = '"' + text_value + '"'
if (
global_node["file_path"]
!= xconv_options["protocol_files"]["file_path"]
):
xconv_options["protocol_files"]["inputs"] = []
xconv_options["protocol_files"]["file_path"] = global_node[
"file_path"
]
xconv_options["protocol_files"]["inputs"].append("-f")
xconv_options["protocol_files"]["inputs"].append('"' + text_value + '"')

elif tag_name == "output_dir":
xconv_options["args"]["-o"] = '"' + text_value + '"'
Expand Down Expand Up @@ -435,6 +445,8 @@ def load_list_item_nodes(lis):

for item_output in item_output_matrix:
item_cmd_args_array = []
item_cmd_args_array.extend(global_cmd_args_prefix_array)
item_cmd_args_array.extend(xconv_options["protocol_files"]["inputs"])

# merge global options
if "tags" in item_output and item_output["tags"]:
Expand Down Expand Up @@ -588,11 +600,12 @@ def worker_func(idx, exit_data):

cprintf_stdout(
[print_style.FC_GREEN],
('"{0}"' + os.linesep + "\t>{1}" + os.linesep).format(
'" "'.join(java_options), (os.linesep + "\t>").join(this_thd_cmds)
('"{0}"' + os.linesep + "\t> {1}" + os.linesep).format(
'" "'.join(java_options), (os.linesep + "\t> ").join(this_thd_cmds)
),
)

# ----------------------------------------- 实际开始转换 -----------------------------------------
for i in range(0, options.parallelism):
this_worker_thd = threading.Thread(target=worker_func, args=[i, exit_data])
this_worker_thd.start()
Expand All @@ -602,8 +615,6 @@ def worker_func(idx, exit_data):
for thd in all_worker_thread:
thd.join()

# ----------------------------------------- 实际开始转换 -----------------------------------------

cprintf_stdout(
[print_style.FC_MAGENTA],
"[INFO] all jobs done. {0} job(s) failed.{1}".format(exit_data["exit_code"], os.linesep),
Expand Down

0 comments on commit b9623ad

Please sign in to comment.