|
| 1 | +load("@bazel_skylib//lib:selects.bzl", "selects") |
| 2 | +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") |
| 3 | +load("@rules_cc//cc/toolchains:args_list.bzl", "cc_args_list") |
| 4 | + |
| 5 | +cc_args_list( |
| 6 | + name = "args", |
| 7 | + args = |
| 8 | + select({ |
| 9 | + ":libcxx": [ |
| 10 | + ":arg-include", |
| 11 | + ":arg-lib", |
| 12 | + ":link_actions", |
| 13 | + ":link_executable_actions", |
| 14 | + ], |
| 15 | + "//conditions:default": [], |
| 16 | + }), |
| 17 | + visibility = ["//runtimes:__pkg__"], |
| 18 | +) |
| 19 | + |
| 20 | +cc_args( |
| 21 | + name = "arg-include", |
| 22 | + actions = [ |
| 23 | + "@rules_cc//cc/toolchains/actions:c_compile", |
| 24 | + "@rules_cc//cc/toolchains/actions:cpp_compile_actions", |
| 25 | + ], |
| 26 | + args = [ |
| 27 | + "-isystem", |
| 28 | + "{include}", |
| 29 | + ], |
| 30 | + data = [ |
| 31 | + ":include", |
| 32 | + ], |
| 33 | + format = { |
| 34 | + "include": ":include", |
| 35 | + }, |
| 36 | +) |
| 37 | + |
| 38 | +cc_args( |
| 39 | + name = "arg-lib", |
| 40 | + actions = [ |
| 41 | + "@rules_cc//cc/toolchains/actions:link_actions", |
| 42 | + ], |
| 43 | + args = [ |
| 44 | + "-L{lib}", |
| 45 | + ], |
| 46 | + data = [ |
| 47 | + ":lib", |
| 48 | + ], |
| 49 | + format = { |
| 50 | + "lib": ":lib", |
| 51 | + }, |
| 52 | +) |
| 53 | + |
| 54 | +cc_args( |
| 55 | + name = "link_actions", |
| 56 | + actions = [ |
| 57 | + "@rules_cc//cc/toolchains/actions:link_actions", |
| 58 | + ], |
| 59 | + args = select({ |
| 60 | + ":libcxx-shared": [ |
| 61 | + "-L{lib}", |
| 62 | + "-lc++", |
| 63 | + "-lc++abi", |
| 64 | + "-lunwind", |
| 65 | + "-llzma", |
| 66 | + ], |
| 67 | + ":libcxx-static": [ |
| 68 | + "{lib}/libc++.a", |
| 69 | + "{lib}/libc++abi.a", |
| 70 | + "{lib}/libunwind.a", |
| 71 | + "{lib}/liblzma.a", |
| 72 | + ], |
| 73 | + }), |
| 74 | + data = [ |
| 75 | + ":lib", |
| 76 | + ], |
| 77 | + format = { |
| 78 | + "lib": ":lib", |
| 79 | + }, |
| 80 | +) |
| 81 | + |
| 82 | +cc_args( |
| 83 | + name = "link_executable_actions", |
| 84 | + actions = [ |
| 85 | + "@rules_cc//cc/toolchains/actions:link_executable_actions", |
| 86 | + ], |
| 87 | + args = select({ |
| 88 | + ":libcxx-shared": [ |
| 89 | + "-L{lib}", |
| 90 | + ], |
| 91 | + ":libcxx-static": [ |
| 92 | + "-L{lib}", |
| 93 | + ], |
| 94 | + }), |
| 95 | + data = [ |
| 96 | + ":lib", |
| 97 | + ], |
| 98 | + format = { |
| 99 | + "lib": ":lib", |
| 100 | + }, |
| 101 | +) |
| 102 | + |
| 103 | +alias( |
| 104 | + name = "include", |
| 105 | + actual = select({ |
| 106 | + ":libcxx-latest": "//runtimes/libcxx/19.1.7:include", |
| 107 | + ":libcxx-19.1.7": "//runtimes/libcxx/19.1.7:include", |
| 108 | + }), |
| 109 | +) |
| 110 | + |
| 111 | +alias( |
| 112 | + name = "lib", |
| 113 | + actual = select({ |
| 114 | + ":libcxx-latest": "//runtimes/libcxx/19.1.7:lib", |
| 115 | + ":libcxx-19.1.7": "//runtimes/libcxx/19.1.7:lib", |
| 116 | + }), |
| 117 | +) |
| 118 | + |
| 119 | +selects.config_setting_group( |
| 120 | + name = "libcxx", |
| 121 | + match_any = [ |
| 122 | + ":libcxx-latest", |
| 123 | + ":libcxx-19.1.7", |
| 124 | + ], |
| 125 | +) |
| 126 | + |
| 127 | +selects.config_setting_group( |
| 128 | + name = "libcxx-shared", |
| 129 | + match_any = [ |
| 130 | + ":libcxx-shared-latest", |
| 131 | + ":libcxx-shared-19.1.7", |
| 132 | + ], |
| 133 | +) |
| 134 | + |
| 135 | +selects.config_setting_group( |
| 136 | + name = "libcxx-static", |
| 137 | + match_any = [ |
| 138 | + ":libcxx-static-latest", |
| 139 | + ":libcxx-static-19.1.7", |
| 140 | + ], |
| 141 | +) |
| 142 | + |
| 143 | +selects.config_setting_group( |
| 144 | + name = "libcxx-latest", |
| 145 | + match_any = [ |
| 146 | + ":libcxx-shared-latest", |
| 147 | + ":libcxx-static-latest", |
| 148 | + ], |
| 149 | +) |
| 150 | + |
| 151 | +config_setting( |
| 152 | + name = "libcxx-shared-latest", |
| 153 | + flag_values = { |
| 154 | + "//:use_runtimes": "libcxx", |
| 155 | + }, |
| 156 | +) |
| 157 | + |
| 158 | +config_setting( |
| 159 | + name = "libcxx-static-latest", |
| 160 | + flag_values = { |
| 161 | + "//:use_runtimes": "libcxx-static", |
| 162 | + }, |
| 163 | +) |
| 164 | + |
| 165 | +selects.config_setting_group( |
| 166 | + name = "libcxx-19.1.7", |
| 167 | + match_any = [ |
| 168 | + ":libcxx-shared-19.1.7", |
| 169 | + ":libcxx-static-19.1.7", |
| 170 | + ], |
| 171 | +) |
| 172 | + |
| 173 | +config_setting( |
| 174 | + name = "libcxx-shared-19.1.7", |
| 175 | + flag_values = { |
| 176 | + "//:use_runtimes": "libcxx-19.1.7", |
| 177 | + }, |
| 178 | +) |
| 179 | + |
| 180 | +config_setting( |
| 181 | + name = "libcxx-static-19.1.7", |
| 182 | + flag_values = { |
| 183 | + "//:use_runtimes": "libcxx-static-19.1.7", |
| 184 | + }, |
| 185 | +) |
0 commit comments