|
1 | 1 | """Bazel rules for building Envoy dynamic modules.""" |
2 | 2 |
|
| 3 | +load("@envoy_repo//:compiler.bzl", "LLVM_PATH") |
3 | 4 | load("@rules_cc//cc:defs.bzl", "cc_import") |
4 | 5 |
|
5 | 6 | def envoy_dynamic_module_prefix_symbols(name, module_name, archive, tags = [], **kwargs): |
@@ -61,19 +62,30 @@ def envoy_dynamic_module_prefix_symbols(name, module_name, archive, tags = [], * |
61 | 62 | # NOTE: The case statement is kept outside $() command substitution for |
62 | 63 | # compatibility with bash 3.2 (macOS default), which cannot parse case |
63 | 64 | # pattern delimiters inside $(). |
| 65 | + archive_select_cmd = ( |
| 66 | + "ARCH=\"\"; " + |
| 67 | + "for f in $(SRCS); do case $$f in *.pic.a) continue;; *.a) ARCH=$$f; break;; esac; done; " + |
| 68 | + "[ -z \"$$ARCH\" ] && " + |
| 69 | + "for f in $(SRCS); do case $$f in *.a) ARCH=$$f; break;; esac; done; " |
| 70 | + ) |
64 | 71 | native.genrule( |
65 | 72 | name = renamed_name, |
66 | 73 | srcs = [archive, ":" + redefine_syms_name], |
67 | 74 | outs = [name + "_renamed.a"], |
68 | | - cmd = ( |
69 | | - "ARCH=\"\"; " + |
70 | | - "for f in $(SRCS); do case $$f in *.pic.a) continue;; *.a) ARCH=$$f; break;; esac; done; " + |
71 | | - "[ -z \"$$ARCH\" ] && " + |
72 | | - "for f in $(SRCS); do case $$f in *.a) ARCH=$$f; break;; esac; done; " + |
73 | | - "$(location @llvm_toolchain_llvm//:objcopy) " + |
74 | | - "--redefine-syms=$(location :" + redefine_syms_name + ") $$ARCH $@" |
75 | | - ), |
76 | | - tools = ["@llvm_toolchain_llvm//:objcopy"], |
| 75 | + cmd = archive_select_cmd + select({ |
| 76 | + "@envoy_repo//:use_local_llvm": ( |
| 77 | + "%s/bin/llvm-objcopy " % LLVM_PATH + |
| 78 | + "--redefine-syms=$(location :" + redefine_syms_name + ") $$ARCH $@" |
| 79 | + ), |
| 80 | + "//conditions:default": ( |
| 81 | + "$(location @llvm_toolchain_llvm//:objcopy) " + |
| 82 | + "--redefine-syms=$(location :" + redefine_syms_name + ") $$ARCH $@" |
| 83 | + ), |
| 84 | + }), |
| 85 | + tools = select({ |
| 86 | + "@envoy_repo//:use_local_llvm": [], |
| 87 | + "//conditions:default": ["@llvm_toolchain_llvm//:objcopy"], |
| 88 | + }), |
77 | 89 | tags = tags, |
78 | 90 | ) |
79 | 91 |
|
|
0 commit comments