• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (c) 2021 Huawei Device Co., Ltd.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14set -e
15protoc='protoc'
16proto_dir='.'
17protoreader_plugin='protoreader_plugin'
18case "$OSTYPE" in
19  msys*)    out='../../out/windows' protoreader_plugin='protoreader_plugin.exe' protoc='protoc.exe' proto_dir=$( cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) ;;
20  darwin*)  out='../../out/macx' proto_dir=$( cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) ;;
21  linux*)   out='../../out/linux'  proto_dir=$( cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) ;;
22  *)        echo "other: $OSTYPE" ;;
23esac
24echo $proto_dir
25SOURCE="${BASH_SOURCE[0]}"
26cd $(dirname ${SOURCE})
27if [ ! -f "$out/$protoc" ];then
28    echo "no $out/$protoc found, you need to run \"./build.sh protoc\" at root folder, and copy protoc.exe to $out/$protoc"
29    exit
30fi
31echo "begin to generate proto based files"
32SOURCE=$(dirname ${SOURCE})
33services_dir="$proto_dir/services"
34# kernel_version="5.10.79_aarch64"
35kernel_version="."
36ftrace_data_dir="$proto_dir/types/plugins/ftrace_data/$kernel_version"
37memory_data_dir="$proto_dir/types/plugins/memory_data"
38hilog_data_dir="$proto_dir/types/plugins/hilog_data"
39native_hook_dir="$proto_dir/types/plugins/native_hook"
40hidump_data_dir="$proto_dir/types/plugins/hidump_data"
41network_data_dir="$proto_dir/types/plugins/network_data"
42cpu_data_dir="$proto_dir/types/plugins/cpu_data"
43diskio_data_dir="$proto_dir/types/plugins/diskio_data"
44process_data_dir="$proto_dir/types/plugins/process_data"
45hisysevent_data_dir="$proto_dir/types/plugins/hisysevent_data"
46test_data_dir="$proto_dir/types/plugins/test_data"
47js_memory_dir="$proto_dir/types/plugins/js_memory"
48proto_array=("${services_dir}/common_types.proto"
49    "$ftrace_data_dir/trace_plugin_result.proto"
50    "$ftrace_data_dir/ftrace_event.proto"
51    "$ftrace_data_dir/irq.proto"
52    "$ftrace_data_dir/vmscan.proto"
53    "$ftrace_data_dir/workqueue.proto"
54    "$ftrace_data_dir/task.proto"
55    "$ftrace_data_dir/power.proto"
56    "$ftrace_data_dir/sched.proto"
57    "$ftrace_data_dir/filemap.proto"
58    "$ftrace_data_dir/i2c.proto"
59    "$ftrace_data_dir/kmem.proto"
60    "$ftrace_data_dir/block.proto"
61    "$ftrace_data_dir/ipi.proto"
62    "$ftrace_data_dir/ftrace.proto"
63    "$ftrace_data_dir/ext4.proto"
64    "$ftrace_data_dir/oom.proto"
65    "$ftrace_data_dir/compaction.proto"
66    "$ftrace_data_dir/clk.proto"
67    "$ftrace_data_dir/cgroup.proto"
68    "$ftrace_data_dir/binder.proto"
69    "$ftrace_data_dir/signal.proto"
70    "$ftrace_data_dir/sunrpc.proto"
71    "$ftrace_data_dir/net.proto"
72    "$ftrace_data_dir/cpuhp.proto"
73    "$ftrace_data_dir/writeback.proto"
74    "$ftrace_data_dir/v4l2.proto"
75    "$ftrace_data_dir/pagemap.proto"
76    "$ftrace_data_dir/dma_fence.proto"
77    "$ftrace_data_dir/printk.proto"
78    "$ftrace_data_dir/filelock.proto"
79    "$ftrace_data_dir/gpio.proto"
80    "$ftrace_data_dir/timer.proto"
81    "$ftrace_data_dir/raw_syscalls.proto"
82    "$ftrace_data_dir/rcu.proto"
83    "$memory_data_dir/memory_plugin_common.proto"
84    "$memory_data_dir/memory_plugin_config.proto"
85    "$memory_data_dir/memory_plugin_result.proto"
86    "$hilog_data_dir/hilog_plugin_result.proto"
87    "$native_hook_dir/native_hook_result.proto"
88    "$native_hook_dir/native_hook_config.proto"
89    "$hidump_data_dir/hidump_plugin_result.proto"
90    "$network_data_dir/network_plugin_result.proto"
91    "$cpu_data_dir/cpu_plugin_result.proto"
92    "$diskio_data_dir/diskio_plugin_result.proto"
93    "$hisysevent_data_dir/hisysevent_plugin_config.proto"
94    "$process_data_dir/process_plugin_result.proto"
95    "$hisysevent_data_dir/hisysevent_plugin_result.proto"
96    "$js_memory_dir/js_heap_result.proto"
97    "$js_memory_dir/js_heap_config.proto"
98    "$test_data_dir/test.proto")
99
100export LD_LIBRARY_PATH=$out
101for ((i = 0; i < ${#proto_array[@]}; i ++))
102do
103   newpath=$(dirname ${proto_array[$i]})
104   tailpath='\'${newpath#$proto_dir}
105   newpath=${tailpath:2}
106   cppout=../../third_party/protogen/$newpath
107   mkdir -p $cppout
108   $out/$protoc --proto_path=$memory_data_dir:$native_hook_dir:$hidump_data_dir:$hilog_data_dir:$ftrace_data_dir:$js_memory_dir:$services_dir:$network_data_dir:$cpu_data_dir:$diskio_data_dir:$process_data_dir:$hisysevent_data_dir:$test_data_dir --cpp_out=$cppout ${proto_array[$i]}
109   echo "----$out/$protoc --proto_path=$memory_data_dir:$native_hook_dir:$hidump_data_dir:$hilog_data_dir:$ftrace_data_dir:$js_memory_dir:$services_dir:$network_data_dir:$cpu_data_dir:$diskio_data_dir:$process_data_dir:$hisysevent_data_dir:$test_data_dir --plugin=protoc-gen-plugin=$out/$protoreader_plugin --plugin_out=wrapper_namespace=ProtoReader:$cppout ${proto_array[$i]}---"
110  #  $out/$protoc --proto_path=$memory_data_dir:$native_hook_dir:$hidump_data_dir:$hilog_data_dir:$ftrace_data_dir:$js_memory_dir:$services_dir:$network_data_dir:$cpu_data_dir:$diskio_data_dir:$process_data_dir:$hisysevent_data_dir:$test_data_dir --plugin=protoc-gen-plugin=$out/$protoreader_plugin --plugin_out=wrapper_namespace=ProtoReader:$cppout ${proto_array[$i]}
111   $out/$protoc --proto_path=$memory_data_dir:$native_hook_dir:$hidump_data_dir:$hilog_data_dir:$ftrace_data_dir:$js_memory_dir:$services_dir:$network_data_dir:$cpu_data_dir:$diskio_data_dir:$process_data_dir:$hisysevent_data_dir:$test_data_dir --plugin=protoc-gen-plugin=$out/$protoreader_plugin --plugin_out=wrapper_namespace=ProtoReader:$cppout ${proto_array[$i]}
112done
113echo "generate proto based files over"
114