xref: /btstack/port/esp32/integrate_btstack.py (revision cb0081eb43d6408128e4dc08a5568347c287e0d2)
16ccd8248SMilanka Ringwald#!/usr/bin/env python3
29c7c30eeSMatthias Ringwald
39c7c30eeSMatthias Ringwald#
49c7c30eeSMatthias Ringwald# Add btstack component to esp-idf
59c7c30eeSMatthias Ringwald#
69c7c30eeSMatthias Ringwald
79c7c30eeSMatthias Ringwaldimport os
89c7c30eeSMatthias Ringwaldimport sys
99c7c30eeSMatthias Ringwaldimport shutil
109c7c30eeSMatthias Ringwaldimport create_examples
119c7c30eeSMatthias Ringwald
129c7c30eeSMatthias Ringwaldif not 'IDF_PATH' in os.environ:
139c7c30eeSMatthias Ringwald	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');
149c7c30eeSMatthias Ringwald	sys.exit(10)
159c7c30eeSMatthias Ringwald
169c7c30eeSMatthias RingwaldIDF_PATH=os.environ['IDF_PATH']
179c7c30eeSMatthias Ringwaldprint("IDF_PATH=%s" % IDF_PATH)
189c7c30eeSMatthias Ringwald
199c7c30eeSMatthias RingwaldIDF_COMPONENTS=IDF_PATH + "/components"
209c7c30eeSMatthias Ringwald
219c7c30eeSMatthias Ringwaldif not os.path.exists(IDF_COMPONENTS):
229c7c30eeSMatthias Ringwald	print("Error: No components folder at $IDF_PATH/components, please check IDF_PATH")
239c7c30eeSMatthias Ringwald	sys.exit(10)
249c7c30eeSMatthias Ringwald
259c7c30eeSMatthias RingwaldIDF_BTSTACK=IDF_COMPONENTS+"/btstack"
269c7c30eeSMatthias Ringwald
279c7c30eeSMatthias Ringwaldif os.path.exists(IDF_BTSTACK):
289c7c30eeSMatthias Ringwald	print("Deleting old BTstack component %s" % IDF_BTSTACK)
299c7c30eeSMatthias Ringwald	shutil.rmtree(IDF_BTSTACK)
309c7c30eeSMatthias Ringwald
319c7c30eeSMatthias Ringwald# get local dir
329c7c30eeSMatthias Ringwaldlocal_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
339c7c30eeSMatthias Ringwald
349c7c30eeSMatthias Ringwald# create components/btstack
359c7c30eeSMatthias Ringwaldprint("Creating BTstack component at %s" % IDF_COMPONENTS)
369c7c30eeSMatthias Ringwaldshutil.copytree(local_dir+'/components/btstack', IDF_BTSTACK)
379c7c30eeSMatthias Ringwald
389c7c30eeSMatthias Ringwalddirs_to_copy = [
399c7c30eeSMatthias Ringwald'src',
409c7c30eeSMatthias Ringwald'3rd-party/bluedroid',
419c7c30eeSMatthias Ringwald'3rd-party/hxcmod-player',
4286a50e77SMatthias Ringwald'3rd-party/lwip/dhcp-server',
43*cb0081ebSMatthias Ringwald'3rd-party/lc3-google',
44bc44e666SMatthias Ringwald'3rd-party/md5',
45826d4bceSMatthias Ringwald'3rd-party/micro-ecc',
466420389dSMatthias Ringwald'3rd-party/yxml',
479c7c30eeSMatthias Ringwald'platform/freertos',
489c7c30eeSMatthias Ringwald'platform/embedded',
4966871e79SMatthias Ringwald'platform/lwip',
509c7c30eeSMatthias Ringwald'tool'
519c7c30eeSMatthias Ringwald]
529c7c30eeSMatthias Ringwald
539c7c30eeSMatthias Ringwaldfor dir in dirs_to_copy:
549c7c30eeSMatthias Ringwald	print('- %s' % dir)
559c7c30eeSMatthias Ringwald	shutil.copytree(local_dir + '/../../' + dir, IDF_BTSTACK + '/' + dir)
569c7c30eeSMatthias Ringwald
57b35e5ee4SMatthias Ringwald# add hci dump stdout
58b35e5ee4SMatthias Ringwaldshutil.copy(local_dir+'/../../platform/embedded/hci_dump_embedded_stdout.c', IDF_BTSTACK)
59b35e5ee4SMatthias Ringwald
609c7c30eeSMatthias Ringwald# create example/btstack
61bb44f0f5SMatthias Ringwaldcreate_examples.create_examples(local_dir, '')
62