@@ -15,9 +15,9 @@ load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
1515load ("//cargo:defs.bzl" , "cargo_build_script" )
1616
1717_EXPECTED_CC_TOOLCHAIN_TOOLS = {
18+ "AR" : "/usr/fake/ar" ,
1819 "CC" : "/usr/fake/gcc" ,
1920 "CXX" : "/usr/fake/g++" ,
20- "AR" : "/usr/fake/ar" ,
2121}
2222
2323def _test_cc_config_impl (ctx ):
@@ -142,9 +142,9 @@ def _test_cc_config_impl(ctx):
142142test_cc_config = rule (
143143 implementation = _test_cc_config_impl ,
144144 attrs = {
145+ "extra_ar_flags" : attr .string_list (),
145146 "extra_cc_compile_flags" : attr .string_list (),
146147 "extra_cxx_compile_flags" : attr .string_list (),
147- "extra_ar_flags" : attr .string_list (),
148148 "legacy_cc_toolchain" : attr .bool (default = False ),
149149 },
150150 provides = [CcToolchainConfigInfo ],
@@ -207,9 +207,9 @@ def _cc_args_and_env_analysis_test_impl(ctx):
207207 )
208208
209209 _ENV_VAR_TO_EXPECTED_ARGS = {
210+ "ARFLAGS" : ctx .attr .expected_arflags ,
210211 "CFLAGS" : ctx .attr .expected_cflags ,
211212 "CXXFLAGS" : ctx .attr .expected_cxxflags ,
212- "ARFLAGS" : ctx .attr .expected_arflags ,
213213 }
214214
215215 for env_var , expected_flags in _ENV_VAR_TO_EXPECTED_ARGS .items ():
@@ -227,9 +227,9 @@ cc_args_and_env_analysis_test = analysistest.make(
227227 impl = _cc_args_and_env_analysis_test_impl ,
228228 doc = """An analysistest to examine the custom cargo flags of an cargo_build_script target.""" ,
229229 attrs = {
230+ "expected_arflags" : attr .string_list (default = ["-x" ]),
230231 "expected_cflags" : attr .string_list (default = ["-Wall" ]),
231232 "expected_cxxflags" : attr .string_list (default = ["-fno-rtti" ]),
232- "expected_arflags" : attr .string_list (default = ["-x" ]),
233233 "legacy_cc_toolchain" : attr .bool (default = False ),
234234 },
235235)
@@ -251,7 +251,9 @@ def cargo_build_script_with_extra_cc_compile_flags(
251251
252252 Args:
253253 name: The name of the test target.
254- extra_cc_compile_flags: Extra args for the cc_toolchain.
254+ extra_cc_compile_flags: Extra C/C++ args for the cc_toolchain.
255+ extra_cxx_compile_flags: Extra C++-specific args for the cc_toolchain.
256+ extra_ar_flags: Extra archiver args for the cc_toolchain.
255257 """
256258
257259 test_cc_config (
0 commit comments