1fb726d48Sopenharmony_ci#!/bin/bash 2fb726d48Sopenharmony_ci# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. 3fb726d48Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 4fb726d48Sopenharmony_ci# you may not use this file except in compliance with the License. 5fb726d48Sopenharmony_ci# You may obtain a copy of the License at 6fb726d48Sopenharmony_ci# 7fb726d48Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 8fb726d48Sopenharmony_ci# 9fb726d48Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 10fb726d48Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 11fb726d48Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12fb726d48Sopenharmony_ci# See the License for the specific language governing permissions and 13fb726d48Sopenharmony_ci# limitations under the License. 14fb726d48Sopenharmony_ciset -e 15fb726d48Sopenharmony_citarget_os="linux" 16fb726d48Sopenharmony_cign="gn" 17fb726d48Sopenharmony_cicase "$OSTYPE" in 18fb726d48Sopenharmony_ci solaris*) echo "SOLARIS" ;; 19fb726d48Sopenharmony_ci darwin*) target_os="macx" ;; 20fb726d48Sopenharmony_ci linux*) target_os="linux" ;; 21fb726d48Sopenharmony_ci bsd*) echo "is bsd os" ;; 22fb726d48Sopenharmony_ci msys*) target_os="windows" gn="gn.exe" ;; 23fb726d48Sopenharmony_ci *) echo "unknown: $OSTYPE" ;; 24fb726d48Sopenharmony_ciesac 25fb726d48Sopenharmony_ciPRJ_ROOT_DIR=$(readlink -f -- "$(dirname $0)/") 26fb726d48Sopenharmony_cicd ${PRJ_ROOT_DIR} 27fb726d48Sopenharmony_ciFORMAT_DIR_LIST=( 28fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/build" 29fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/gn" 30fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/sdk" 31fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/src" 32fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/test" 33fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/trace_extend/src" 34fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/trace_extend/test" 35fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/prebuilts/fuzz" 36fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/prebuilts/linux" 37fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/prebuilts/macx" 38fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/prebuilts/patch_bounds_checking_function" 39fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/prebuilts/patch_googletest" 40fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/prebuilts/patch_hiperf" 41fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/prebuilts/patch_libunwind" 42fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/prebuilts/patch_perf_event" 43fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/prebuilts/patch_protobuf" 44fb726d48Sopenharmony_ci "${PRJ_ROOT_DIR}/prebuilts/patch_sqlite" 45fb726d48Sopenharmony_ci) 46fb726d48Sopenharmony_ciecho "formatting code ..." 47fb726d48Sopenharmony_cifor d in ${FORMAT_DIR_LIST[@]}; do 48fb726d48Sopenharmony_ci for f in $(find $d -type f -not -name '*sql.c' -regex '.*\.\(cpp\|hpp\|c\|h\)'); do 49fb726d48Sopenharmony_ci dos2unix $f 50fb726d48Sopenharmony_ci chmod -x $f 51fb726d48Sopenharmony_ci clang-format --verbose -i $f 52fb726d48Sopenharmony_ci done 53fb726d48Sopenharmony_ci for f in $(find $d -type f -not -name '*sql.c' -regex '.*\.\(gn\|gni\)'); do 54fb726d48Sopenharmony_ci ./prebuilts/$target_os/gn format $f 55fb726d48Sopenharmony_ci done 56fb726d48Sopenharmony_cidone 57fb726d48Sopenharmony_ciecho "formatting code over" 58