Skip to content

Commit c991b44

Browse files
committed
meson: use common ldflags
1 parent 4c0c58f commit c991b44

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

foreign_cc/meson.bzl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ def _create_meson_script(configureParameters):
9090
script.append("##export_var## CXXFLAGS \"{} ${{CXXFLAGS:-}}\"".format(_join_flags_list(ctx.workspace_name, cxxopts).replace("\"", "'")))
9191

9292
if flags.cxx_linker_executable:
93-
script.append("##export_var## LDFLAGS \"{} ${{LDFLAGS:-}}\"".format(_join_flags_list(ctx.workspace_name, flags.cxx_linker_executable).replace("\"", "'")))
93+
ldflags = _filter_flags(flags.cxx_linker_executable, ctx.attr.linkopts_exclude)
94+
script.append("##export_var## LDFLAGS \"{} ${{LDFLAGS:-}}\"".format(_join_flags_list(ctx.workspace_name, ldflags).replace("\"", "'")))
9495

9596
script.append("##export_var## CMAKE {}".format(attrs.cmake_path))
9697
script.append("##export_var## NINJA {}".format(attrs.ninja_path))
@@ -216,6 +217,10 @@ def _attrs():
216217
doc = "__deprecated__: please use `target_args` with `'install'` target key.",
217218
mandatory = False,
218219
),
220+
"linkopts_exclude": attr.string_list(
221+
doc = "Optional link options to be excluded from the common set of flags passed from the Bazel toolchain to Meson.",
222+
mandatory = False,
223+
),
219224
"options": attr.string_dict(
220225
doc = "Meson `setup` options (converted to `-Dkey=value`)",
221226
mandatory = False,
@@ -300,3 +305,8 @@ def _absolutize(workspace_name, text, force = False):
300305

301306
def _join_flags_list(workspace_name, flags):
302307
return " ".join([_absolutize(workspace_name, flag) for flag in flags])
308+
309+
def _filter_flags(flags, exclude_list):
310+
if len(exclude_list):
311+
return [flag for flag in flags if flag not in exclude_list]
312+
return flags

0 commit comments

Comments
 (0)