1#!/usr/bin/env python 2 3# 4# Add btstack component to esp-idf 5# 6 7import os 8import sys 9import shutil 10import create_examples 11 12if not 'IDF_PATH' in os.environ: 13 print('Error: IDF_PATH not defined. Please set IDF_PATH as described here:\nhttp://esp-idf.readthedocs.io/en/latest/get-started/index.html#get-started-get-esp-idf'); 14 sys.exit(10) 15 16IDF_PATH=os.environ['IDF_PATH'] 17print("IDF_PATH=%s" % IDF_PATH) 18 19IDF_COMPONENTS=IDF_PATH + "/components" 20 21if not os.path.exists(IDF_COMPONENTS): 22 print("Error: No components folder at $IDF_PATH/components, please check IDF_PATH") 23 sys.exit(10) 24 25IDF_BTSTACK=IDF_COMPONENTS+"/btstack" 26 27if os.path.exists(IDF_BTSTACK): 28 print("Deleting old BTstack component %s" % IDF_BTSTACK) 29 shutil.rmtree(IDF_BTSTACK) 30 31# get local dir 32local_dir = os.path.abspath(os.path.dirname(sys.argv[0])) 33 34# create components/btstack 35print("Creating BTstack component at %s" % IDF_COMPONENTS) 36shutil.copytree(local_dir+'/components/btstack', IDF_BTSTACK) 37 38dirs_to_copy = [ 39'src', 40'3rd-party/bluedroid', 41'3rd-party/hxcmod-player', 42'platform/freertos', 43'platform/embedded', 44'tool' 45] 46 47for dir in dirs_to_copy: 48 print('- %s' % dir) 49 shutil.copytree(local_dir + '/../../' + dir, IDF_BTSTACK + '/' + dir) 50 51# create example/btstack 52create_examples.create_examples(local_dir) 53