Skip to content

Commit

Permalink
Re-generate zap (which moves Clusters.matter to stay with zap files)
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Jan 14, 2022
1 parent c6fa556 commit e2d404d
Show file tree
Hide file tree
Showing 19 changed files with 16 additions and 7 deletions.
File renamed without changes.
23 changes: 16 additions & 7 deletions scripts/tools/zap_regen_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@
class ZAPGenerateTarget:
def __init__(self, zap_config, template=None, output_dir=None):
self.script = './scripts/tools/zap/generate.py'
self.output_dir = output_dir
self.zap_config = zap_config
self.zap_config = str(zap_config)
self.template = template

if output_dir:
# make sure we convert any os.PathLike object to string
self.output_dir = str(output_dir)
else:
self.output_dir = None

def generate(self):
"""Runs a ZAP generate command on the configured zap/template/outputs.
"""
Expand All @@ -52,6 +57,10 @@ def extractAnyGeneratedIDL(self):
"""Searches for Clusters.matter in the output directory and if found,
will move it to stay along with the zap file config
"""
if not self.output_dir:
# TODO: where do things get generated if no output dir?
# Assume here that IDL is not generated in such cases
return

idl_path = os.path.join(self.output_dir, "Clusters.matter")
if not os.path.exists(idl_path):
Expand All @@ -62,9 +71,10 @@ def extractAnyGeneratedIDL(self):
# We expect "something.zap" and don't handle corner cases of
# multiple extensions. This is to work with existing codebase only
raise Error("Unexpected input zap file %s" % self.zap_config)

os.rename(idl_path, target_path)


def checkPythonVersion():
if sys.version_info[0] < 3:
print('Must use Python 3. Current version is ' +
Expand Down Expand Up @@ -96,10 +106,9 @@ def getGlobalTemplatesTargets():
os.makedirs(output_dir)
template = 'examples/placeholder/templates/templates.json'

targets.append(ZAPGenerateTarget(
str(filepath), output_dir=output_dir))
targets.append(ZAPGenerateTarget(filepath, output_dir=output_dir))
targets.append(
ZAPGenerateTarget(str(filepath), output_dir=output_dir, template=template))
ZAPGenerateTarget(filepath, output_dir=output_dir, template=template))
continue

logging.info("Found example %s (via %s)" %
Expand All @@ -112,7 +121,7 @@ def getGlobalTemplatesTargets():
if not os.path.exists(output_dir):
os.makedirs(output_dir)

targets.append(ZAPGenerateTarget(str(filepath), output_dir=output_dir))
targets.append(ZAPGenerateTarget(filepath, output_dir=output_dir))

targets.append(ZAPGenerateTarget(
'./src/controller/data_model/controller-clusters.zap',
Expand Down

0 comments on commit e2d404d

Please sign in to comment.