Loading system/gd/cert/bluetooth_packets_python3_setup.py 0 → 100644 +75 −0 Original line number Diff line number Diff line #!/usr/bin/env python3 # # Copyright 2019 - The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Usage: # 1. Run envsetup and lunch first in an Android checkout # 2. Make target bluetooth_packets_python3 that will generate C++ sources for the # Extension # 3. Build only: # python3 bluetooth_packets_python3_setup.py build_ext # Then Find the .so file in build/lib.linux-x86_64-3.X # 4. Install: # python3 bluetooth_packets_python3_setup.py install --user import os import glob from setuptools import setup, Extension ANDROID_BUILD_TOP = os.getenv("ANDROID_BUILD_TOP") PYBIND11_INCLUDE_DIR = os.path.join(ANDROID_BUILD_TOP, "external/python/pybind11/include") GD_DIR = os.path.join(ANDROID_BUILD_TOP, "packages/modules/Bluetooth/system/gd") BT_PACKETS_GEN_DIR = os.path.join(ANDROID_BUILD_TOP, "out/soong/.intermediates/packages/modules/Bluetooth/system/gd/BluetoothGeneratedPackets_h/gen") BT_PACKETS_PY3_GEN_DIR = os.path.join(ANDROID_BUILD_TOP, "out/soong/.intermediates/packages/modules/Bluetooth/system/gd/BluetoothGeneratedPackets_python3_cc/gen") BT_PACKETS_BASE_SRCS = [ os.path.join(GD_DIR, "l2cap/fcs.cc"), os.path.join(GD_DIR, "packet/bit_inserter.cc"), os.path.join(GD_DIR, "packet/byte_inserter.cc"), os.path.join(GD_DIR, "packet/byte_observer.cc"), os.path.join(GD_DIR, "packet/iterator.cc"), os.path.join(GD_DIR, "packet/fragmenting_inserter.cc"), os.path.join(GD_DIR, "packet/packet_view.cc"), os.path.join(GD_DIR, "packet/raw_builder.cc"), os.path.join(GD_DIR, "packet/view.cc"), ] BT_PACKETS_PY3_SRCs = \ [os.path.join(GD_DIR, "packet/python3_module.cc")] \ + glob.glob(os.path.join(BT_PACKETS_PY3_GEN_DIR, "hci", "*.cc")) \ + glob.glob(os.path.join(BT_PACKETS_PY3_GEN_DIR, "l2cap", "*.cc")) \ + glob.glob(os.path.join(BT_PACKETS_PY3_GEN_DIR, "security", "*.cc")) bluetooth_packets_python3_module = Extension('bluetooth_packets_python3', sources=BT_PACKETS_BASE_SRCS + BT_PACKETS_PY3_SRCs, include_dirs=[GD_DIR, BT_PACKETS_GEN_DIR, BT_PACKETS_PY3_GEN_DIR, PYBIND11_INCLUDE_DIR], extra_compile_args=['-std=c++17'] ) setup(name='bluetooth_packets_python3', version='1.0', author="Android Open Source Project", description="""Bluetooth Packet Library""", ext_modules=[bluetooth_packets_python3_module], py_modules=["bluetooth_packets_python3"], ) system/gd/cert/run_cert.sh +3 −1 Original line number Diff line number Diff line #! /bin/bash act.py -c $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/host_only_config.json -tf $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/cert_testcases -tp $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd # For bluetooth_packets_python3 export PYTHONPATH=$PYTHONPATH:$ANDROID_BUILD_TOP/out/host/linux-x86/lib64 python3.8 `which act.py` -c $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/host_only_config.json -tf $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/cert_testcases -tp $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd system/gd/cert/run_device_cert.sh +3 −1 Original line number Diff line number Diff line #! /bin/bash act.py -c $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/android_devices_config.json -tf $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/cert_testcases -tp $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd # For bluetooth_packets_python3 export PYTHONPATH=$PYTHONPATH:$ANDROID_BUILD_TOP/out/host/linux-x86/lib64 python3.8 `which act.py` -c $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/android_devices_config.json -tf $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/cert_testcases -tp $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd system/gd/cert/set_up_acts.sh +38 −7 Original line number Diff line number Diff line Loading @@ -46,9 +46,15 @@ function SetUpAndroidBuild { popd } function SetupPython3 { echo "Setting up python3" sudo apt-get install python3-dev function SetupPython38 { echo "Setting up python3.8" sudo apt-get install python3.8-dev } function CompileBluetoothPacketsPython3 { echo "bluetooth_packets_python3 is not found, compiling" croot make -j bluetooth_packets_python3 } if [[ "${BASH_SOURCE[0]}" == "${0}" ]] ; then Loading @@ -60,16 +66,41 @@ if [[ -z "$ANDROID_BUILD_TOP" ]] ; then SetUpAndroidBuild fi ## Check python3 is installed properly dpkg -l python3-dev > /dev/null 2>&1 ## Check python3.8 is installed properly ## Need Python 3.8 because bluetooth_packets_python3 is compiled against ## Python 3.8 headers dpkg -l python3.8-dev > /dev/null 2>&1 if [[ $? -ne 0 ]] ; then SetupPython38 fi ## Check bluetooth_packets_python3 is compiled succssfully export PYTHONPATH=$PYTHONPATH:$ANDROID_BUILD_TOP/out/host/linux-x86/lib64 python3.8 -c " import bluetooth_packets_python3 as bp3 bp3.BaseStruct " if [[ $? -ne 0 ]] ; then SetupPython3 pushd . CompileBluetoothPacketsPython3 popd python3.8 -c " import bluetooth_packets_python3 as bp3 bp3.BaseStruct " if [[ $? -ne 0 ]] ; then echo "Setup failed as bluetooth_packets_python3 cannot be found" else echo "Found bluetooth_packets_python3 after compilation" fi else echo "Found bluetooth_packets_python3" fi ## All is good now so go ahead with the acts setup pushd . cd $ANDROID_BUILD_TOP/tools/test/connectivity/acts/framework/ sudo python3 setup.py develop sudo python3.8 setup.py develop if [[ $? -eq 0 ]] ; then echo "cert setup complete" else Loading Loading
system/gd/cert/bluetooth_packets_python3_setup.py 0 → 100644 +75 −0 Original line number Diff line number Diff line #!/usr/bin/env python3 # # Copyright 2019 - The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Usage: # 1. Run envsetup and lunch first in an Android checkout # 2. Make target bluetooth_packets_python3 that will generate C++ sources for the # Extension # 3. Build only: # python3 bluetooth_packets_python3_setup.py build_ext # Then Find the .so file in build/lib.linux-x86_64-3.X # 4. Install: # python3 bluetooth_packets_python3_setup.py install --user import os import glob from setuptools import setup, Extension ANDROID_BUILD_TOP = os.getenv("ANDROID_BUILD_TOP") PYBIND11_INCLUDE_DIR = os.path.join(ANDROID_BUILD_TOP, "external/python/pybind11/include") GD_DIR = os.path.join(ANDROID_BUILD_TOP, "packages/modules/Bluetooth/system/gd") BT_PACKETS_GEN_DIR = os.path.join(ANDROID_BUILD_TOP, "out/soong/.intermediates/packages/modules/Bluetooth/system/gd/BluetoothGeneratedPackets_h/gen") BT_PACKETS_PY3_GEN_DIR = os.path.join(ANDROID_BUILD_TOP, "out/soong/.intermediates/packages/modules/Bluetooth/system/gd/BluetoothGeneratedPackets_python3_cc/gen") BT_PACKETS_BASE_SRCS = [ os.path.join(GD_DIR, "l2cap/fcs.cc"), os.path.join(GD_DIR, "packet/bit_inserter.cc"), os.path.join(GD_DIR, "packet/byte_inserter.cc"), os.path.join(GD_DIR, "packet/byte_observer.cc"), os.path.join(GD_DIR, "packet/iterator.cc"), os.path.join(GD_DIR, "packet/fragmenting_inserter.cc"), os.path.join(GD_DIR, "packet/packet_view.cc"), os.path.join(GD_DIR, "packet/raw_builder.cc"), os.path.join(GD_DIR, "packet/view.cc"), ] BT_PACKETS_PY3_SRCs = \ [os.path.join(GD_DIR, "packet/python3_module.cc")] \ + glob.glob(os.path.join(BT_PACKETS_PY3_GEN_DIR, "hci", "*.cc")) \ + glob.glob(os.path.join(BT_PACKETS_PY3_GEN_DIR, "l2cap", "*.cc")) \ + glob.glob(os.path.join(BT_PACKETS_PY3_GEN_DIR, "security", "*.cc")) bluetooth_packets_python3_module = Extension('bluetooth_packets_python3', sources=BT_PACKETS_BASE_SRCS + BT_PACKETS_PY3_SRCs, include_dirs=[GD_DIR, BT_PACKETS_GEN_DIR, BT_PACKETS_PY3_GEN_DIR, PYBIND11_INCLUDE_DIR], extra_compile_args=['-std=c++17'] ) setup(name='bluetooth_packets_python3', version='1.0', author="Android Open Source Project", description="""Bluetooth Packet Library""", ext_modules=[bluetooth_packets_python3_module], py_modules=["bluetooth_packets_python3"], )
system/gd/cert/run_cert.sh +3 −1 Original line number Diff line number Diff line #! /bin/bash act.py -c $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/host_only_config.json -tf $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/cert_testcases -tp $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd # For bluetooth_packets_python3 export PYTHONPATH=$PYTHONPATH:$ANDROID_BUILD_TOP/out/host/linux-x86/lib64 python3.8 `which act.py` -c $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/host_only_config.json -tf $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/cert_testcases -tp $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd
system/gd/cert/run_device_cert.sh +3 −1 Original line number Diff line number Diff line #! /bin/bash act.py -c $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/android_devices_config.json -tf $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/cert_testcases -tp $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd # For bluetooth_packets_python3 export PYTHONPATH=$PYTHONPATH:$ANDROID_BUILD_TOP/out/host/linux-x86/lib64 python3.8 `which act.py` -c $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/android_devices_config.json -tf $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/cert_testcases -tp $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd
system/gd/cert/set_up_acts.sh +38 −7 Original line number Diff line number Diff line Loading @@ -46,9 +46,15 @@ function SetUpAndroidBuild { popd } function SetupPython3 { echo "Setting up python3" sudo apt-get install python3-dev function SetupPython38 { echo "Setting up python3.8" sudo apt-get install python3.8-dev } function CompileBluetoothPacketsPython3 { echo "bluetooth_packets_python3 is not found, compiling" croot make -j bluetooth_packets_python3 } if [[ "${BASH_SOURCE[0]}" == "${0}" ]] ; then Loading @@ -60,16 +66,41 @@ if [[ -z "$ANDROID_BUILD_TOP" ]] ; then SetUpAndroidBuild fi ## Check python3 is installed properly dpkg -l python3-dev > /dev/null 2>&1 ## Check python3.8 is installed properly ## Need Python 3.8 because bluetooth_packets_python3 is compiled against ## Python 3.8 headers dpkg -l python3.8-dev > /dev/null 2>&1 if [[ $? -ne 0 ]] ; then SetupPython38 fi ## Check bluetooth_packets_python3 is compiled succssfully export PYTHONPATH=$PYTHONPATH:$ANDROID_BUILD_TOP/out/host/linux-x86/lib64 python3.8 -c " import bluetooth_packets_python3 as bp3 bp3.BaseStruct " if [[ $? -ne 0 ]] ; then SetupPython3 pushd . CompileBluetoothPacketsPython3 popd python3.8 -c " import bluetooth_packets_python3 as bp3 bp3.BaseStruct " if [[ $? -ne 0 ]] ; then echo "Setup failed as bluetooth_packets_python3 cannot be found" else echo "Found bluetooth_packets_python3 after compilation" fi else echo "Found bluetooth_packets_python3" fi ## All is good now so go ahead with the acts setup pushd . cd $ANDROID_BUILD_TOP/tools/test/connectivity/acts/framework/ sudo python3 setup.py develop sudo python3.8 setup.py develop if [[ $? -eq 0 ]] ; then echo "cert setup complete" else Loading