|
|
#
|
|
|
# Copyright (C) 2011 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.
|
|
|
#
|
|
|
function set_wifi_bt_env()
|
|
|
{
|
|
|
local wifibt_vendor=""
|
|
|
local wifibt_device=""
|
|
|
local DEVELOPMENT_DIR=vendor/huanglong/development
|
|
|
local need_copy=$1
|
|
|
local git_args=""
|
|
|
|
|
|
if [ ! -d $(gettop)/$DEVELOPMENT_DIR/thirdparty/wifi_bt ] && [[ $need_copy != "copy" ]]; then
|
|
|
echo "$DEVELOPMENT_DIR folder is not exist, skip copy wifi_bt source code"
|
|
|
return
|
|
|
fi
|
|
|
wifibt_mk=$(gettop)/vendor/thirdparty/wifi_bt/config/wifi_bt.mk
|
|
|
if [[ ! -f "${wifibt_mk}" ]]; then return; fi
|
|
|
wificfgfile=$(gettop)/vendor/thirdparty/wifi_bt/config/wifi_bt_cfg.mk
|
|
|
module_device=$(grep "^BOARD_WIFI_BLUETOOTH_DEVICE_.*y$" $wificfgfile |awk '{print $1}'|sort|uniq)
|
|
|
# 比较apply_wifi_bt_patch.sh和apply_wifi_bt_patch.sh.tamp,如果apply_wifi_bt_patch.sh的修改时间较新,
|
|
|
# 说明该脚本有被修改,sdk版本号有可能被更新,清理旧sdk代码。
|
|
|
if [[ -z $(ls -lt $(gettop)/vendor/thirdparty/wifi_bt/drv_script/apply_wifi_bt_patch.sh* |head -n 1|sed -n '/stamp/p') ]]; then
|
|
|
[ ! -d $(gettop)/$DEVELOPMENT_DIR/thirdparty/wifi_bt ] && git_args="--exclude=drv_script/"
|
|
|
cd $(gettop)/vendor/thirdparty/wifi_bt && git clean -dfx $git_args 1>/dev/null 2>&1 || \
|
|
|
echo "not a git repository ,please manually clear the source code directory"
|
|
|
cd $(gettop)
|
|
|
need_copy="copy"
|
|
|
echo "need update sdk version."
|
|
|
fi
|
|
|
if [ -f "$(gettop)/set_wifi_bt_env.log" ]; then
|
|
|
rm $(gettop)/set_wifi_bt_env.log
|
|
|
fi
|
|
|
for m in $module_device
|
|
|
do
|
|
|
case "$m" in
|
|
|
BOARD_WIFI_BLUETOOTH_DEVICE_RTL8723DU)
|
|
|
wifibt_vendor="realtek"
|
|
|
wifibt_device="usb_rtl8723du";;
|
|
|
BOARD_WIFI_BLUETOOTH_DEVICE_MT7668U)
|
|
|
wifibt_vendor="mtk"
|
|
|
wifibt_device="usb_mt7668u";;
|
|
|
BOARD_WIFI_BLUETOOTH_DEVICE_RTL8822BEH)
|
|
|
wifibt_vendor="realtek"
|
|
|
wifibt_device="pcie_rtl8822beh";;
|
|
|
BOARD_WIFI_BLUETOOTH_DEVICE_RTL8822CS)
|
|
|
wifibt_vendor="realtek"
|
|
|
wifibt_device="sdio_rtl8822cs";;
|
|
|
BOARD_WIFI_BLUETOOTH_DEVICE_RTL8822BS)
|
|
|
wifibt_vendor="realtek"
|
|
|
wifibt_device="sdio_rtl8822bs";;
|
|
|
BOARD_WIFI_BLUETOOTH_DEVICE_RTL8822CU)
|
|
|
wifibt_vendor="realtek"
|
|
|
wifibt_device="usb_rtl8822cu";;
|
|
|
*)
|
|
|
echo "skip copy, unkown module:$m"
|
|
|
continue
|
|
|
esac
|
|
|
local file_num=$(find $(gettop)/vendor/thirdparty/wifi_bt/wifi/drv/$wifibt_device/ -type f | wc -l)
|
|
|
# source时,如果模组驱动编译目录里的文件数大于等于10(所有模组在没有进行过代码
|
|
|
# 拷贝时编译目录的文件数小于10),认为有拷贝过源码,不再进行拷贝。手动带参执行脚本,必定拷贝。
|
|
|
if [ $file_num -lt 10 ] || [[ $need_copy == "copy" ]]; then
|
|
|
echo "$m=y, need copy $wifibt_vendor $wifibt_device"
|
|
|
if [[ -d $(gettop)/$DEVELOPMENT_DIR/thirdparty/wifi_bt ]]; then
|
|
|
$(gettop)/vendor/thirdparty/wifi_bt/drv_script/copy_source_file.sh $wifibt_vendor $wifibt_device >>$(gettop)/set_wifi_bt_env.log
|
|
|
$(gettop)/vendor/thirdparty/wifi_bt/drv_script/apply_wifi_bt_patch.sh $wifibt_device >>$(gettop)/set_wifi_bt_env.log
|
|
|
[ $? -ne 0 ] && echo "copy $m wifi_bt source error , please $(gettop)/set_wifi_bt_env.log for detail." && return
|
|
|
else
|
|
|
$(gettop)/vendor/thirdparty/wifi_bt/drv_script/apply_wifi_bt_patch.sh $wifibt_device
|
|
|
[ $? -ne 0 ] && echo "copy $m wifi_bt source error." && return
|
|
|
fi
|
|
|
else
|
|
|
echo "$m source code has been copied."
|
|
|
fi
|
|
|
done
|
|
|
realtek_hostapd_mk=$(gettop)/vendor/thirdparty/wifi_bt/wifi/wpa_supplicant/realtek/hostapd/Android.mk
|
|
|
realtek_wpa_supplicant_mk=$(gettop)/vendor/thirdparty/wifi_bt/wifi/wpa_supplicant/realtek/wpa_supplicant/Android.mk
|
|
|
realtek_wpa_supplicant_c=$(gettop)/vendor/thirdparty/wifi_bt/wifi/wpa_supplicant/realtek/wpa_supplicant/src/common/wpa_ctrl.c
|
|
|
if [[ -f "${realtek_hostapd_mk}" ]]; then cp -f $(gettop)/vendor/thirdparty/wifi_bt/config/realtek/hostapd/Android.mk.bak ${realtek_hostapd_mk}; fi
|
|
|
if [[ -f "${realtek_wpa_supplicant_mk}" ]]; then cp -f $(gettop)/vendor/thirdparty/wifi_bt/config/realtek/wpa_supplicant/Android.mk.bak ${realtek_wpa_supplicant_mk}; fi
|
|
|
if [[ -f "${realtek_wpa_supplicant_c}" ]]; then cp -f $(gettop)/vendor/thirdparty/wifi_bt/config/realtek/wpa_supplicant/wpa_ctrl.c.bak ${realtek_wpa_supplicant_c}; fi
|
|
|
# 创建一个标识文件,在下次拷贝源码时如果apply_wifi_bt_patch.sh比apply_wifi_bt_patch.sh.stamp新,
|
|
|
# 则说明apply_wifi_bt_patch.sh有被修改,可能存在版本更新,然后去清理旧版本代码。
|
|
|
touch $(gettop)/vendor/thirdparty/wifi_bt/drv_script/apply_wifi_bt_patch.sh.stamp
|
|
|
if [ -f "$(gettop)/set_wifi_bt_env.log" ]; then
|
|
|
echo "copy wifi_bt source done, please $(gettop)/set_wifi_bt_env.log for detail."
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
set_wifi_bt_env $1
|