Commit 8e74a764 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras
Browse files

Introduce cache-ing of AADL ASTs created by ANTLR-based parser.

parent b7f5c79b
......@@ -80,6 +80,7 @@ but with an extra call to OnFinal at the end.
import os
import sys
import hashlib
from distutils import spawn
from typing import cast, Optional, Dict, List, Tuple, Set, Any # NOQA pylint: disable=unused-import
......@@ -145,6 +146,32 @@ def ParseAADLfilesAndResolveSignals() -> None:
'''Invokes the ANTLR generated AADL parser, and resolves
all references to AAADL Data types into the param._signal member
of each SUBPROGRAM param.'''
projectCache = os.getenv("PROJECT_CACHE")
if projectCache is not None:
if not os.path.isdir(projectCache):
panic("The configured cache folder:\n\n\t" + projectCache +
"\n\ not there!\n")
cachedModelExists = False
aadlASTcache = None
if projectCache is not None:
filehash = hashlib.md5()
for each in sorted(sys.argv[1:]):
newHash = filehash.hexdigest()
# set the name of the Pickle files containing the dumped AST
aadlASTcache = projectCache + os.sep + newHash + "_aadl_ast.pickle"
if not os.path.exists(aadlASTcache):
print("[DMT] No cached AADL model found for",
cachedModelExists = True
print("[DMT] Reusing cached AADL model for",
import pickle
if cachedModelExists:
astInfo = pickle.load(open(aadlASTcache, 'rb'), fix_imports=False)
import tempfile
f = tempfile.NamedTemporaryFile(delete=False)
astFile =
......@@ -158,6 +185,9 @@ of each SUBPROGRAM param.'''
if os.path.exists(astFile):
panic("AADL parsing failed. Aborting...")
astInfo = pickle.load(open(astFile, 'rb'), fix_imports=False)
if aadlASTcache:
pickle.dump(astInfo, open(aadlASTcache, 'wb'), fix_imports=False)
def FixMetaClasses(sp: ApLevelContainer) -> None:
def patchMe(o: Any) -> None:
......@@ -181,8 +211,6 @@ of each SUBPROGRAM param.'''
for cn in sp._connections:
import pickle
astInfo = pickle.load(open(astFile, 'rb'), fix_imports=False)
for k in ['g_processImplementations', 'g_apLevelContainers',
'g_signals', 'g_systems', 'g_subProgramImplementations',
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment