]> git.proxmox.com Git - mirror_edk2.git/commit - BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools: AutoGen refactor ModuleAutoGen caching
authorJaben Carsey <jaben.carsey@intel.com>
Fri, 3 Aug 2018 15:11:06 +0000 (23:11 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Mon, 20 Aug 2018 02:53:05 +0000 (10:53 +0800)
commitb23414f6540d4f336b6f00b44681911d469f9a04
tree07276d9f2a931fa1bc336e49954e9e23e60d17ce
parentf843a328772a30c11162c281adaf2afc1b4a972f
BaseTools: AutoGen refactor ModuleAutoGen caching

1) Add a new file Common/caching.py
    a. Allows for automated caching of repeated class functions, class
        properties, and non-class functions
    b. When called the first time the value is cached and if called a
        second time, the cached result is called, not the function.
    c. When used, this saves lots of memory since the actual function
        pointers are replaced with smaller data elements.
    d.  note that not all features are used yet.
2) Fix AutoGen/GenMake and AutoGen/GetC to not call into private member
    variables of ModuleAutoGen class
    a. use the existing accessor properties for the data
3) Change AutoGen classes to remove a exception for duplicate members in
    __new__ and use ?in? testing to speed up
4) Work on ModuleAutoGen class
    a. Change all properties that use caching to use @caching_property
        (see #1 above)
    b. Change all properties that do not use caching to use standard python
        decorator "@property"
    c. Change all cases where a dictionary/set/list/object was created
        and then immediately updated to use constructor parameters
    d. Refactor each property function to remove the internal variable
        that is no longer needed (this helps find items like #2 above)
    e.  Refactor _ApplyBuildRule with optional parameter to work around
        circular dependency with BinaryFileList.

Note that 4e was almost certainly unintended as the functions were acting on
incomplete information since they were directly accessing private instance
variables at the same time another function on the stack was creating the same
private isntance data.

This overall changes behavior slightly, but makes the codebase smaller and
easier to read.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools/Source/Python/AutoGen/GenC.py
BaseTools/Source/Python/AutoGen/GenMake.py
BaseTools/Source/Python/Common/caching.py [new file with mode: 0644]