From e6ef8f0693d2a555beba4e997147fa000e0f4329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=A4bler?= Date: Wed, 31 Jul 2019 12:29:00 +0200 Subject: [PATCH] CLASSES: flashlayout: Find layout file in BBPATH Instead of expecting FLASHLAYOUT_DEFAULT_SRC to be a fully qualified path, search in BBPATCH for a matching file. This way it is easier for 3rd party layers to use the mechanism. Change-Id: I0bbcb52a3401e4fca2e75061719c4f1d9062bd67 --- classes/flashlayout-stm32mp.bbclass | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/classes/flashlayout-stm32mp.bbclass b/classes/flashlayout-stm32mp.bbclass index 0875777..c626024 100644 --- a/classes/flashlayout-stm32mp.bbclass +++ b/classes/flashlayout-stm32mp.bbclass @@ -19,7 +19,7 @@ # # Configuration example (machine file or local.conf): # ENABLE_FLASHLAYOUT_DEFAULT = "1" -# FLASHLAYOUT_DEFAULT_SRC = "${STM32MP_BASE}/files/flashlayouts/FlashLayout_sdcard_stm32mp157c-ev1_sample.tsv" +# FLASHLAYOUT_DEFAULT_SRC = "files/flashlayouts/FlashLayout_sdcard_stm32mp157c-ev1_sample.tsv" # # --------------------- # Dynamic configuration @@ -280,6 +280,14 @@ def get_binaryname(labeltype, bootscheme, config, partition, d): # Return binary_name value return binary_name +def flashlayout_search(d, files): + search_path = d.getVar("BBPATH").split(":") + for file in files.split(): + for p in search_path: + file_path = p + "/" + file + if os.path.isfile(file_path): + return (True, file_path) + return (False, "") python do_create_flashlayout_config() { import re @@ -302,15 +310,15 @@ python do_create_flashlayout_config() { bb.fatal("FLASHLAYOUT_DEFAULT_SRC not defined, please set a proper value") if not flashlayout_src.strip(): bb.fatal("No static flashlayout file configured, nothing to do") - for f in flashlayout_src.split(): - if os.path.isfile(f): - flashlayout_staticname=os.path.basename(f) - flashlayout_file = d.expand("${FLASHLAYOUT_DESTDIR}/%s" % flashlayout_staticname) - shutil.copy2(flashlayout_src, flashlayout_file) - bb.note('Copy %s to output file %s' % (f, flashlayout_file)) - return - else: - bb.fatal("Configure static file: %s is not pointing to an existing file" % f) + found, f = flashlayout_search(d, flashlayout_src) + if found: + flashlayout_staticname=os.path.basename(f) + flashlayout_file = d.expand("${FLASHLAYOUT_DESTDIR}/%s" % flashlayout_staticname) + shutil.copy2(f, flashlayout_file) + bb.note('Copy %s to output file %s' % (f, flashlayout_file)) + return + else: + bb.fatal("Configure static file: %s not found" % flashlayout_src) # Set bootschemes for partition var override configuration bootschemes = d.getVar('FLASHLAYOUT_BOOTSCHEME_LABELS')