From e28396114f0fa7bb95779e56d7a8b4d0a59af1a3 Mon Sep 17 00:00:00 2001 From: gulu-goolu Date: Tue, 20 Aug 2024 16:04:50 +0000 Subject: [PATCH] fix: keep original source tree when symlink into ext_include_dir --- foreign_cc/private/framework.bzl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/foreign_cc/private/framework.bzl b/foreign_cc/private/framework.bzl index 892467e58..1ef59dcaa 100644 --- a/foreign_cc/private/framework.bzl +++ b/foreign_cc/private/framework.bzl @@ -749,13 +749,23 @@ def _symlink_contents_to_dir(dir_name, files_list): path = _file_path(file).strip() if path: lines.append("##symlink_contents_to_dir## \ -$$EXT_BUILD_ROOT$$/{} $$EXT_BUILD_DEPS$$/{} True".format(path, dir_name)) +$$EXT_BUILD_ROOT$$/{} $$EXT_BUILD_DEPS$$/{} True".format(path, _get_dir_name(dir_name, file))) return lines def _file_path(file): return file if type(file) == "string" else file.path +def _get_dir_name(dir, file): + if dir == "include": + if type(file) == "File" and file.owner != None and file.owner.package != "": + workspace_root = file.owner.workspace_root + path = "/".join(file.path.split("/")[:-1]) + prefix = "{}/".format(workspace_root) + if path.startswith(prefix): + return "{}/{}".format(dir, path.removeprefix(prefix)) + return dir + _FORBIDDEN_FOR_FILENAME = ["\\", "/", ":", "*", "\"", "<", ">", "|"] def _check_file_name(var):