diff options
author | Yonghong Zhu <yonghong.zhu@intel.com> | 2017-09-19 14:31:09 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2017-09-27 17:14:54 +0800 |
commit | 36d083ef0018b78ea12db1a5f2e8df5336541fea (patch) | |
tree | b51b862e4e3bcf590525dbe617666c293f984713 /BaseTools/Source/Python/build | |
parent | 3dcb53258df3d3f7deb9ef4083fdb5b7aa9e22b3 (diff) | |
download | edk2-36d083ef0018b78ea12db1a5f2e8df5336541fea.tar.gz edk2-36d083ef0018b78ea12db1a5f2e8df5336541fea.tar.bz2 edk2-36d083ef0018b78ea12db1a5f2e8df5336541fea.zip |
BaseTools: add support for BIOS build with binary cache
Add three new options:
--hash enables hash-based caching during build process. when --hash is
enabled, build tool will base on the module hash value to do the
incremental build, without --hash, build tool will base on the
timestamp to do the incremental build. --hash option use md5 method to
get every hash value, DSC/FDF, tools_def.txt, build_rule.txt and build
command are calculated as global hash value, Package DEC and its
include header files are calculated as package hash value, Module
source files and its INF file are calculated as module hash value.
Library hash value will combine the global hash value and its dependent
package hash value. Driver hash value will combine the global hash
value, its dependent package hash value and its linked library hash
value.
When --hash and --binary-destination are specified, build tool will
copy generated binary files for each module into the directory specified
by binary-destination at the build phase. Binary-destination directory
caches all generated binary files.
When --hash and --binary-source are specified, build tool will try to
get the binary files from the binary source directory at the build
phase.If the cached binary has the same hash value, it will be directly
used. Otherwise, build tool will compile the source files and generate
the binary files.
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/build')
-rw-r--r-- | BaseTools/Source/Python/build/build.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py index 8275f1b5b9..dd65c66b65 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -771,6 +771,30 @@ class Build(): GlobalData.BuildOptionPcd = BuildOptions.OptionPcd
#Set global flag for build mode
GlobalData.gIgnoreSource = BuildOptions.IgnoreSources
+ GlobalData.gUseHashCache = BuildOptions.UseHashCache
+ GlobalData.gBinCacheDest = BuildOptions.BinCacheDest
+ GlobalData.gBinCacheSource = BuildOptions.BinCacheSource
+
+ if GlobalData.gBinCacheDest and not GlobalData.gUseHashCache:
+ EdkLogger.error("build", OPTION_NOT_SUPPORTED, ExtraData="--binary-destination must be used together with --hash.")
+
+ if GlobalData.gBinCacheSource and not GlobalData.gUseHashCache:
+ EdkLogger.error("build", OPTION_NOT_SUPPORTED, ExtraData="--binary-source must be used together with --hash.")
+
+ if GlobalData.gBinCacheDest and GlobalData.gBinCacheSource:
+ EdkLogger.error("build", OPTION_NOT_SUPPORTED, ExtraData="--binary-destination can not be used together with --binary-source.")
+
+ if GlobalData.gBinCacheSource:
+ BinCacheSource = os.path.normpath(GlobalData.gBinCacheSource)
+ if not os.path.isabs(BinCacheSource):
+ BinCacheSource = mws.join(self.WorkspaceDir, BinCacheSource)
+ GlobalData.gBinCacheSource = BinCacheSource
+
+ if GlobalData.gBinCacheDest:
+ BinCacheDest = os.path.normpath(GlobalData.gBinCacheDest)
+ if not os.path.isabs(BinCacheDest):
+ BinCacheDest = mws.join(self.WorkspaceDir, BinCacheDest)
+ GlobalData.gBinCacheDest = BinCacheDest
if self.ConfDirectory:
# Get alternate Conf location, if it is absolute, then just use the absolute directory name
@@ -1952,6 +1976,9 @@ class Build(): if Ma == None:
continue
+ if Ma.CanSkipbyHash():
+ continue
+
# Not to auto-gen for targets 'clean', 'cleanlib', 'cleanall', 'run', 'fds'
if self.Target not in ['clean', 'cleanlib', 'cleanall', 'run', 'fds']:
# for target which must generate AutoGen code and makefile
@@ -2274,6 +2301,9 @@ def MyOptionParser(): Parser.add_option("--ignore-sources", action="store_true", dest="IgnoreSources", default=False, help="Focus to a binary build and ignore all source files")
Parser.add_option("--pcd", action="append", dest="OptionPcd", help="Set PCD value by command line. Format: \"PcdName=Value\" ")
Parser.add_option("-l", "--cmd-len", action="store", type="int", dest="CommandLength", help="Specify the maximum line length of build command. Default is 4096.")
+ Parser.add_option("--hash", action="store_true", dest="UseHashCache", default=False, help="Enable hash-based caching during build process.")
+ 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.")
(Opt, Args) = Parser.parse_args()
return (Opt, Args)
|