• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright 2022 The Android Open Source Project
3#
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# Formats source files according to Google's style guide.
17
18REPO=$(dirname "$0")/../../..
19OS=$(uname | tr '[:upper:]' '[:lower:]') # The possible values are "linux" and "darwin".
20
21# Run clang-format.
22find $REPO/tools/netsim/src \( -name '*.cc' -o -name '*.h' -o -name '*.proto' \) \
23  -exec clang-format -i {} \;
24
25# Format rust.
26find $REPO/tools/netsim/rust \( \
27  -path $REPO/tools/netsim/rust/target -prune -false \
28  -o -name '*.rs' \) \
29  -exec $REPO/prebuilts/rust/$OS-x86/stable/rustfmt -v {} \;
30
31# Format TypeScript.
32find $REPO/tools/netsim/ui/ts \( -name '*.ts' \) \
33  -exec clang-format -i {} \;
34
35# Run cmake-format.
36find $REPO/tools/netsim \( -name 'CMakeLists.txt' \) \
37  -exec cmake-format -i {} \;
38find $REPO/tools/netsim/cmake \( -name "*.cmake" \) \
39  -exec cmake-format -i {} \;
40
41# Run bpfmt to format Android.bp if in aosp_master repo.
42BPFMT=$REPO/prebuilts/build-tools/$OS-x86/bin/bpfmt
43if [ -f "$BPFMT" ]; then
44    $BPFMT -w $REPO/tools/netsim/Android.bp
45    $BPFMT -w $REPO/tools/netsim/ui/Android.bp
46    $BPFMT -w $REPO/tools/netsim/src/proto/Android.bp
47fi
48