From d70efd6d8c51467da90eb1e8a77e349b00180d4e Mon Sep 17 00:00:00 2001 From: Michael Allwright Date: Tue, 13 Aug 2024 01:08:34 +0200 Subject: [PATCH] Fix `_get_make_variables` ignoring user environment variables (#1230) Co-authored-by: James Sharpe --- foreign_cc/private/make_env_vars.bzl | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/foreign_cc/private/make_env_vars.bzl b/foreign_cc/private/make_env_vars.bzl index 98a767c0..f38fa442 100644 --- a/foreign_cc/private/make_env_vars.bzl +++ b/foreign_cc/private/make_env_vars.bzl @@ -99,15 +99,14 @@ def _get_make_variables(workspace_name, tools, flags, user_env_vars, make_comman vars = {} for flag in _MAKE_FLAGS: - flag_value = getattr(flags, _MAKE_FLAGS[flag]) - if flag_value: - vars[flag] = flag_value - - # Merge flags lists - for user_var in user_env_vars: - toolchain_val = vars.get(user_var) - if toolchain_val: - vars[user_var] = toolchain_val + [user_env_vars[user_var]] + toolchain_flags = getattr(flags, _MAKE_FLAGS[flag], []) + user_flags = [ + user_flag + for user_flag in user_env_vars.get(flag, "").split(" ") + if user_flag + ] + if toolchain_flags or user_flags: + vars[flag] = toolchain_flags + user_flags tools_dict = {} for tool in _MAKE_TOOLS: