From bbc27ea07787cad5dffcfe7e810f63f4aef1d205 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Fri, 1 Apr 2022 12:07:35 -0700 Subject: [PATCH] Make dir work on multiple paths To increase its feature parity with our notdir implementation and gnu make. Bug: 227245326 Test: Manually Change-Id: Ied975f934d7af963e0099054c416f0d364aec8f9 --- core/product_config.rbc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/core/product_config.rbc b/core/product_config.rbc index 0e7dbf186d..89324f973d 100644 --- a/core/product_config.rbc +++ b/core/product_config.rbc @@ -439,10 +439,6 @@ def __base(path): """Returns basename.""" return path.rsplit("/",1)[-1] -def __dir(path): - """Returns dirname.""" - return path.rsplit("/",1)[0] - def _board_platform_in(g, string_or_list): """Returns true if board is in the list.""" board = g.get("TARGET_BOARD_PLATFORM","") @@ -526,6 +522,13 @@ def _filter(pattern, text): res.append(w) return res +def _dir(paths): + """Equivalent to the GNU make function $(dir). + + Returns the folder of the file for each path in paths. + """ + return " ".join([w.rsplit("/",1)[0] for w in __words(paths)]) + def _notdir(paths): """Equivalent to the GNU make function $(notdir). @@ -740,7 +743,7 @@ rblf = struct( copy_files = _copy_files, copy_if_exists = _copy_if_exists, cfg = __h_cfg, - dir = __dir, + dir = _dir, enforce_product_packages_exist = _enforce_product_packages_exist, expand_wildcard = _expand_wildcard, file_exists = rblf_file_exists,