• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# Copyright (c) 2021 Huawei Device Co., Ltd.
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17set -e
18
19DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
20TOP=$(realpath $DIR/../../..)
21CLANG_DIR=$TOP/prebuilts/clang/ohos/linux-x86_64/llvm/bin
22GN_DIR=$TOP/prebuilts/build-tools/linux-x86/bin
23
24export PATH=$CLANG_DIR:$GN_DIR:$PATH
25echo "formatting C/C++ code ..."
26find $@ -name '*.h' -o -name '*.cpp' | xargs dos2unix
27find $@ -name '*.h' -o -name '*.cpp' | xargs chmod -x
28find $@ -name '*.h' -o -name '*.cpp' | xargs clang-format --verbose -i
29
30echo "formatting GN code ..."
31find $@ -name '*.gn' -o -name '*.gni' | xargs gn format
32