Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Javagedes committed Sep 25, 2023
1 parent a868557 commit 4b98611
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
39 changes: 19 additions & 20 deletions edk2toolext/environment/reporttypes/component_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,33 @@
from edk2toollib.database import Edk2DB

COMPONENT_QUERY = """
SELECT id, path
SELECT path
FROM instanced_inf
WHERE
(path LIKE ? OR ? LIKE '%' || path || '%')
AND env = ?
AND env = ?;
"""

LIBRARY_QUERY = """
SELECT
instanced_inf.id,
instanced_inf.class,
instanced_inf.path
FROM
junction
LEFT JOIN instanced_inf ON instanced_inf.id = junction.key2
SELECT ii.class, iij.instanced_inf2
FROM instanced_inf_junction AS iij
JOIN instanced_inf as ii
ON
ii.env = iij.env
AND ii.component = iij.component
AND iij.instanced_inf2 = ii.path
WHERE
junction.table1 = 'instanced_inf'
AND junction.table2 = 'instanced_inf'
AND junction.key1 = ?
AND junction.env = ?
AND instanced_inf.component = ?;
iij.env = ?
AND iij.component = ?
AND iij.instanced_inf1 = ?;
"""

FLAT_LIBRARY_QUERY = """
SELECT class, path
FROM instanced_inf
WHERE
component = ?
AND env = ?
AND path != component;
"""

Expand Down Expand Up @@ -92,14 +91,14 @@ def run_report(self, db: Edk2DB, args: Namespace) -> None:
self.env_id = args.env_id or self.conn.execute(ID_QUERY).fetchone()[0]
self.component = PurePath(args.component).as_posix()

id, inf_path = self.conn.execute(
inf_path, = self.conn.execute(
COMPONENT_QUERY, (f'%{self.component}%', self.component, self.env_id)).fetchone()
# Print in flat format
if args.flatten:
return self.print_libraries_flat(inf_path)

# Print in recursive format
libraries = self.conn.execute(LIBRARY_QUERY, (id, self.env_id, self.component)).fetchall()
libraries = self.conn.execute(LIBRARY_QUERY, (self.env_id, self.component, self.component)).fetchall()

if self.sort:
libraries = sorted(libraries, key=lambda x: x[1])
Expand All @@ -108,17 +107,17 @@ def run_report(self, db: Edk2DB, args: Namespace) -> None:
for library in libraries:
self.print_libraries_recursive(library, [])

def print_libraries_recursive(self, library: Tuple[str, str, str], visited: list, depth: int = 0):
def print_libraries_recursive(self, library: Tuple[str, str], visited: list, depth: int = 0):
"""Prints the libraries used in a provided library / component."""
id, library_class, library_instance = library
library_class, library_instance = library
if depth >= self.depth:
return
print(f'{" "*depth}- {library_class}| {library_instance or "NOT FOUND IN DSC"}', file=self.file)

if library_instance is None:
return

libraries = self.conn.execute(LIBRARY_QUERY, (id, self.env_id, self.component))
libraries = self.conn.execute(LIBRARY_QUERY, (self.env_id, self.component, library_instance)).fetchall()

if self.sort:
libraries = sorted(libraries, key=lambda x: x[1])
Expand All @@ -132,7 +131,7 @@ def print_libraries_recursive(self, library: Tuple[str, str, str], visited: list

def print_libraries_flat(self, component):
"""Prints the libraries used in a provided component."""
libraries = self.conn.execute(FLAT_LIBRARY_QUERY, (component,)).fetchall()
libraries = self.conn.execute(FLAT_LIBRARY_QUERY, (component,self.env_id)).fetchall()

length = max(len(item[0]) for item in libraries)
if self.sort:
Expand Down
2 changes: 1 addition & 1 deletion edk2toolext/environment/reporttypes/usage_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
FROM
variable,
instanced_fv
JOIN junction ON instanced_fv.id = junction.key1
JOIN junction ON instanced_fv.env = junction.env
AND junction.table1 = 'instanced_fv'
AND junction.table2 = 'inf'
JOIN instanced_inf ON instanced_inf.component = junction.key2
Expand Down
1 change: 0 additions & 1 deletion edk2toolext/invocables/edk2_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ def parse_with_builder_settings(self, db: Edk2DB, pathobj: Edk2Path, env: VarDic
logging.info(f" ACTIVE_PLATFORM: {env_dict['ACTIVE_PLATFORM']}")
logging.info(f" TARGET_ARCH: {env_dict['TARGET_ARCH']}")
db.parse(env_dict)
db.parse(env_dict)
return 0

def parse_with_ci_settings(self, db: Edk2DB, pathobj: Edk2Path, env: VarDict):
Expand Down

0 comments on commit 4b98611

Please sign in to comment.