From nobody Tue May 21 06:43:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+57163+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+57163+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1586480823; cv=none; d=zohomail.com; s=zohoarc; b=SZsgO/pbBKAnuNkB3pvkjWeGmKTfrpBrJCATzLjtguRSCO9R8pqyLrl5cKJC9RHmbLNrI+0OL3TylrHCDP9kVIppw8tSOfFsR5+6j2WVjzsSUtITt/5iyTrMUbd+brXKON4KYijmghjjBI2rjFfXd2R9VqEQY1hlogf7roQPsR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586480823; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=lKEWrj0G9H81Qjax/iXtxMDNCa9GQg4tSptUH0ArKkQ=; b=DRQbojjys92a7hW4lNHioc9Dy7sAKX6pozQqyT0jqXxwtVYz/5mVW0LDnzKyR30IbWYqFBN/joph05pcx5FN8lgS7PNIZwuqw0l98E0uWuiL+cS0OwH3V0vNHqOjacQYDfdfh9r6ar9hZ5tmTWysimC07Skkf9/5aCoBzBpxaOc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+57163+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1586480823308878.9239823055636; Thu, 9 Apr 2020 18:07:03 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id meBHYY1788612xbvXffzRsHA; Thu, 09 Apr 2020 18:07:02 -0700 X-Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web12.1127.1586480822216380701 for ; Thu, 09 Apr 2020 18:07:02 -0700 IronPort-SDR: 2gtDACOJO3oejekzcdYbgU48KGssle4jtEOmbvcG6EO++9LnchyJ697ZxslMp69CDh04oH1fr4 n4qLaMgmJFsw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2020 18:07:01 -0700 IronPort-SDR: GiSinK+uctrA4SUa5kceLMEQMfnNniRYr1h9mWGxvweCCYzCRcIObMGsGrTxEZqne6vJC4acAY 0thH5pLtWg7g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,364,1580803200"; d="scan'208";a="398777541" X-Received: from unknown (HELO hengluo-dev.ccr.corp.intel.com) ([10.239.153.154]) by orsmga004.jf.intel.com with ESMTP; 09 Apr 2020 18:06:59 -0700 From: "Heng Luo" To: devel@edk2.groups.io Cc: Ray Ni , Eric Dong , Liming Gao , Bob Feng , Amy Chan Subject: [edk2-devel] [PATCH] Platform/Intel/Tools: Add scripts to set PACKAGES_PATH environment Date: Fri, 10 Apr 2020 09:05:49 +0800 Message-Id: <20200410010549.866-1-heng.luo@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,heng.luo@intel.com X-Gm-Message-State: P4nGF9y5Y2GxtMFhXkWlyCvkx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1586480822; bh=ggxqie2KYSzLwSnvj6j+zJgQ5piO7YdC55JA7m0BcRg=; h=Cc:Date:From:Reply-To:Subject:To; b=XNOPI5nwRnf0W8PsDDhUqiouuwgg9CowZyzZEftJlZEK8oQNRj8Pu5qF8zRMDf0B2P5 Zjpfkm7cLqTE5I0E6IuiJpsmSjnMmQhVqz+k9+qCOEzopk7WodJCGvIM/7Du1DWdbvfOP 0/5vQBwzqn7qtR7OxBeI1bZvVBtODu8gRLw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2656 1. Add GetPackagesPath.py, it will be used to get package pathes from special directories. A sub directory is a qualified package path when an EDKII Package can be found under it. 2. Add AppendPackagesPath.bat and AppendPackagesPath.sh, these scripts call GetPackagesPath.py to collect all package paths under specified directories and append them to PACKAGES_PATH environment variable. Cc: Ray Ni Cc: Eric Dong Cc: Liming Gao Cc: Bob Feng Cc: Amy Chan Signed-off-by: Heng Luo Reviewed-by: Bob Feng Reviewed-by: Eric Dong Reviewed-by: Ray Ni --- Platform/Intel/Tools/AppendPackagesPath/AppendPackagesPath.bat | 33 ++++++= +++++++++++++++++++++++++++ Platform/Intel/Tools/AppendPackagesPath/AppendPackagesPath.sh | 42 ++++++= ++++++++++++++++++++++++++++++++++++ Platform/Intel/Tools/AppendPackagesPath/GetPackagesPath.py | 98 ++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++ Platform/Intel/Tools/AppendPackagesPath/Readme.md | 28 ++++++= ++++++++++++++++++++++ 4 files changed, 201 insertions(+) diff --git a/Platform/Intel/Tools/AppendPackagesPath/AppendPackagesPath.bat= b/Platform/Intel/Tools/AppendPackagesPath/AppendPackagesPath.bat new file mode 100644 index 0000000000..da15d9c451 --- /dev/null +++ b/Platform/Intel/Tools/AppendPackagesPath/AppendPackagesPath.bat @@ -0,0 +1,33 @@ +@REM @file +@REM Windows batch file to set PACKAGES_PATH environment +@REM +@REM Copyright (c) 2020, Intel Corporation. All rights reserved.
+@REM SPDX-License-Identifier: BSD-2-Clause-Patent +@REM +@REM This script calls GetPackagesPath.py to collect all package paths und= er +@REM specified directories and appends them to PACKAGES_PATH environment +@REM variable. A sub directory is a qualified package path when an EDKII +@REM Package can be found under it. + +@echo off +@if /I "%1"=3D=3D"" @goto Usage +@if /I "%1"=3D=3D"-h" @goto Usage +@if /I "%1"=3D=3D"--help" @goto Usage +@if /I "%1"=3D=3D"/?" @goto Usage + +for /f %%i in ('python %~dp0\GetPackagesPath.py %*') do ( + if defined PACKAGES_PATH ( + set "PACKAGES_PATH=3D%PACKAGES_PATH%;%%i" + ) else ( + set "PACKAGES_PATH=3D%%i" + ) +) +@goto End + +:Usage +@echo Usage: AppendPackagesPath.bat directory [directory ...] +@echo Copyright(c) 2020, Intel Corporation. All rights reserved. +@echo Options: +@echo --help, -h Print this help screen and exit + +:End diff --git a/Platform/Intel/Tools/AppendPackagesPath/AppendPackagesPath.sh = b/Platform/Intel/Tools/AppendPackagesPath/AppendPackagesPath.sh new file mode 100644 index 0000000000..599c8d073b --- /dev/null +++ b/Platform/Intel/Tools/AppendPackagesPath/AppendPackagesPath.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# This script calls GetPackagesPath.py to collect all package paths under +# specified directories and appends them to PACKAGES_PATH environment +# variable. A sub directory is a qualified package path when an EDKII +# Package can be found under it. +# +# Note: This script must be \'sourced\' so the environment can be changed: +# source SetPackagesPath.sh +# . AppendPackagesPath.sh + +function Usage() +{ + echo "Usage: source AppendPackagesPath.sh directory [directory ...]" + echo "Copyright(c) 2020, Intel Corporation. All rights reserved." + echo "Options:" + echo " --help, -h Print this help screen and exit" + echo "Please note: This script must be \'sourced\' so the environment = can be changed." + echo ". AppendPackagesPath.sh" + echo "source AppendPackagesPath.sh" +} + +function SetEnv() +{ + local tool_path=3D$(dirname "$BASH_SOURCE") + local paths=3D$(python $tool_path/GetPackagesPath.py $@) + if [ "$PACKAGES_PATH" ]; then + PACKAGES_PATH=3D$PACKAGES_PATH:$paths + else + PACKAGES_PATH=3D$paths + fi +} + +if [ $# -eq 0 -o "$1" =3D=3D "-h" -o "$1" =3D=3D "--help" -o "$1" =3D=3D "= /?" ]; then + Usage +else + SetEnv $@ +fi diff --git a/Platform/Intel/Tools/AppendPackagesPath/GetPackagesPath.py b/P= latform/Intel/Tools/AppendPackagesPath/GetPackagesPath.py new file mode 100644 index 0000000000..31ed44cfa3 --- /dev/null +++ b/Platform/Intel/Tools/AppendPackagesPath/GetPackagesPath.py @@ -0,0 +1,98 @@ +## @file +# Get all recursive package paths from special directories. +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +import os +import glob +import argparse + +# +# Globals for help information +# +__prog__ =3D 'GetPackagesPath.py' +__copyright__ =3D 'Copyright (c) 2020, Intel Corporation. All rights reser= ved.' +__description__ =3D 'Gets all recursive package paths in specified directo= ry.\n' + +def __get_packages_path(root): + """ Gets all recursive package paths in specified directory. + A directory is a package path if it satisfies conditions below: + 1. it is a directory + 2. it is not an EDK II Package. An EDK II Package (directory) is + a directory that contains an EDK II package declaration (DEC) f= ile. + 3. it contains at least one first level EDK II Package. + Note: A directory is not package path but its subdirectory could b= e. + Example: edk2-platforms/Features is not package path + but edk2-platforms/Features/Intel is. + + :param root: The specified directory to find package paths in it, + the caller should ensure it is an valid directory + :type root: String + :returns: Return all recursive package paths + :rtype: String list + """ + + paths =3D [] + contain_package =3D False + for filename in os.listdir(root): + # skip files whose name starts with ".", such as ".git" + if filename.startswith('.'): + continue + filepath =3D os.path.join(root, filename) + if os.path.isdir(filepath): + if glob.glob(os.path.join(filepath, '*.dec')): + # it is an EDK II Package + contain_package =3D True + else: + # get package paths for subdirectory if it is not package + paths =3D paths + __get_packages_path(filepath) + + if contain_package: + # root is a package path because it contains EDK II Package + # in first level folder, inset it to head of list + paths.insert(0, root) + + # return package paths + return paths + +def get_packages_path(directories): + """ For each direcory in directories, gets all recursive package paths + in this directory and joins them into one string. + + :param directories: the list of directory + :type directories: String list + :returns: Return string of package paths + :rtype: String + """ + + packages_path =3D '' + for directory in directories: + directory =3D os.path.abspath(directory) + if (not os.path.exists(directory)) or (not os.path.isdir(directory= )): + continue + + if glob.glob(os.path.join(directory, '*.dec')): + # it is an EDK II Package + continue + + paths =3D __get_packages_path(directory) + for path in paths: + if packages_path =3D=3D '': + packages_path =3D path + else: + packages_path +=3D os.pathsep + path + return packages_path + +if __name__ =3D=3D '__main__': + # Create command line argument parser object + parser =3D argparse.ArgumentParser( + prog=3D__prog__, + description=3D__description__ + __copyright__, + conflict_handler=3D'resolve' + ) + parser.add_argument('directory', nargs=3D'+', + help=3D'Specified directory where package packages are got fro= m') + args =3D parser.parse_args() + print(get_packages_path(args.directory)) diff --git a/Platform/Intel/Tools/AppendPackagesPath/Readme.md b/Platform/I= ntel/Tools/AppendPackagesPath/Readme.md new file mode 100644 index 0000000000..66aebee7cf --- /dev/null +++ b/Platform/Intel/Tools/AppendPackagesPath/Readme.md @@ -0,0 +1,28 @@ + +# How to use AppendPackagesPath + +## Overview + +This script calls GetPackagesPath.py to collect all package paths under sp= ecified directories and appends them to PACKAGES_PATH environment variable.= A sub directory is a qualified package path when an EDKII Package can be f= ound under it. + +**Notice**: +The old PACKAGES_PATH will be replaced by new one.s + +## The usage of the tool + +### Windows + +Usage: AppendPackagesPath.bat directory [directory ...] +Copyright(c) 2020, Intel Corporation. All rights reserved. +Options: + --help, -h Print this help screen and exit + +### Ubuntu + +Usage: source AppendPackagesPath.sh directory [directory ...] +Copyright(c) 2020, Intel Corporation. All rights reserved. +Options: + --help, -h Print this help screen and exit +Please note: This script must be \'sourced\' so the environment can be cha= nged. +. AppendPackagesPath.sh +source AppendPackagesPath.sh --=20 2.24.0.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#57163): https://edk2.groups.io/g/devel/message/57163 Mute This Topic: https://groups.io/mt/72911539/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-