From 4d4acaa112ae646a21e3766182b21882ad9df921 Mon Sep 17 00:00:00 2001 From: Wong Heung Sang <35202375+whs-dot-hk@users.noreply.github.com> Date: Mon, 25 Jan 2021 23:02:05 +0000 Subject: [PATCH] Fix pkgconfig for configure_make and make (#447) * Fix pkgconfig for configure_make * Extract pkgconfig script * Fix pkgconfig for make Co-authored-by: James Sharpe --- tools/build_defs/configure_script.bzl | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/tools/build_defs/configure_script.bzl b/tools/build_defs/configure_script.bzl index dd9d1a13b..26b706207 100644 --- a/tools/build_defs/configure_script.bzl +++ b/tools/build_defs/configure_script.bzl @@ -2,6 +2,18 @@ load(":cc_toolchain_util.bzl", "absolutize_path_in_str") load(":framework.bzl", "get_foreign_cc_dep") +def _pkgconfig_script(ext_build_dirs): + """Create a script fragment to configure pkg-config""" + script = [] + for ext_dir in ext_build_dirs: + script.append("##increment_pkg_config_path## $$EXT_BUILD_DEPS$$/" + ext_dir.basename) + + script.append("echo \"PKG_CONFIG_PATH=$$PKG_CONFIG_PATH$$\"") + + script.append("##define_absolute_paths## $$EXT_BUILD_DEPS$$ $$EXT_BUILD_DEPS$$") + + return script + # buildifier: disable=function-docstring def create_configure_script( workspace_name, @@ -28,11 +40,9 @@ def create_configure_script( autogen_env_vars): env_vars_string = get_env_vars(workspace_name, tools, flags, user_vars, deps, inputs) - script = [] - for ext_dir in inputs.ext_build_dirs: - script.append("##increment_pkg_config_path## $$EXT_BUILD_ROOT$$/" + ext_dir.path) + ext_build_dirs = inputs.ext_build_dirs - script.append("echo \"PKG_CONFIG_PATH=$$PKG_CONFIG_PATH$$\"") + script = _pkgconfig_script(ext_build_dirs) root_path = "$$EXT_BUILD_ROOT$$/{}".format(root) configure_path = "{}/{}".format(root_path, configure_command) @@ -83,11 +93,10 @@ def create_make_script( make_commands, prefix): env_vars_string = get_env_vars(workspace_name, tools, flags, user_vars, deps, inputs) - script = [] - for ext_dir in inputs.ext_build_dirs: - script.append("##increment_pkg_config_path## $$EXT_BUILD_ROOT$$/" + ext_dir.path) - script.append("echo \"PKG_CONFIG_PATH=$$PKG_CONFIG_PATH$$\"") + ext_build_dirs = inputs.ext_build_dirs + + script = _pkgconfig_script(ext_build_dirs) script.append("##symlink_contents_to_dir## $$EXT_BUILD_ROOT$$/{} $$BUILD_TMPDIR$$".format(root)) script.append("" + " && ".join(make_commands))