Skip to content

Commit 868feed

Browse files
feat: make the thrift get cross platform compat (#386)
## Summary - Make the thrift gen python executable, use `py_binary` to support python generally ## Checklist - [ ] Added Unit Tests - [ ] Covered by existing CI - [ ] Integration tested - [ ] Documentation update <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Chores** - Enhanced the build process for a key automation tool by streamlining its execution and command handling, leading to improved overall build reliability and performance. - Transitioned the export mechanism of a Python script to a defined executable binary target for better integration within the build system. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- av pr metadata This information is embedded by the av CLI when creating PRs to track the status of stacks when using Aviator. Please do not delete or edit this section of the PR. ``` {"parent":"main","parentHead":"","trunk":"main"} ``` --> Co-authored-by: Thomas Chow <[email protected]>
1 parent c2bfcdc commit 868feed

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

scripts/codemod/BUILD.bazel

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
exports_files(["thrift_package_replace.py"])
1+
py_binary(
2+
name = "thrift_package_replace",
3+
srcs = ["thrift_package_replace.py"],
4+
main = "thrift_package_replace.py",
5+
visibility = ["//visibility:public"],
6+
)

tools/build_rules/thrift/thrift.bzl

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,30 +56,23 @@ def _thrift_gen_library_impl(ctx):
5656

5757
def replace_java_files_with_custom_thrift_package_prefix(ctx, input_directories):
5858
output_directories = []
59-
60-
# Get the script from the rule's files
61-
script = ctx.file._python_script
62-
59+
script = ctx.executable._python_script
6360
for input_directory in input_directories:
6461
output_directory = ctx.actions.declare_directory(
65-
input_directory.basename + "_modified",
62+
input_directory.basename + "_modified"
6663
)
6764
output_directories.append(output_directory)
6865

69-
command = """
70-
python3 "{script}" -v "{input_path}" "{output_path}"
71-
""".format(
72-
script = script.path,
73-
input_path = input_directory.path,
74-
output_path = output_directory.path,
75-
)
76-
77-
ctx.actions.run_shell(
78-
inputs = [input_directory, script], # Include script in inputs
66+
ctx.actions.run(
67+
executable=script,
68+
inputs = [input_directory],
7969
outputs = [output_directory],
80-
command = command,
70+
arguments = [
71+
"-v",
72+
input_directory.path,
73+
output_directory.path
74+
],
8175
progress_message = "Replacing package names in input Java files for %s" % input_directory.short_path,
82-
use_default_shell_env = True,
8376
)
8477

8578
return output_directories
@@ -94,8 +87,9 @@ _thrift_gen_library = rule(
9487
),
9588
"thrift_binary": attr.string(),
9689
"_python_script": attr.label(
97-
default = "//scripts/codemod:thrift_package_replace.py",
98-
allow_single_file = True,
90+
default = "//scripts/codemod:thrift_package_replace",
91+
executable = True,
92+
cfg = "host",
9993
),
10094
},
10195
)

0 commit comments

Comments
 (0)