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 <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Acked-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Acked-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
@ -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()
|
||||
|
||||
##
|
||||
#
|
||||
|
Reference in New Issue
Block a user