diff --git a/foreign_cc/private/framework.bzl b/foreign_cc/private/framework.bzl index 33129b8fc..10b3dd1d5 100644 --- a/foreign_cc/private/framework.bzl +++ b/foreign_cc/private/framework.bzl @@ -767,13 +767,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):