1# Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14#!/bin/bash 15set -e 16 17OUT_DIR="$1" 18DEST_PATH="$2" 19PACKTOOL_PATH=${OUT_DIR}/kh_packtool 20echo "=========>>kh pre build:DEST_PATH=${DEST_PATH},PACKTOOL_PATH=${PACKTOOL_PATH}" >&2 21 22if [ ! -f ${DEST_PATH}/gd32_uart_bootloader.bin ]; then 23 echo "=========>>kh pre build:${DEST_PATH}/gd32_uart_bootloader.bin does not exist." >&2 24 if [ -d ${PACKTOOL_PATH} ]; then 25 rm -rf ${PACKTOOL_PATH} 26 fi 27 mkdir -p ${PACKTOOL_PATH} 28 cd ${PACKTOOL_PATH} 29 git clone https://gitee.com/download_tools/khdvk_450a.git 30 cp -af khdvk_450a/bootloader/gd32_uart_bootloader.bin ${DEST_PATH} 31 cd - 32fi 33 34if [ ! -f ${OUT_DIR}/mklfs ]; then 35 echo "=========>>kh pre build:${OUT_DIR}/mklfs does not exist." >&2 36 cd ${DEST_PATH}/../../third_party/ 37 # gcc -std=gnu99 -Os -Wall -Ilfs -I. -D__NO_INLINE__ -I../../../../third_party/littlefs -o mklfs mklfs.c ../../../../third_party/littlefs/lfs.c ../../../../third_party/littlefs/lfs_util.c 38 # mv ${DEST_PATH}/../../third_party/mklfs ${OUT_DIR} 39 ../../../../prebuilts/build-tools/linux-x86/bin/gn gen out && ../../../../prebuilts/build-tools/linux-x86/bin/ninja -C out && mv out/mklfs ${OUT_DIR} && rm -rf out 40 cd - 41fi