esp32: re-implement integrate_btstack in python as rsync is missing in prebuild esp-idf windows toolchain

This commit is contained in:
Matthias Ringwald 2017-10-09 13:56:01 +02:00
parent 3d244bfa4d
commit 9c7c30eeba
4 changed files with 115 additions and 92 deletions

View File

@ -12,9 +12,11 @@ Status: Basic port incl. all examples. BTstack runs on dedicated FreeRTOS thread
In port/esp32, run
./integrate_btstack.sh
./integrate_btstack.py
The script will copy parts of the BTstack tree into the ESP-IDF as $IDF_PATH/components/btstack and then create project folders for all examples. Each example project folder, e.g. port/esp32/examples/spp_and_le_counter, contains a Makefile. Please run the command again after updating the BTstack tree to also update the copy in the ESP-IDF.
The script will copy parts of the BTstack tree into the ESP-IDF as $IDF_PATH/components/btstack and then create project folders for all examples.
Each example project folder, e.g. port/esp32/examples/spp_and_le_counter, contains a Makefile. Please run the command again after updating the BTstack tree (e.g. by git pull) to also update the copy in the ESP-IDF.
To compile an example, run:

View File

@ -31,9 +31,7 @@ EXAMPLE.h: $(COMPONENT_PATH)/EXAMPLE.gatt
COMPONENT_EXTRA_CLEAN = EXAMPLE.h
'''
# get script path
script_path = os.path.abspath(os.path.dirname(sys.argv[0]))
def create_examples(script_path):
# path to examples
examples_embedded = script_path + "/../../example/"
@ -99,3 +97,10 @@ for file in os.listdir(examples_embedded):
print("- %s including GATT DB compilation rules" % example)
else:
print("- %s" % example)
if __name__ == '__main__':
# get script path
script_path = os.path.abspath(os.path.dirname(sys.argv[0]))
create_examples(script_path)

52
port/esp32/integrate_btstack.py Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env python
#
# Add btstack component to esp-idf
#
import os
import sys
import shutil
import create_examples
if not 'IDF_PATH' in os.environ:
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');
sys.exit(10)
IDF_PATH=os.environ['IDF_PATH']
print("IDF_PATH=%s" % IDF_PATH)
IDF_COMPONENTS=IDF_PATH + "/components"
if not os.path.exists(IDF_COMPONENTS):
print("Error: No components folder at $IDF_PATH/components, please check IDF_PATH")
sys.exit(10)
IDF_BTSTACK=IDF_COMPONENTS+"/btstack"
if os.path.exists(IDF_BTSTACK):
print("Deleting old BTstack component %s" % IDF_BTSTACK)
shutil.rmtree(IDF_BTSTACK)
# get local dir
local_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
# create components/btstack
print("Creating BTstack component at %s" % IDF_COMPONENTS)
shutil.copytree(local_dir+'/components/btstack', IDF_BTSTACK)
dirs_to_copy = [
'src',
'3rd-party/bluedroid',
'3rd-party/hxcmod-player',
'platform/freertos',
'platform/embedded',
'tool'
]
for dir in dirs_to_copy:
print('- %s' % dir)
shutil.copytree(local_dir + '/../../' + dir, IDF_BTSTACK + '/' + dir)
# create example/btstack
create_examples.create_examples(local_dir)

View File

@ -1,36 +0,0 @@
#/bin/sh
# check esp-idf path
if [ ! -f "$IDF_PATH/README.md" ]; then
echo "IDF_PATH not set, please follow esp-idf installation instructions"
echo "http://esp-idf.readthedocs.io/en/latest/get-started/index.html#setup-path-to-esp-idf"
exit 10
fi
echo "Integrating BTstack into esp-idf at $IDF_PATH"
echo "Adding component/btstack"
# create subsys/btstack
rsync -a components/btstack ${IDF_PATH}/components
# sync sources
rsync -a ../../src ${IDF_PATH}/components/btstack
# sync bludroid
rsync -a ../../3rd-party/bluedroid ${IDF_PATH}/components/btstack/3rd-party
# sync hxcmod player
rsync -a ../../3rd-party/hxcmod-player ${IDF_PATH}/components/btstack/3rd-party
# sync freertos support
rsync -a ../../platform/freertos ${IDF_PATH}/components/btstack/platform
# sync embedded run loop
rsync -a ../../platform/embedded ${IDF_PATH}/components/btstack/platform
# sync tools - used to access compile_gatt.py
rsync -a ../../tool ${IDF_PATH}/components/btstack
# create samples/btstack
./create_examples.py