From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.6201.1586912708695545268 for ; Tue, 14 Apr 2020 18:05:08 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=AyDcrXIE; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: bob.c.feng@intel.com) IronPort-SDR: N692R8nYq2BECMgy0oI5RZk287IfSENi8xa5T6gzbnu9tboBCf2pX+947RBX0QiUUraPMZurGh 09dPL4v8aEIA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2020 18:05:04 -0700 IronPort-SDR: 0Hk6Fc7/UZjbF/aqxEKW76IvE24O/YZRbxRyuYrjtmrpnHXxS8xX82IcyLidQmKaCPmU4TVwfp /V82//JIpPCw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,385,1580803200"; d="scan'208";a="245568147" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga008.fm.intel.com with ESMTP; 14 Apr 2020 18:05:04 -0700 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 14 Apr 2020 18:05:03 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 14 Apr 2020 18:05:03 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.176) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 14 Apr 2020 18:04:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XJwdbF0PydT8wRnq6tFXmqRJq06uRVnv0NuvxoRAwP9SYJ50co+e4oZkTHVvnia06FJSCg4q/9wS6hZCdRYy+5gFH4F4nxfMyuDOU3AYwbU17hvlWzFw52+HCWjl3tJ1f9fSamoD3CddfeFLNxjcHij1I7Tmwa3IicmU3hZrVX5iPYPpdxjiWqfLzMmYrz6CByx85kUsz6ALIKFgToIzwOxAak5tmsse6i7CO5329Sb48Q2qrR8Bt3WrnpaogHm5b7/pf+ctNrmZbCGKdvbyDFbKiDiBQzE7TkGMz6HYQvbhbSQOaJYgzB/H5Nm6N5Sh0gX2zZbas9MM12z3vMUbiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S2cRKdExhFXjo8nQAsUWJqYH1U1VaigZ10J+VdVnWh8=; b=YYg0ZISCMff2+pMTqeTB1prYAFNTpXcVIap7xkGvP5zCiWbqolgtl9Q1zH7jDqI5drFHrVGzWX0Xp/Kh3boAq2+QCO/9BQMyCacei1M+Z7hvSYG8xsQ93DGV1zKJ7pD3jWyITIxNdSgrqUyWJhJSkDKq6S84Rcub/gCgmaoKXjQwLCC/BIY3YItg211dQzsB2OsrpK9vxnkNpR31UCYhKeJK3PfiiveSTc8RMv8EpZwEDms3BGVwfSqrNz1BTNvgYpOHLg2n2bwOT2En80CUx1IRmHdcR+AGWqlNWQnci0oCQFj4i+BQgYYAIvQUtCtym3+p+5ZWbQDEQw5OrpXqiQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S2cRKdExhFXjo8nQAsUWJqYH1U1VaigZ10J+VdVnWh8=; b=AyDcrXIEpbNQv/DM9dLAz7DMDO+vwtreY1kploNCDzZL5eugCVhH12kf4zm4+fRH82vX8qhSMEa+BmSU1vQBMRZ4BBEuHX/LRu5EnkMGfk3zozK+G4faw01TEqjMLXzEmSSvOpCQ/yNIuPNiSP0TKfZ+XbWiq9VAjo23hRExxOc= Received: from BN6PR11MB0068.namprd11.prod.outlook.com (2603:10b6:405:69::17) by BN6PR11MB1857.namprd11.prod.outlook.com (2603:10b6:404:103::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.26; Wed, 15 Apr 2020 01:04:37 +0000 Received: from BN6PR11MB0068.namprd11.prod.outlook.com ([fe80::2d53:d47c:1269:d601]) by BN6PR11MB0068.namprd11.prod.outlook.com ([fe80::2d53:d47c:1269:d601%6]) with mapi id 15.20.2900.026; Wed, 15 Apr 2020 01:04:37 +0000 From: "Bob Feng" 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 Thread-Topic: [PATCH] Platform/Intel/Tools: Add scripts to set PACKAGES_PATH environment Thread-Index: AQHWDtRa10cLnKwZUEm6kRbwNhQPSah5ZVZA Date: Wed, 15 Apr 2020 01:04:36 +0000 Message-ID: References: <20200410010549.866-1-heng.luo@intel.com> In-Reply-To: <20200410010549.866-1-heng.luo@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: spf=none (sender IP is ) smtp.mailfrom=bob.c.feng@intel.com; x-originating-ip: [192.102.204.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0fe2cf0b-41b4-4537-8732-08d7e0d8f7ed x-ms-traffictypediagnostic: BN6PR11MB1857: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:209; x-forefront-prvs: 0374433C81 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR11MB0068.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(10019020)(39860400002)(366004)(136003)(376002)(396003)(346002)(316002)(9686003)(66446008)(53546011)(6506007)(54906003)(52536014)(86362001)(478600001)(76116006)(71200400001)(5660300002)(81156014)(33656002)(66556008)(64756008)(66946007)(110136005)(8676002)(8936002)(55016002)(66476007)(966005)(19627235002)(107886003)(26005)(7696005)(4326008)(2906002)(186003)(134885004);DIR:OUT;SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ot4FcR92nsw9YZf2gahw+bqF5yQ1ii2Pm0hJlUnrDou4qkzo0DWd4T/2/1SOJdV07oHznN/5B2HGbVYn6snAwFd6L4lXZeB8izB6FbIiiecuQvgnYDjJUD8qnwYpVcdUguveXBU1GJL5gVrNTEys4hwGq8QiujJHP7HRqnyqf1tnBYcXPn7MSDRRuZ80r+9snLNQ6xZg8jvvgwNMZI6hNfNGhgoBR3oF4Tn5sLq3Vf9qSolw7RnUi78zhmtLD0vY3+fVj1Hd07ltKmZAdJuhxn8k/f6zEGvuoakcxyCg3JVsOvPg9l569hFxnMiW9mzL6Q/iDICvvW7DXfR16+wIQeA6Fy+rgZBsyMPNmbi7ejhnCBjuzwrdYnBmZE0nDPQgSiLyKJIFgdOw+qJtgkf0ACMbgTT23C3OdgIdCP+ZS2fNAWSyD38/t9BN1DqYS/oOSeK/xEAMw6huCNIxkL417OxAk4PNMmEPdp6g8uslj1dmof9747TTsYvBoSbQard5vgOnmGTxAUPv+VL2eGfMaWAr1loUR7Wby1gK5OwjurVBbZuKCKTtvR0K66eJN8KfCo6GfdWeY6fsWv1Dv3BP9g== x-ms-exchange-antispam-messagedata: QRtpt5pBprBDHKg8TlVDeVHde02Suh6vtnymAusVdQ6kQ2tAM3Xl1gkSDUIdcb36lSHgEk4gh+pgHDz1cS3+cR95DRiqMvDTZrF0j7iKie8TAI67LoktWNveA09c8fEOdWD0gfZctZi+KSPYWUJJ0w== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 0fe2cf0b-41b4-4537-8732-08d7e0d8f7ed X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Apr 2020 01:04:36.9823 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: b1R+WO43+3RD2kWCxCg5TBXc4I7t5bx7BlwyidiS6/YTuQ0+sr81NE3pDZ7sdCw9jRhm4SOax8f7tKtF1c1esw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1857 Return-Path: bob.c.feng@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable A typo in the Readme.md. Others are fine for me. **:+The old PACKAGES_PATH will be replaced by new one.s After fix that typo, Reviewed-by: Bob Feng -----Original Message----- From: Luo, Heng =20 Sent: Friday, April 10, 2020 9:06 AM To: devel@edk2.groups.io Cc: Ni, Ray ; Dong, Eric ; Gao, Limi= ng ; Feng, Bob C ; Chan, Amy Subject: [PATCH] Platform/Intel/Tools: Add scripts to set PACKAGES_PATH env= ironment 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 --- Platform/Intel/Tools/AppendPackagesPath/AppendPackagesPath.bat | 33 ++++++= +++++++++++++++++++++++++++ Platform/Intel/Tools/AppendPackagesPath/Append= PackagesPath.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 SP= DX-License-Identifier: BSD-2-Clause-Patent+@REM+@REM This script calls GetP= ackagesPath.py to collect all package paths under+@REM specified directorie= s and appends them to PACKAGES_PATH environment+@REM variable. A sub direct= ory is a qualified package path when an EDKII+@REM Package can be found und= er it.++@echo off+@if /I "%1"=3D=3D"" @goto Usage+@if /I "%1"=3D=3D"-h" @go= to 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 def= ined 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/T= ools/AppendPackagesPath/AppendPackagesPath.sh b/Platform/Intel/Tools/Append= PackagesPath/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.
#=20 +SPDX-License-Identifier: BSD-2-Clause-Patent # # This script calls=20 +GetPackagesPath.py to collect all package paths under # specified=20 +directories and appends them to PACKAGES_PATH environment # variable. A=20 +sub directory is a qualified package path when an EDKII # Package can=20 +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.+#+# C= opyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-Licen= se-Identifier: BSD-2-Clause-Patent+#++import os+import glob+import argparse= ++#+# Globals for help information+#+__prog__ =3D 'GetPackagesPath.py'+__co= pyright__ =3D 'Copyright (c) 2020, Intel Corporation. All rights reserved.'= +__description__ =3D 'Gets all recursive package paths in specified directo= ry.\n'++def __get_packages_path(root):+ """ Gets all recursive package p= aths in specified directory.+ A directory is a package path if it sa= tisfies 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) file.+ 3. it cont= ains at least one first level EDK II Package.+ Note: A directory is = not package path but its subdirectory could be.+ Example: edk2-platf= orms/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)+ i= f os.path.isdir(filepath):+ if glob.glob(os.path.join(filepath, = '*.dec')):+ # it is an EDK II Package+ contai= n_package =3D True+ else:+ # get package paths fo= r subdirectory if it is not package+ paths =3D paths + __get= _packages_path(filepath)++ if contain_package:+ # root is a packa= ge path because it contains EDK II Package+ # in first level folder,= inset it to head of list+ paths.insert(0, root)++ # return packa= ge paths+ return paths++def get_packages_path(directories):+ """ For = each direcory in directories, gets all recursive package paths+ in t= his directory and joins them into one string.++ :param directories: = the list of directory+ :type directories: String list+ :retur= ns: Return string of package paths+ :rtype: String+ """++ pack= ages_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.p= ath.join(directory, '*.dec')):+ # it is an EDK II Package+ = continue++ paths =3D __get_packages_path(directory)+ fo= r path in paths:+ if packages_path =3D=3D '':+ pa= ckages_path =3D path+ else:+ packages_path +=3D o= s.pathsep + path+ return packages_path++if __name__ =3D=3D '__main__':+ = # Create command line argument parser object+ parser =3D argparse.Arg= umentParser(+ prog=3D__prog__,+ description=3D__descr= iption__ + __copyright__,+ conflict_handler=3D'resolve'+ )+ = parser.add_argument('directory', nargs=3D'+',+ help=3D'Specifi= ed directory where package packages are got from')+ args =3D parser.pars= e_args()+ print(get_packages_path(args.directory))diff --git a/Platform/= Intel/Tools/AppendPackagesPath/Readme.md b/Platform/Intel/Tools/AppendPacka= gesPath/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 GetPackag= esPath.py to collect all package paths under specified directories and appe= nds them to PACKAGES_PATH environment variable. A sub directory is a qualif= ied 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 to= ol++### Windows++Usage: AppendPackagesPath.bat directory [directory ...]+Co= pyright(c) 2020, Intel Corporation. All rights reserved.+Options:+ --help,= -h Print this help screen and exit++### Ubuntu++Usage: source AppendPa= ckagesPath.sh directory [directory ...]+Copyright(c) 2020, Intel Corporatio= n. All rights reserved.+Options:+ --help, -h Print this help screen an= d exit+Please note: This script must be \'sourced\' so the environment can = be changed.+. AppendPackagesPath.sh+source AppendPackagesPath.sh--=20 2.24.0.windows.2