9 _LOG = logging.getLogger(__name__)
11 ROOT = 'examples/all-clusters-app/esp32'
14 """Runs specified commands via an executor that activates the CHIP build environment."""
18 script_path = os.path.dirname(os.path.realpath(__file__))
19 self.chip_root = os.path.realpath(os.path.join(script_path, '..', '..'))
21 logging.info("CHIP Root directory: %s" % self.chip_root)
23 self.run_cmd = os.path.join(self.chip_root, "scripts", "run_in_build_env.sh")
24 logging.info("Executing via: %s" % self.run_cmd)
27 def execute(self, command):
28 os.chdir(self.chip_root)
29 subprocess.call([self.run_cmd, 'source "%s/%s/idf.sh"; idf %s' % (self.chip_root, ROOT, command)])
33 """Main task if executed standalone."""
34 parser = argparse.ArgumentParser(description='Build all-clusters-app example')
38 type=lambda x: getattr(logging, x),
39 help='Configure the logging level.')
43 choices=['m5stack', 'devkit'],
45 args = parser.parse_args()
47 # Ensures somewhat pretty logging of what is going on
50 format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
56 logging.info('Building a clear configuration')
57 sdkconfig = 'sdkconfig_%s.defaults' % args.clear_config
59 curr_sdkconfig = os.path.join(ROOT, 'sdkconfig')
60 if os.path.exists(curr_sdkconfig):
61 os.remove(curr_sdkconfig)
63 e.execute('SDKCONFIG_DEFAULTS="{sdkname}" make -j{cpus} -C {example_root} defconfig'.format(
64 sdkname=sdkconfig, cpus=os.cpu_count(), example_root = ROOT
68 logging.info('Compiling')
69 e.execute('make -j{cpus} -C {example_root}'.format(cpus=os.cpu_count(), example_root=ROOT))
72 if __name__ == '__main__':
73 # execute only if run as a script