xref: /btstack/port/esp32/integrate_btstack.py (revision cc528b9d66cd63ff4662ca3aba554b3ddf559fb2)
1#!/usr/bin/env python3
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'3rd-party/lwip/dhcp-server',
43'3rd-party/lc3-google',
44'3rd-party/md5',
45'3rd-party/micro-ecc',
46'3rd-party/yxml',
47'platform/freertos',
48'platform/lwip',
49'tool'
50]
51
52for dir in dirs_to_copy:
53	print('- %s' % dir)
54	shutil.copytree(local_dir + '/../../' + dir, IDF_BTSTACK + '/' + dir)
55
56# manually prepare platform/embedded
57print('- platform/embedded')
58platform_embedded_path = IDF_BTSTACK + '/platform/embedded'
59os.makedirs(platform_embedded_path)
60platform_embedded_files_to_copy = [
61	'hal_time_ms.h',
62	'hal_uart_dma.h',
63	'hci_dump_embedded_stdout.h',
64	'hci_dump_embedded_stdout.c',
65]
66for file in platform_embedded_files_to_copy:
67	shutil.copy(local_dir+'/../../platform/embedded/'+file, platform_embedded_path)
68
69# create example/btstack
70create_examples.create_examples(local_dir, '')
71