mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
[better_engineering][multiplatform] Replace host_info() check with separate cmd and cmd_exe commands for protos (#98426)
Summary: Same as title Test Plan: CI Differential Revision: D44670281 Pull Request resolved: https://github.com/pytorch/pytorch/pull/98426 Approved by: https://github.com/ezyang
This commit is contained in:
parent
d5120ff18a
commit
b663f7e887
1 changed files with 16 additions and 19 deletions
35
c2_defs.bzl
35
c2_defs.bzl
|
|
@ -390,19 +390,17 @@ def c2_protobuf_rule(protos):
|
|||
raw_headers = {}
|
||||
for p in protos:
|
||||
proto = paths.basename(p)
|
||||
if native.host_info().os.is_windows:
|
||||
protocexe = "$(exe fbsource//third-party/protobuf:protoc-host)" if is_arvr_mode() else "$(location fbsource//xplat/third-party/protobuf:protoc.Windows)"
|
||||
protocmd = "powershell.exe -file $(location fbsource//xplat/caffe2/scripts:proto)\\proto.ps1 -Protoc {} -Unprocessed $SRCDIR/{} -Processed $SRCDIR/{} -out $OUT -srcdir $SRCDIR".format(protocexe, p, proto)
|
||||
else:
|
||||
protocmd = ("cp $SRCDIR/{} $SRCDIR/{} && chmod +w $SRCDIR/{} && echo \"option optimize_for = LITE_RUNTIME;\" >> $SRCDIR/{} && ".format(p, proto, proto, proto) +
|
||||
"cp $SRCDIR/caffe2/proto/caffe2.proto $SRCDIR/caffe2.proto && chmod +w $SRCDIR/caffe2.proto && echo \"option optimize_for = LITE_RUNTIME;\" >> $SRCDIR/caffe2.proto && " +
|
||||
"sed -i -e 's/caffe2\\/proto\\/caffe2.proto/caffe2.proto/g' $SRCDIR/{} && ".format(proto) +
|
||||
("$(exe fbsource//third-party/protobuf:protoc-host) " if using_protobuf_v3() else "$(exe fbsource//xplat/third-party/protobuf:protoc) --osx $(location fbsource//xplat/third-party/protobuf:protoc.Darwin) --linux $(location fbsource//xplat/third-party/protobuf:protoc.Linux) ") +
|
||||
"-I $SRCDIR --cpp_out=$OUT $SRCDIR/{}".format(proto))
|
||||
protocexe = "$(exe fbsource//third-party/protobuf:protoc-host)" if is_arvr_mode() else "$(location fbsource//xplat/third-party/protobuf:protoc.Windows)"
|
||||
protocmd_exe = "powershell.exe -file $(location fbsource//xplat/caffe2/scripts:proto)\\proto.ps1 -Protoc {} -Unprocessed $SRCDIR/{} -Processed $SRCDIR/{} -out $OUT -srcdir $SRCDIR".format(protocexe, p, proto)
|
||||
protocmd = ("cp $SRCDIR/{} $SRCDIR/{} && chmod +w $SRCDIR/{} && echo \"option optimize_for = LITE_RUNTIME;\" >> $SRCDIR/{} && ".format(p, proto, proto, proto) +
|
||||
"cp $SRCDIR/caffe2/proto/caffe2.proto $SRCDIR/caffe2.proto && chmod +w $SRCDIR/caffe2.proto && echo \"option optimize_for = LITE_RUNTIME;\" >> $SRCDIR/caffe2.proto && " +
|
||||
"sed -i -e 's/caffe2\\/proto\\/caffe2.proto/caffe2.proto/g' $SRCDIR/{} && ".format(proto) +
|
||||
("$(exe fbsource//third-party/protobuf:protoc-host) " if using_protobuf_v3() else "$(exe fbsource//xplat/third-party/protobuf:protoc) --osx $(location fbsource//xplat/third-party/protobuf:protoc.Darwin) --linux $(location fbsource//xplat/third-party/protobuf:protoc.Linux) ") +
|
||||
"-I $SRCDIR --cpp_out=$OUT $SRCDIR/{}".format(proto))
|
||||
buck_genrule(
|
||||
name = proto,
|
||||
srcs = sorted(collections.uniq([p, "caffe2/proto/caffe2.proto"])),
|
||||
cmd_exe = protocmd,
|
||||
cmd_exe = protocmd_exe,
|
||||
bash = protocmd,
|
||||
out = ".",
|
||||
)
|
||||
|
|
@ -437,19 +435,18 @@ def c2_full_protobuf_rule(protos):
|
|||
raw_headers = {}
|
||||
for p in protos:
|
||||
proto = paths.basename(p)
|
||||
if native.host_info().os.is_windows:
|
||||
protocexe = "$(exe fbsource//third-party/protobuf:protoc-host)" if is_arvr_mode() else "$(location fbsource//xplat/third-party/protobuf:protoc.Windows)"
|
||||
protocmd = "powershell.exe -file $(location fbsource//xplat/caffe2/scripts:proto)\\proto.ps1 -Protoc {} -Unprocessed $SRCDIR/{} -Processed $SRCDIR/{} -out $OUT -srcdir $SRCDIR".format(protocexe, p, proto)
|
||||
else:
|
||||
protocmd = ("cp $SRCDIR/{} $SRCDIR/{} && ".format(p, proto) +
|
||||
"cp $SRCDIR/caffe2/proto/caffe2.proto $SRCDIR/caffe2.proto && " +
|
||||
"sed -i -e 's/caffe2\\/proto\\/caffe2.proto/caffe2.proto/g' $SRCDIR/{} && ".format(proto) +
|
||||
("$(exe fbsource//third-party/protobuf:protoc-host) " if using_protobuf_v3() else "$(exe fbsource//xplat/third-party/protobuf:protoc) --osx $(location fbsource//xplat/third-party/protobuf:protoc.Darwin) --linux $(location fbsource//xplat/third-party/protobuf:protoc.Linux) ") +
|
||||
"-I $SRCDIR --cpp_out=$OUT $SRCDIR/{}".format(proto))
|
||||
protocexe = "$(exe fbsource//third-party/protobuf:protoc-host)" if is_arvr_mode() else "$(location fbsource//xplat/third-party/protobuf:protoc.Windows)"
|
||||
protocmd_exe = "powershell.exe -file $(location fbsource//xplat/caffe2/scripts:proto)\\proto.ps1 -Protoc {} -Unprocessed $SRCDIR/{} -Processed $SRCDIR/{} -out $OUT -srcdir $SRCDIR".format(protocexe, p, proto)
|
||||
protocmd = ("cp $SRCDIR/{} $SRCDIR/{} && ".format(p, proto) +
|
||||
"cp $SRCDIR/caffe2/proto/caffe2.proto $SRCDIR/caffe2.proto && " +
|
||||
"sed -i -e 's/caffe2\\/proto\\/caffe2.proto/caffe2.proto/g' $SRCDIR/{} && ".format(proto) +
|
||||
("$(exe fbsource//third-party/protobuf:protoc-host) " if using_protobuf_v3() else "$(exe fbsource//xplat/third-party/protobuf:protoc) --osx $(location fbsource//xplat/third-party/protobuf:protoc.Darwin) --linux $(location fbsource//xplat/third-party/protobuf:protoc.Linux) ") +
|
||||
"-I $SRCDIR --cpp_out=$OUT $SRCDIR/{}".format(proto))
|
||||
buck_genrule(
|
||||
name = prefix + proto,
|
||||
srcs = sorted(collections.uniq([p, "caffe2/proto/caffe2.proto"])),
|
||||
cmd = protocmd,
|
||||
cmd_exe = protocmd_exe,
|
||||
out = ".",
|
||||
)
|
||||
(name, _) = paths.split_extension(proto)
|
||||
|
|
|
|||
Loading…
Reference in a new issue