[PATCH] wscript: Deduplicate installed files

Kinsey Moore wkm042 at oarcorp.com
Fri Feb 3 18:45:06 UTC 2023


This is my first stab at solving this duplicate install problem. I could 
manually solve the problem by deduplicating the object includes and 
moving it up to the BSP, but that is less intuitive since these drivers 
both depend on the same code and the BSP doesn't depend on it directly.


Kinsey

On 2/3/2023 12:36 PM, Kinsey Moore wrote:
> The addition of the NAND and NOR drivers both depending on the Xilinx
> support code independently has introduced the possibility of duplicate
> installed headers. This duplication results in multiple header install
> attempts which can conflict since the installs can run on multiple CPUs.
> This change to wscript deduplicates the header installs individually as
> necessary. This change ignores identical installs and throws an error on
> different header installs to the same location.
> ---
>   wscript | 33 ++++++++++++++++++++++++++++++++-
>   1 file changed, 32 insertions(+), 1 deletion(-)
>
> diff --git a/wscript b/wscript
> index a34cac51e2..385ba8eb1c 100755
> --- a/wscript
> +++ b/wscript
> @@ -269,8 +269,39 @@ class Item(object):
>               bld.install_files(install_path, self.get(bld, "target"))
>   
>       def install_files(self, bld):
> +        if "rtems_installed" not in bld.env:
> +            bld.env["rtems_installed"] = {}
> +
>           for install in self.data["install"]:
> -            bld.install_files(install["destination"], install["source"])
> +            # setup destination array if it doesn't exist
> +            dest = install["destination"]
> +            if dest not in bld.env.rtems_installed:
> +                bld.env["rtems_installed"][dest] = []
> +
> +            # build deduplicated install set
> +            dedup_set = []
> +
> +            for item in install["source"]:
> +                # search for duplicate installs
> +                match_found = False
> +                filename = os.path.basename(item)
> +
> +                for existing in bld.env["rtems_installed"][dest]:
> +                    if existing[0] == filename:
> +                        # duplicate found
> +                        if item != existing[1]:
> +                            bld.fatal(("File installs {} and {} " +
> +                                "target the same location").format(
> +                                    item, existing[1]))
> +                        match_found = True
> +                        break
> +
> +                if not match_found:
> +                    dedup_set.append(item)
> +                    bld.env["rtems_installed"][dest].append([filename, item])
> +
> +            if len(dedup_set):
> +                bld.install_files(dest, dedup_set)
>   
>       def asm(self, bld, bic, source, target=None):
>           if target is None:


More information about the devel mailing list