From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web11.6380.1586912809702568478 for ; Tue, 14 Apr 2020 18:06:49 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: eric.dong@intel.com) IronPort-SDR: ODqHXuiDxBBaujSfgwGI3ORze3B0cR8uqX09MjevBW3RSfOKgbeRC/LtZHZgtpPqBFTu/rSZtJ 7EnG6RVLDM/A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2020 18:06:48 -0700 IronPort-SDR: hqRV9TCuURO0WPdZRa/RJoZPv9BJ8IYWrrrjuEVKBFjlvd4hOdULd0+kN2rrKxZ46ny+9xQAXE VyVe6taUjCwQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,385,1580803200"; d="scan'208";a="242161211" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga007.jf.intel.com with ESMTP; 14 Apr 2020 18:06:48 -0700 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 14 Apr 2020 18:06:48 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 14 Apr 2020 18:06:47 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.138]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.7]) with mapi id 14.03.0439.000; Wed, 15 Apr 2020 09:06:44 +0800 From: "Dong, Eric" To: "Feng, Bob C" , "Luo, Heng" , "devel@edk2.groups.io" CC: "Ni, Ray" , "Gao, Liming" , "Chan, Amy" Subject: Re: [PATCH] Platform/Intel/Tools: Add scripts to set PACKAGES_PATH environment Thread-Topic: [PATCH] Platform/Intel/Tools: Add scripts to set PACKAGES_PATH environment Thread-Index: AQHWDtRaRIQqy+bBjkCWiQJ3ZUAxg6h43+QAgACGXkA= Date: Wed, 15 Apr 2020 01:06:44 +0000 Message-ID: References: <20200410010549.866-1-heng.luo@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: eric.dong@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks bob. Heng, Please help to update the patch and send it to me, I will help to push it. Thanks, Eric > -----Original Message----- > From: Feng, Bob C > Sent: Wednesday, April 15, 2020 9:05 AM > To: Luo, Heng ; devel@edk2.groups.io > Cc: Ni, Ray ; Dong, Eric ; Gao, > Liming ; Chan, Amy > Subject: RE: [PATCH] Platform/Intel/Tools: Add scripts to set > PACKAGES_PATH environment >=20 > A typo in the Readme.md. Others are fine for me. > **:+The old PACKAGES_PATH will be replaced by new one.s >=20 > After fix that typo, > Reviewed-by: Bob Feng >=20 > -----Original Message----- > From: Luo, Heng > Sent: Friday, April 10, 2020 9:06 AM > To: devel@edk2.groups.io > Cc: Ni, Ray ; Dong, Eric ; Gao, > Liming ; Feng, Bob C ; Chan, > Amy > Subject: [PATCH] Platform/Intel/Tools: Add scripts to set PACKAGES_PATH > environment >=20 > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2656 >=20 > 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. >=20 > Cc: Ray Ni > Cc: Eric Dong > Cc: Liming Gao > Cc: Bob Feng > Cc: Amy Chan > Signed-off-by: Heng Luo > --- > 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(+) >=20 > 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 under+@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" @got= o > 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++:Enddiff --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 change= d: > +# 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 environmen= t 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/Platform/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 Corpora= tion. > All rights reserved.'+__description__ =3D 'Gets all recursive package pat= hs in > specified directory.\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 t= hat > contains an EDK II package declaration (DEC) file.+ 3. it contains= at least > one first level EDK II Package.+ Note: A directory is not package = path but > its subdirectory could be.+ Example: edk2-platforms/Features is no= t > package path+ but edk2-platforms/Features/Intel is.++ :para= m root: > The specified directory to find package paths in it,+ the call= er should > ensure it is an valid directory+ :type root: String+ :retur= ns: 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 leve= l folder, > inset it to head of list+ paths.insert(0, root)++ # return pack= age paths+ > return paths++def get_packages_path(directories):+ """ For each direco= ry > in directories, gets all recursive package paths+ in this director= y 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(d= irectory)) > or (not os.path.isdir(directory)):+ continue++ if > glob.glob(os.path.join(directory, '*.dec')):+ # it is an EDK I= I Package+ > continue++ paths =3D __get_packages_path(directory)+ for pa= th in > paths:+ if packages_path =3D=3D '':+ packages_p= ath =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 packag= es are got > from')+ args =3D parser.parse_args()+ > print(get_packages_path(args.directory))diff --git > a/Platform/Intel/Tools/AppendPackagesPath/Readme.md > b/Platform/Intel/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 specified directori= es > 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.++**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 he= lp 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+Pleas= e note: > This script must be \'sourced\' so the environment can be changed.+. > AppendPackagesPath.sh+source AppendPackagesPath.sh-- > 2.24.0.windows.2 >=20