summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/Common
diff options
context:
space:
mode:
authorFeng, Bob C <bob.c.feng@intel.com>2019-07-22 14:23:40 +0800
committerFeng, Bob C <bob.c.feng@intel.com>2019-08-09 23:15:54 +0800
commitc60fb00f6cf084a755eacef55f4347270520202e (patch)
tree6360db2f686159ebab88964f8879b8d7b08e16f0 /BaseTools/Source/Python/Common
parent636ed13a7f9339aea7fdb74de24be1703e9d482c (diff)
downloadedk2-c60fb00f6cf084a755eacef55f4347270520202e.tar.gz
edk2-c60fb00f6cf084a755eacef55f4347270520202e.tar.bz2
edk2-c60fb00f6cf084a755eacef55f4347270520202e.zip
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>
Diffstat (limited to 'BaseTools/Source/Python/Common')
-rw-r--r--BaseTools/Source/Python/Common/TargetTxtClassObject.py28
1 files changed, 24 insertions, 4 deletions
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()
##
#