mirror of
https://gitee.com/openharmony/developtools_profiler
synced 2024-11-23 15:00:17 +00:00
fix sh file
Signed-off-by: zyxzyx <zhangyixin19@huawei.com>
This commit is contained in:
parent
d50f4b29bf
commit
16f896d9f3
@ -17,21 +17,16 @@ import sys
|
||||
import shutil
|
||||
|
||||
|
||||
def replace_lite_option(target_path, protofilepath, type):
|
||||
def replace_lite_option(target_path, protofilepath):
|
||||
target_file_path = os.path.basename(protofilepath)
|
||||
prototype = "_" + type + ".proto"
|
||||
target_file_path = target_path + '/' + target_file_path.replace(".proto", prototype)
|
||||
target_file_path = target_path + '/' + target_file_path.replace(".proto", "_standard.proto")
|
||||
shutil.copyfile(protofilepath, target_file_path)
|
||||
# replease lite flag, import file name, add package name
|
||||
with open(target_file_path, 'r+') as content:
|
||||
newcontent = content.read()
|
||||
if type == "standard":
|
||||
newcontent = newcontent.replace('option optimize_for = LITE_RUNTIME;\n', '')
|
||||
newcontent = newcontent.replace('syntax = "proto3";', 'syntax = "proto3";\npackage ForStandard;')
|
||||
newcontent = newcontent.replace('.proto";', '_standard.proto";')
|
||||
elif type == "lite":
|
||||
newcontent = newcontent.replace('grpc.service";\n',
|
||||
'grpc.service";\n\noption optimize_for = LITE_RUNTIME;\n\npackage LITE;\n')
|
||||
newcontent = newcontent.replace('option optimize_for = LITE_RUNTIME;\n', '')
|
||||
newcontent = newcontent.replace('syntax = "proto3";', 'syntax = "proto3";\npackage ForStandard;')
|
||||
newcontent = newcontent.replace('.proto";', '_standard.proto";')
|
||||
content.seek(0, 0)
|
||||
content.write(newcontent)
|
||||
content.truncate()
|
||||
@ -39,15 +34,12 @@ def replace_lite_option(target_path, protofilepath, type):
|
||||
|
||||
|
||||
def main():
|
||||
type = sys.argv[1]
|
||||
target_dir = sys.argv[2]
|
||||
i = 3
|
||||
target_dir = sys.argv[1]
|
||||
i = 2
|
||||
while i < len(sys.argv):
|
||||
proto_file_path = sys.argv[i]
|
||||
replace_lite_option(target_dir, proto_file_path, "standard")
|
||||
if type == "lite":
|
||||
replace_lite_option(target_dir, proto_file_path, "lite")
|
||||
replace_lite_option(target_dir, proto_file_path)
|
||||
i += 1
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
@ -24,13 +24,7 @@ PROTOC=$PROJECT_TOP/$2/thirdparty/protobuf/protoc
|
||||
OPT_PLUGIN_PATH=$PROJECT_TOP/$2/developtools/hiprofiler/protoencoder_plugin
|
||||
OPT_PLUGIN=--plugin=protoc-gen-opt=$PROJECT_TOP/$2/developtools/hiprofiler/protoencoder_plugin
|
||||
OPT_OUT=--opt_out
|
||||
PROTO_TYPE="standard"
|
||||
if [[ "${8##*/}" == "common_types.proto" ]]; then
|
||||
if [[ $# -eq 8 ]]; then
|
||||
PROTO_TYPE="lite"
|
||||
fi
|
||||
fi
|
||||
PYTHON_SHELL=$THIS_DIR/make_proto.py # shell path
|
||||
PYTHON_SHELL=$THIS_DIR/make_standard_proto.py # shell path
|
||||
TMP=$2
|
||||
PROTO_OUT_DIR="$PROJECT_TOP/${TMP%/*}/$3" # path of the new proto file
|
||||
|
||||
@ -52,7 +46,7 @@ do
|
||||
done
|
||||
PARAMS_PRINT="$PROTO_OUT_DIR $PARAMS_SOURCES" # splice the python args
|
||||
echo "EXEC: python $PYTHON_SHELL $PARAMS_PRINT"
|
||||
python $PYTHON_SHELL $PROTO_TYPE $PARAMS_PRINT
|
||||
python $PYTHON_SHELL $PARAMS_PRINT
|
||||
# end python
|
||||
|
||||
# creat pb file
|
||||
@ -65,16 +59,6 @@ do
|
||||
done
|
||||
PARAMS_ALL="$PARAMS_SRC $PARAMS_STANDARD" # add new argument list to old argument list
|
||||
|
||||
if [[ "$PROTO_TYPE" == "lite" ]]; then # common_types.proto need to create lite pb file
|
||||
PARAMS_LITE_REPLACE=${PARAMS_SOURCES//.proto/_lite.proto} # make the new proto file name. like "_lite.proto"
|
||||
PARAMS_LITE=" --proto_path $PROTO_OUT_DIR " # add proto_path,$PROTO_OUT_DIR is the pb file path
|
||||
for VAR in ${PARAMS_LITE_REPLACE[@]}
|
||||
do
|
||||
PARAMS_LITE="$PARAMS_LITE$PROTO_OUT_DIR/${VAR##*/} " # add .proto file name to args
|
||||
done
|
||||
PARAMS_ALL="$PARAMS_SRC $PARAMS_STANDARD $PARAMS_LITE" # add new argument list to old argument list
|
||||
fi
|
||||
|
||||
# avoid conflict, param4=--plugin* means ipc plugin, generate encode file if opt plugin exist
|
||||
if [[ "$4" != --plugin* ]]; then
|
||||
if [ -f "$OPT_PLUGIN_PATH" ]; then
|
||||
@ -85,4 +69,4 @@ if [[ "$4" != --plugin* ]]; then
|
||||
fi
|
||||
|
||||
echo "EXEC: LD_LIBRARY_PATH=$LIBCXX_X64_OUT:$SUBSYS_X64_OUT $PROTOC $PARAMS_ALL"
|
||||
LD_LIBRARY_PATH=$LIBCXX_X64_OUT:$SUBSYS_X64_OUT exec $PROTOC $PARAMS_ALL
|
||||
LD_LIBRARY_PATH=$LIBCXX_X64_OUT:$SUBSYS_X64_OUT exec $PROTOC $PARAMS_ALL
|
@ -25,7 +25,6 @@ config("hook_config") {
|
||||
"HIPERF_DEBUG",
|
||||
"CONFIG_NO_HILOG",
|
||||
"NATIVEDAEMON_USE_CALLSTACK",
|
||||
"LITE_PROTO",
|
||||
]
|
||||
defines += [ "target_cpu_${target_cpu}" ]
|
||||
if (use_jemalloc) {
|
||||
@ -111,7 +110,6 @@ ohos_executable("native_daemon") {
|
||||
":hiprofiler_daemon.cfg",
|
||||
"${OHOS_PROFILER_DIR}/device/services/shared_memory:shared_memory_source",
|
||||
"${OHOS_PROFILER_DIR}/proto_encoder:proto_encoder_source",
|
||||
"${OHOS_PROFILER_DIR}/protos/services:common_types_lite_proto",
|
||||
"${OHOS_PROFILER_DIR}/protos/services:plugin_service_proto",
|
||||
"${OHOS_PROFILER_DIR}/protos/services:profiler_service_all_type_source",
|
||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp",
|
||||
|
@ -38,7 +38,6 @@ config("native_memory_profiler_sa_config") {
|
||||
"HIPERF_DEBUG",
|
||||
"CONFIG_NO_HILOG",
|
||||
"NATIVEDAEMON_USE_CALLSTACK",
|
||||
"LITE_PROTO",
|
||||
]
|
||||
defines += [ "target_cpu_${target_cpu}" ]
|
||||
if (use_jemalloc) {
|
||||
@ -105,7 +104,6 @@ ohos_unittest("native_memory_profiler_sa_ut") {
|
||||
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||
"${OHOS_PROFILER_DIR}/device/services/shared_memory:shared_memory_source",
|
||||
"${OHOS_PROFILER_DIR}/proto_encoder:proto_encoder_source",
|
||||
"${OHOS_PROFILER_DIR}/protos/services:common_types_lite_proto",
|
||||
"${OHOS_PROFILER_DIR}/protos/services:plugin_service_proto",
|
||||
"${OHOS_PROFILER_DIR}/protos/services:profiler_service_all_type_source",
|
||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp",
|
||||
|
@ -21,9 +21,7 @@
|
||||
#include <cstdio>
|
||||
|
||||
#include "common.h"
|
||||
#ifdef LITE_PROTO
|
||||
#include "common_types_lite.pb.h"
|
||||
#endif
|
||||
#include "common_types.pb.h"
|
||||
#include "logging.h"
|
||||
|
||||
using CharPtr = std::unique_ptr<char>::pointer;
|
||||
@ -86,10 +84,9 @@ bool TraceFileWriter::SetPluginConfig(const void* data, size_t size)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef LITE_PROTO
|
||||
void TraceFileWriter::WriteStandalonePluginData(std::string pluginName, std::string data, std::string pluginVersion)
|
||||
{
|
||||
LITE::ProfilerPluginData pluginData;
|
||||
ProfilerPluginData pluginData;
|
||||
pluginData.set_name(pluginName);
|
||||
pluginData.set_data(data);
|
||||
if (!pluginVersion.empty()) {
|
||||
@ -100,7 +97,7 @@ void TraceFileWriter::WriteStandalonePluginData(std::string pluginName, std::str
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
pluginData.set_tv_sec(ts.tv_sec);
|
||||
pluginData.set_tv_nsec(ts.tv_nsec);
|
||||
pluginData.set_clock_id(LITE::ProfilerPluginData::CLOCKID_REALTIME);
|
||||
pluginData.set_clock_id(ProfilerPluginData::CLOCKID_REALTIME);
|
||||
}
|
||||
|
||||
std::vector<char> msgData(pluginData.ByteSizeLong());
|
||||
@ -110,7 +107,6 @@ void TraceFileWriter::WriteStandalonePluginData(std::string pluginName, std::str
|
||||
|
||||
Write(msgData.data(), msgData.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
void TraceFileWriter::SetTimeStamp()
|
||||
{
|
||||
|
@ -242,42 +242,3 @@ ohos_source_set("proto_services_cpp") {
|
||||
subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
|
||||
part_name = "${OHOS_PROFILER_PART_NAME}"
|
||||
}
|
||||
|
||||
#######################################################
|
||||
common_types_lite_proto = [ "./common_types.proto" ]
|
||||
|
||||
common_types_lite_codegen = []
|
||||
foreach(proto, common_types_lite_proto) {
|
||||
name = get_path_info(proto, "name")
|
||||
common_types_lite_codegen += [
|
||||
"$proto_out_dir/${name}_lite.pb.h",
|
||||
"$proto_out_dir/${name}_lite.pb.cc",
|
||||
]
|
||||
}
|
||||
|
||||
action("common_types_lite_proto_gen") {
|
||||
script = "${OHOS_PROFILER_DIR}/build/protoc.sh"
|
||||
sources = common_types_lite_proto
|
||||
outputs = common_types_lite_codegen
|
||||
args = [
|
||||
"$libc_dir_proto",
|
||||
"$root_output_dir_proto",
|
||||
"$proto_rel_out_dir", # standard proto file destination path
|
||||
"--cpp_out",
|
||||
"$proto_rel_out_dir",
|
||||
"--proto_path",
|
||||
rebase_path(".", root_build_dir),
|
||||
]
|
||||
args += rebase_path(sources, root_build_dir)
|
||||
deps = [ "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc(${host_toolchain})" ]
|
||||
}
|
||||
|
||||
ohos_source_set("common_types_lite_proto") {
|
||||
deps = [ ":common_types_lite_proto_gen" ]
|
||||
public_deps = [ "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite" ]
|
||||
include_dirs = [ "$proto_out_dir" ]
|
||||
public_configs = [ ":public_configs" ]
|
||||
sources = common_types_lite_codegen
|
||||
subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
|
||||
part_name = "${OHOS_PROFILER_PART_NAME}"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user