blob: d32b3fa328b9c2770a55368797fb77df13f0b7ea [file] [log] [blame]
#!/usr/bin/env python3
#
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import os
from pathlib import Path
import sys
import subprocess
CHIP_ROOT_DIR = os.path.realpath(
os.path.join(os.path.dirname(__file__), '../..'))
def checkPythonVersion():
if sys.version_info[0] < 3:
print('Must use Python 3. Current version is ' +
str(sys.version_info[0]))
exit(1)
zapFilesToSkip = [
# examples/chef/sample_app_util/test_files/sample_zap_file.zap is
# not a real .zap file; it's input to generating .zap files. So
# the path to zcl.json in it is just wrong, and we should skip it.
"examples/chef/sample_app_util/test_files/sample_zap_file.zap",
]
def getTargets():
targets = []
targets.extend([[str(filepath)]
for filepath in Path('./examples').rglob('*.zap')
if str(filepath) not in zapFilesToSkip])
targets.extend([[str(filepath)]
for filepath in Path('./src/darwin').rglob('*.zap')
if str(filepath) not in zapFilesToSkip])
targets.extend([[str(filepath)] for filepath in Path(
'./src/controller/data_model').rglob('*.zap')
if str(filepath) not in zapFilesToSkip])
return targets
def main():
checkPythonVersion()
os.chdir(CHIP_ROOT_DIR)
targets = getTargets()
for target in targets:
subprocess.check_call(['./scripts/tools/zap/convert.py'] + target)
if __name__ == '__main__':
main()