@@ -69,6 +69,7 @@ def _create_meson_script(configureParameters):
69
69
inputs = configureParameters .inputs
70
70
71
71
tools = get_tools_info (ctx )
72
+ flags = get_flags_info (ctx )
72
73
script = pkgconfig_script (inputs .ext_build_dirs )
73
74
74
75
# CFLAGS and CXXFLAGS are also set in foreign_cc/private/cmake_script.bzl, so that meson
@@ -81,20 +82,15 @@ def _create_meson_script(configureParameters):
81
82
if " " not in tools .cxx :
82
83
script .append ("##export_var## CXX {}" .format (_absolutize (ctx .workspace_name , tools .cxx )))
83
84
84
- # set flags same as foreign_cc/private/cc_toolchain_util.bzl
85
- # cannot use get_flags_info() because bazel adds additional flags that
86
- # aren't compatible with compiler or linker above
87
- copts = (ctx .fragments .cpp .copts + ctx .fragments .cpp .conlyopts + getattr (ctx .attr , "copts" , [])) or []
88
- cxxopts = (ctx .fragments .cpp .copts + ctx .fragments .cpp .cxxopts + getattr (ctx .attr , "copts" , [])) or []
89
-
85
+ copts = flags .cc
86
+ cxxopts = flags .cxx
90
87
if copts :
91
- script .append ("##export_var## CFLAGS \" {} ${{CFLAGS:-}}\" " .format (" " . join ( copts ).replace ("\" " , "'" )))
88
+ script .append ("##export_var## CFLAGS \" {} ${{CFLAGS:-}}\" " .format (_join_flags_list ( ctx . workspace_name , copts ).replace ("\" " , "'" )))
92
89
if cxxopts :
93
- script .append ("##export_var## CXXFLAGS \" {} ${{CXXFLAGS:-}}\" " .format (" " . join ( cxxopts ).replace ("\" " , "'" )))
90
+ script .append ("##export_var## CXXFLAGS \" {} ${{CXXFLAGS:-}}\" " .format (_join_flags_list ( ctx . workspace_name , cxxopts ).replace ("\" " , "'" )))
94
91
95
- flags = get_flags_info (ctx )
96
92
if flags .cxx_linker_executable :
97
- script .append ("##export_var## LDFLAGS \" {} ${{LDFLAGS:-}}\" " .format (" " . join ( flags .cxx_linker_executable ).replace ("\" " , "'" )))
93
+ script .append ("##export_var## LDFLAGS \" {} ${{LDFLAGS:-}}\" " .format (_join_flags_list ( ctx . workspace_name , flags .cxx_linker_executable ).replace ("\" " , "'" )))
98
94
99
95
script .append ("##export_var## CMAKE {}" .format (attrs .cmake_path ))
100
96
script .append ("##export_var## NINJA {}" .format (attrs .ninja_path ))
@@ -240,7 +236,7 @@ def meson_with_requirements(name, requirements, **kwargs):
240
236
)
241
237
242
238
def _absolutize (workspace_name , text , force = False ):
243
- if text .strip (" " ).startswith ("C:" ) or text .strip (" " ).startswith ("c:" ):
244
- return "\" {}\" " .format (text )
245
-
246
239
return absolutize_path_in_str (workspace_name , "$EXT_BUILD_ROOT/" , text , force )
240
+
241
+ def _join_flags_list (workspace_name , flags ):
242
+ return " " .join ([_absolutize (workspace_name , flag ) for flag in flags ])
0 commit comments