From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A4EF52194EB75 for ; Wed, 13 Mar 2019 15:11:03 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Mar 2019 15:11:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,475,1544515200"; d="scan'208";a="140546998" Received: from jyao1-mobl2.ccr.corp.intel.com ([10.254.215.66]) by FMSMGA003.fm.intel.com with ESMTP; 13 Mar 2019 15:11:01 -0700 From: Jiewen Yao To: edk2-devel@lists.01.org Cc: Bob Feng , Liming Gao , Yonghong Zhu Date: Thu, 14 Mar 2019 06:10:54 +0800 Message-Id: <20190313221054.17132-1-jiewen.yao@intel.com> X-Mailer: git-send-email 2.19.2.windows.1 MIME-Version: 1.0 Subject: [PATCH] BaseTool/Build: Add --disable-include-path-check. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Mar 2019 22:11:03 -0000 Content-Transfer-Encoding: 8bit BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1620 This option is added to disable the include path check for outside of package. The original purpose of thie check is to make sure EDK II modules must not reference header files outside of the packages they depend on or within the module's directory tree. However, we do see the usage to build EDKII as executable running in the operating system which requires include path to outside. For example, EmulatorPkg. The current solution (soft link) is weird hack - EmulatorPkg\Unix\Host\X11IncludeHack. With this solution, this can be supported easily. The patch is validated with and without --disable-include-path-check. If user does not use --disable-include-path-check, the build will fail with outside path in the include path. If user uses --disable-include-path-check, the build will pass with outside path in the include path. Cc: Bob Feng Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jiewen Yao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 15 ++++++++------- BaseTools/Source/Python/build/build.py | 2 ++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index e7dbf66e2f..568d535754 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -3037,13 +3037,14 @@ class ModuleAutoGen(AutoGen): # EDK II modules must not reference header files outside of the packages they depend on or # within the module's directory tree. Report error if violation. # - for Path in IncPathList: - if (Path not in self.IncludePathList) and (CommonPath([Path, self.MetaFile.Dir]) != self.MetaFile.Dir): - ErrMsg = "The include directory for the EDK II module in this line is invalid %s specified in %s FLAGS '%s'" % (Path, Tool, FlagOption) - EdkLogger.error("build", - PARAMETER_INVALID, - ExtraData=ErrMsg, - File=str(self.MetaFile)) + if GlobalData.gDisableIncludePathCheck == False: + for Path in IncPathList: + if (Path not in self.IncludePathList) and (CommonPath([Path, self.MetaFile.Dir]) != self.MetaFile.Dir): + ErrMsg = "The include directory for the EDK II module in this line is invalid %s specified in %s FLAGS '%s'" % (Path, Tool, FlagOption) + EdkLogger.error("build", + PARAMETER_INVALID, + ExtraData=ErrMsg, + File=str(self.MetaFile)) RetVal += IncPathList return RetVal diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py index 99e79d4dca..de641fb452 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -719,6 +719,7 @@ class Build(): GlobalData.gBinCacheDest = BuildOptions.BinCacheDest GlobalData.gBinCacheSource = BuildOptions.BinCacheSource GlobalData.gEnableGenfdsMultiThread = BuildOptions.GenfdsMultiThread + GlobalData.gDisableIncludePathCheck = BuildOptions.DisableIncludePathCheck if GlobalData.gBinCacheDest and not GlobalData.gUseHashCache: EdkLogger.error("build", OPTION_NOT_SUPPORTED, ExtraData="--binary-destination must be used together with --hash.") @@ -2268,6 +2269,7 @@ def MyOptionParser(): Parser.add_option("--binary-destination", action="store", type="string", dest="BinCacheDest", help="Generate a cache of binary files in the specified directory.") Parser.add_option("--binary-source", action="store", type="string", dest="BinCacheSource", help="Consume a cache of binary files from the specified directory.") Parser.add_option("--genfds-multi-thread", action="store_true", dest="GenfdsMultiThread", default=False, help="Enable GenFds multi thread to generate ffs file.") + Parser.add_option("--disable-include-path-check", action="store_true", dest="DisableIncludePathCheck", default=False, help="Disable the include path check for outside of package.") (Opt, Args) = Parser.parse_args() return (Opt, Args) -- 2.19.2.windows.1