From c60fb00f6cf084a755eacef55f4347270520202e Mon Sep 17 00:00:00 2001 From: "Feng, Bob C" Date: Mon, 22 Jul 2019 14:23:40 +0800 Subject: BaseTools: Move BuildOption parser out of build.py BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875 Build tool supports user to specify the conf folder. To make the build options be evaluated at the beginning of launching build, extract the buildoption function from build.py to a new .py file. Signed-off-by: Bob Feng Cc: Liming Gao Acked-by: Laszlo Ersek Tested-by: Laszlo Ersek Acked-by: Liming Gao --- .../Source/Python/Common/TargetTxtClassObject.py | 28 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'BaseTools/Source/Python/Common/TargetTxtClassObject.py') diff --git a/BaseTools/Source/Python/Common/TargetTxtClassObject.py b/BaseTools/Source/Python/Common/TargetTxtClassObject.py index 79a5acc010..16cc75ccb7 100644 --- a/BaseTools/Source/Python/Common/TargetTxtClassObject.py +++ b/BaseTools/Source/Python/Common/TargetTxtClassObject.py @@ -10,12 +10,15 @@ # from __future__ import print_function from __future__ import absolute_import +from buildoptions import BuildOption,BuildTarget +import Common.GlobalData as GlobalData import Common.LongFilePathOs as os from . import EdkLogger from . import DataType from .BuildToolError import * -from . import GlobalData + from Common.LongFilePathSupport import OpenLongFilePath as open +from Common.MultipleWorkspace import MultipleWorkspace as mws gDefaultTargetTxtFile = "target.txt" @@ -141,12 +144,29 @@ class TargetTxtClassObject(object): # # @retval Target An instance of TargetTxtClassObject() with loaded target.txt # -def TargetTxtDict(ConfDir): +def TargetTxtDict(): Target = TargetTxtClassObject() - Target.LoadTargetTxtFile(os.path.normpath(os.path.join(ConfDir, gDefaultTargetTxtFile))) + if BuildOption.ConfDirectory: + # Get alternate Conf location, if it is absolute, then just use the absolute directory name + ConfDirectoryPath = os.path.normpath(BuildOption.ConfDirectory) + + if not os.path.isabs(ConfDirectoryPath): + # Since alternate directory name is not absolute, the alternate directory is located within the WORKSPACE + # This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf + ConfDirectoryPath = mws.join(os.environ["WORKSPACE"], ConfDirectoryPath) + else: + if "CONF_PATH" in os.environ: + ConfDirectoryPath = os.path.normcase(os.path.normpath(os.environ["CONF_PATH"])) + else: + # Get standard WORKSPACE/Conf use the absolute path to the WORKSPACE/Conf + ConfDirectoryPath = mws.join(os.environ["WORKSPACE"], 'Conf') + GlobalData.gConfDirectory = ConfDirectoryPath + targettxt = os.path.normpath(os.path.join(ConfDirectoryPath, gDefaultTargetTxtFile)) + if os.path.exists(targettxt): + Target.LoadTargetTxtFile(targettxt) return Target -TargetTxt = TargetTxtDict(os.path.join(os.getenv("WORKSPACE"),"Conf")) +TargetTxt = TargetTxtDict() ## # -- cgit v1.2.3