diff --git a/BUILD.gn b/BUILD.gn index e7661a9cfd11e325c7f943b3742b139f0a3d86b7..6562559440ac76cf3a7dcc0ec1a16d5a7ba6419a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -228,10 +228,14 @@ ohos_source_set("hiperf_platform_common") { } external_deps += [ "bounds_checking_function:libsec_shared", - "hisysevent:libhisysevent", - "protobuf:protobuf_lite", "zlib:libz", ] + if (hiperf_independent_compilation) { + external_deps += [ + "hisysevent:libhisysevent", + "protobuf:protobuf_lite", + ] + } sources = sources_platform_common } @@ -258,10 +262,14 @@ ohos_source_set("hiperf_platform_linux") { external_deps += [ "bounds_checking_function:libsec_shared", "c_utils:utils", - "hisysevent:libhisysevent", - "protobuf:protobuf_lite", "zlib:libz", ] + if (hiperf_independent_compilation) { + external_deps += [ + "hisysevent:libhisysevent", + "protobuf:protobuf_lite", + ] + } public_configs += [ ":platform_linux_config" ] configs = [ "interfaces/innerkits/native:hiperf_client_config" ] @@ -279,6 +287,9 @@ ohos_source_set("support_elf") { config("protobuf_config") { defines = [ "HAVE_PROTOBUF=1" ] + if (!hiperf_independent_compilation) { + include_dirs = [ "//third_party/protobuf/src" ] + } } ohos_source_set("support_protobuf") { @@ -296,11 +307,13 @@ ohos_source_set("support_protobuf") { } else { external_deps = [ "faultloggerd:unwinder_host" ] } - external_deps += [ - "bounds_checking_function:libsec_shared", - "c_utils:utils", - "protobuf:protobuf_lite", - ] + external_deps += [ "bounds_checking_function:libsec_shared" ] + if (hiperf_independent_compilation) { + external_deps += [ + "c_utils:utils", + "protobuf:protobuf_lite", + ] + } sources = [ "./src/report_protobuf_file.cpp" ] } @@ -381,10 +394,10 @@ ohos_source_set("proto_file_cpp") { cflags = [] deps = [ ":hiperf_host_build_proto" ] - external_deps = [ - "c_utils:utils", - "protobuf:protobuf_lite", - ] + external_deps = [ "protobuf:protobuf_lite_static" ] + if (hiperf_independent_compilation) { + external_deps += [ "c_utils:utils" ] + } sources = proto_file_codegen public_configs = [ ":proto_file_cpp_config" ] } @@ -414,11 +427,15 @@ ohos_executable("hiperf") { "c_utils:utils", "faultloggerd:libunwinder", "hilog:libhilog", - "hisysevent:libhisysevent", "ipc:ipc_single", - "protobuf:protobuf_lite", ] + if (hiperf_independent_compilation) { + external_deps += [ + "hisysevent:libhisysevent", + "protobuf:protobuf_lite", + ] + } subsystem_name = "developtools" part_name = "hiperf" } @@ -429,11 +446,15 @@ ohos_executable("hiperf_host") { external_deps = [ "bounds_checking_function:libsec_shared", - "c_utils:utils", "faultloggerd:unwinder_host", - "hisysevent:libhisysevent", ] + if (hiperf_independent_compilation) { + external_deps += [ + "c_utils:utils", + "hisysevent:libhisysevent", + ] + } subsystem_name = "developtools" part_name = "hiperf" } @@ -482,10 +503,14 @@ ohos_source_set("hiperf_platform_host") { public_deps = [ ":hiperf_platform_common" ] external_deps = [ "bounds_checking_function:libsec_shared", - "c_utils:utils", "faultloggerd:unwinder_host", - "protobuf:protobuf_lite", ] + if (hiperf_independent_compilation) { + external_deps += [ + "c_utils:utils", + "protobuf:protobuf_lite", + ] + } } ohos_shared_library("hiperf_host_lib") { diff --git a/include/command_reporter.h b/include/command_reporter.h index 6b5f76baeeb5ad95ce0da34c94f5379be698e19f..af782b30583054be70da7cbdeb685faf362a6bc7 100644 --- a/include/command_reporter.h +++ b/include/command_reporter.h @@ -19,7 +19,7 @@ namespace OHOS::Developtools::HiPerf { #define MAKE_ERROR_ITEM(GEN_ITEM) \ - GEN_ITEM(NO_ERROR), /* 0 */ \ + GEN_ITEM(NO_ERR), /* 0 */ \ GEN_ITEM(PROCESS_CONTROL_FAIL), /* 1 */ \ GEN_ITEM(PREPARE_SYS_KERNEL_FAIL), /* 2 */ \ GEN_ITEM(PREPARE_PERF_EVENT_FAIL), /* 3 */ \ @@ -67,7 +67,7 @@ public: std::string subCommand_ = ""; std::string caller_ = ""; std::string targetProcess_ = ""; - HiperfError errorCode_ = HiperfError::NO_ERROR; + HiperfError errorCode_ = HiperfError::NO_ERR; private: bool isReported_ = false; diff --git a/include/subcommand.h b/include/subcommand.h index 73c32d33fb0b64260d6fa109827d44269a328c66..87c3185365523db08a9697f3bd2ff93f33f40a4c 100644 --- a/include/subcommand.h +++ b/include/subcommand.h @@ -76,7 +76,7 @@ public: bool OnSubCommand(std::string stringArgs) { auto args = StringSplit(stringArgs, " "); - return OnSubCommand(args) != HiperfError::NO_ERROR; + return OnSubCommand(args) != HiperfError::NO_ERR; }; // get some cmd diff --git a/src/command.cpp b/src/command.cpp index 0a1bcdd18ca33b9429dcfb23f61128bf423d2b34..a04ed14e0fe338f08f0e7730c5a5f0dd4a3956e9 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -66,7 +66,7 @@ bool Command::DispatchCommands(std::vector arguments) } HLOGD("OnSubCommand -> %s", subCommand->Name().c_str()); - if (HiperfError err = subCommand->OnSubCommand(arguments); err != HiperfError::NO_ERROR) { + if (HiperfError err = subCommand->OnSubCommand(arguments); err != HiperfError::NO_ERR) { printf("subcommand '%s' failed\n", subCommand->Name().c_str()); reporter.errorCode_ = err; return false; diff --git a/src/command_reporter.cpp b/src/command_reporter.cpp index 93d4cb3c789a83b78952922f486931a8da50f435..3f1d38a378ee779ab19b3e3b02695d27f528021e 100644 --- a/src/command_reporter.cpp +++ b/src/command_reporter.cpp @@ -24,9 +24,6 @@ namespace OHOS::Developtools::HiPerf { #define FOR_ERROR_NAME(x) #x -static const char* const ERROR_MESSAGE[] = { - MAKE_ERROR_ITEM(FOR_ERROR_NAME) -}; CommandReporter::CommandReporter(const std::string& fullArgument) : subCommand_(fullArgument) { @@ -50,7 +47,9 @@ void CommandReporter::ReportCommand() } int32_t errorCode = static_cast(errorCode_); - + static const char* const ERROR_MESSAGE[] = { + MAKE_ERROR_ITEM(FOR_ERROR_NAME) + }; int32_t ret = HiSysEventWrite( OHOS::HiviewDFX::HiSysEvent::Domain::PROFILER, "HIPERF_USAGE", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, diff --git a/src/hiperf_libreport.cpp b/src/hiperf_libreport.cpp index 0781fa269937cd1df0f70196901fda3af11897c0..08794ee636298841ce90cb27035bc628ba203d7d 100644 --- a/src/hiperf_libreport.cpp +++ b/src/hiperf_libreport.cpp @@ -60,7 +60,7 @@ int Report(const char *perfFile, const char *reportFile, const char *reportOptio } } if (report->ParseOption(args)) { - return report->OnSubCommand(args) == HiperfError::NO_ERROR ? 0 : -1; + return report->OnSubCommand(args) == HiperfError::NO_ERR ? 0 : -1; } } else { printf("path is nullptr\n"); @@ -89,7 +89,7 @@ int ReportUnwindJson(const char *perfFile, const char *reportFile, const char *s args.emplace_back(symbolsDir); } if (report->ParseOption(args)) { - return report->OnSubCommand(args) == HiperfError::NO_ERROR ? 0 : -1; + return report->OnSubCommand(args) == HiperfError::NO_ERR ? 0 : -1; } } return -1; @@ -194,7 +194,7 @@ int Dump(const char *fileName) std::vector args; args.emplace_back(fileName); if (dump->ParseOption(args)) { - return dump->OnSubCommand(args) == HiperfError::NO_ERROR ? 0 : -1; + return dump->OnSubCommand(args) == HiperfError::NO_ERR ? 0 : -1; } } return -1; diff --git a/src/subcommand_dump.cpp b/src/subcommand_dump.cpp index f620a650bfddcbed8fd6a0edf1aba1bfc250dc4d..48bb81e11c8bb244be957ff57812e0c9d8af80aa 100644 --- a/src/subcommand_dump.cpp +++ b/src/subcommand_dump.cpp @@ -139,12 +139,12 @@ HiperfError SubCommandDump::OnSubCommand(std::vector& args) RETURN_IF(!PrepareDumpOutput(), HiperfError::PREPARE_DUMP_OUTPUT_FAIL); if (!elfFileName_.empty()) { - return DumpElfFile() ? HiperfError::NO_ERROR : HiperfError::DUMP_ELF_FILE_ERROR; + return DumpElfFile() ? HiperfError::NO_ERR : HiperfError::DUMP_ELF_FILE_ERROR; } #if defined(HAVE_PROTOBUF) && HAVE_PROTOBUF if (!protobufDumpFileName_.empty()) { - return DumpProtoFile() ? HiperfError::NO_ERROR : HiperfError::DUMP_PROTO_FILE_ERROR; + return DumpProtoFile() ? HiperfError::NO_ERR : HiperfError::DUMP_PROTO_FILE_ERROR; } #endif @@ -189,7 +189,7 @@ HiperfError SubCommandDump::OnSubCommand(std::vector& args) DumpFeaturePortion(indent_); } - return HiperfError::NO_ERROR; + return HiperfError::NO_ERR; } bool SubCommandDump::DumpElfFile() diff --git a/src/subcommand_help.cpp b/src/subcommand_help.cpp index 3f2ebbb9084608219f054f79de931bc12ed14d8b..16d7d0237f8ca0db057d706aa646f16bdab7b03c 100644 --- a/src/subcommand_help.cpp +++ b/src/subcommand_help.cpp @@ -23,7 +23,7 @@ HiperfError SubCommandHelp::OnSubCommand(std::vector& args) { HLOGV("enter"); OnHelp(args); - return HiperfError::NO_ERROR; + return HiperfError::NO_ERR; } void SubCommandHelp::RegisterSubCommandHelp() diff --git a/src/subcommand_list.cpp b/src/subcommand_list.cpp index f34254a6fb0143a1f14440d33b9ea4cc0a13b3af..7b86c36e46cc769cf5422145393dd1768c696690 100644 --- a/src/subcommand_list.cpp +++ b/src/subcommand_list.cpp @@ -41,7 +41,7 @@ HiperfError SubCommandList::OnSubCommand(std::vector& args) } } ShowSupportEventsTypes(requestEventTypes); - return HiperfError::NO_ERROR; + return HiperfError::NO_ERR; } bool SubCommandList::ShowSupportEventsTypes(std::vector &requestEventTypes) diff --git a/src/subcommand_record.cpp b/src/subcommand_record.cpp index e0b4fa7b473a9eb30e4adda742babeba74fe60a1..2d309a05196eb45d9cbefda88be4865af288261c 100644 --- a/src/subcommand_record.cpp +++ b/src/subcommand_record.cpp @@ -1450,7 +1450,7 @@ HiperfError SubCommandRecord::OnSubCommand(std::vector& args) if (!ProcessControl()) { return HiperfError::PROCESS_CONTROL_FAIL; } else if (isFifoClient_) { - return HiperfError::NO_ERROR; + return HiperfError::NO_ERR; } // prepare PerfEvents @@ -1514,7 +1514,7 @@ HiperfError SubCommandRecord::OnSubCommand(std::vector& args) CloseClientThread(); RemoveVdsoTmpFile(); HIPERF_HILOGI(MODULE_DEFAULT, "SubCommandRecord finish"); - return HiperfError::NO_ERROR; + return HiperfError::NO_ERR; } void SubCommandRecord::CloseClientThread() @@ -2152,7 +2152,7 @@ bool SubCommandRecord::OnlineReportData() args.emplace_back(outputFilename_); args.emplace_back("-s"); if (reporter->ParseOption(args)) { - ret = (reporter->OnSubCommand(args) != HiperfError::NO_ERROR); + ret = (reporter->OnSubCommand(args) != HiperfError::NO_ERR); } if (remove(tempFileName.c_str()) != 0) { diff --git a/src/subcommand_report.cpp b/src/subcommand_report.cpp index 80158524ba1461ebd6dff10d7f9c78a02ecda3b1..31b9711867cd9769b54de91f10fce620884bee3a 100644 --- a/src/subcommand_report.cpp +++ b/src/subcommand_report.cpp @@ -615,7 +615,7 @@ HiperfError SubCommandReport::OnSubCommand(std::vector& args) #endif printf("report done\n"); - return HiperfError::NO_ERROR; + return HiperfError::NO_ERR; } bool SubCommandReport::RegisterSubCommandReport() diff --git a/src/subcommand_stat.cpp b/src/subcommand_stat.cpp index 0dffbae5d792f246fddca8dc4e1fbc1635a8ee79..1d114acc1948dcab05880bbf8f282583d137fe37 100644 --- a/src/subcommand_stat.cpp +++ b/src/subcommand_stat.cpp @@ -637,7 +637,7 @@ void SubCommandStat::SetPerfEvent() HiperfError SubCommandStat::OnSubCommand(std::vector& args) { - CHECK_TRUE(HelpOption(), HiperfError::NO_ERROR, 0, ""); + CHECK_TRUE(HelpOption(), HiperfError::NO_ERR, 0, ""); if (!CheckRestartOption(appPackage_, targetSystemWide_, restart_, selectPids_)) { return HiperfError::CHECK_RESTART_OPTION_FAIL; } @@ -687,7 +687,7 @@ HiperfError SubCommandStat::OnSubCommand(std::vector& args) // start tracking perfEvents_.StartTracking(); - return HiperfError::NO_ERROR; + return HiperfError::NO_ERR; } bool RegisterSubCommandStat() diff --git a/test/unittest/common/native/command_test.cpp b/test/unittest/common/native/command_test.cpp index fb62436fc6e5d7adfa25149d38470ade8ac3d4b0..57f118a8c3792666e414775bcb8208e4de8d21ad 100644 --- a/test/unittest/common/native/command_test.cpp +++ b/test/unittest/common/native/command_test.cpp @@ -44,7 +44,7 @@ void CommandTest::TearDownTestCase() {} void CommandTest::SetUp() { - static constexpr HiperfError noError = HiperfError::NO_ERROR; + static constexpr HiperfError noError = HiperfError::NO_ERR; static constexpr HiperfError optionNotSupport = HiperfError::OPTION_NOT_SUPPORT; ASSERT_EQ(Option::RegisterMainOption(TEST_OPTION_TRUE, TEST_OPTION_HELP, OptionAlwaysTrue), true); diff --git a/test/unittest/common/native/include/subcommand_test.h b/test/unittest/common/native/include/subcommand_test.h index 25fc160f1a55020c679a14814b2c5b0efcb3e03f..d4a5b3aaaefe31639c198f06e86c420d28bb01bf 100644 --- a/test/unittest/common/native/include/subcommand_test.h +++ b/test/unittest/common/native/include/subcommand_test.h @@ -43,7 +43,7 @@ public: HiperfError OnSubCommand(std::vector& args) override { - return HiperfError::NO_ERROR; + return HiperfError::NO_ERR; } }; diff --git a/test/unittest/common/native/subcommand_help_test.cpp b/test/unittest/common/native/subcommand_help_test.cpp index 1cd951a27a70529b208004c02d21219418a891c1..2c9ee6a44fd646a0b9aace9e8104699c8af92708 100644 --- a/test/unittest/common/native/subcommand_help_test.cpp +++ b/test/unittest/common/native/subcommand_help_test.cpp @@ -43,7 +43,7 @@ public: HiperfError OnSubCommand(std::vector& args) override { - return HiperfError::NO_ERROR; + return HiperfError::NO_ERR; } }; @@ -73,7 +73,7 @@ HWTEST_F(SubCommandHelpTest, TestOnSubCommand, TestSize.Level1) std::vector args; args = {"--help"}; - EXPECT_EQ(subCommandHelp.OnSubCommand(args), HiperfError::NO_ERROR); + EXPECT_EQ(subCommandHelp.OnSubCommand(args), HiperfError::NO_ERR); } /** diff --git a/test/unittest/common/native/subcommand_list_test.cpp b/test/unittest/common/native/subcommand_list_test.cpp index 3ba6f5dd86268a8257732022f2a0f0f31b0577b0..79042fd14ec6365c3dc6d914b61626b717ac1379 100644 --- a/test/unittest/common/native/subcommand_list_test.cpp +++ b/test/unittest/common/native/subcommand_list_test.cpp @@ -52,7 +52,7 @@ HWTEST_F(SubCommandListTest, TestOnSubCommandHW, TestSize.Level1) stdoutRecord.Start(); args = {"hw"}; - EXPECT_EQ(subCommandList.OnSubCommand(args), HiperfError::NO_ERROR); + EXPECT_EQ(subCommandList.OnSubCommand(args), HiperfError::NO_ERR); std::string stringOut = stdoutRecord.Stop(); } @@ -68,7 +68,7 @@ HWTEST_F(SubCommandListTest, TestOnSubCommandSW, TestSize.Level1) stdoutRecord.Start(); args = {"sw"}; - EXPECT_EQ(subCommandList.OnSubCommand(args), HiperfError::NO_ERROR); + EXPECT_EQ(subCommandList.OnSubCommand(args), HiperfError::NO_ERR); std::string stringOut = stdoutRecord.Stop(); } @@ -84,7 +84,7 @@ HWTEST_F(SubCommandListTest, TestOnSubCommandTP, TestSize.Level1) stdoutRecord.Start(); args = {"tp"}; - EXPECT_EQ(subCommandList.OnSubCommand(args), HiperfError::NO_ERROR); // still not support + EXPECT_EQ(subCommandList.OnSubCommand(args), HiperfError::NO_ERR); // still not support std::string stringOut = stdoutRecord.Stop(); } @@ -100,7 +100,7 @@ HWTEST_F(SubCommandListTest, TestOnSubCommandCACHE, TestSize.Level1) stdoutRecord.Start(); args = {"cache"}; - EXPECT_EQ(subCommandList.OnSubCommand(args), HiperfError::NO_ERROR); + EXPECT_EQ(subCommandList.OnSubCommand(args), HiperfError::NO_ERR); std::string stringOut = stdoutRecord.Stop(); } @@ -116,7 +116,7 @@ HWTEST_F(SubCommandListTest, TestOnSubCommandRAW, TestSize.Level1) stdoutRecord.Start(); args = {"raw"}; - EXPECT_EQ(subCommandList.OnSubCommand(args), HiperfError::NO_ERROR); + EXPECT_EQ(subCommandList.OnSubCommand(args), HiperfError::NO_ERR); std::string stringOut = stdoutRecord.Stop(); } @@ -148,7 +148,7 @@ HWTEST_F(SubCommandListTest, TestOnSubCommandEmpty, TestSize.Level1) stdoutRecord.Start(); args.clear(); - EXPECT_EQ(subCommandList.OnSubCommand(args), HiperfError::NO_ERROR); + EXPECT_EQ(subCommandList.OnSubCommand(args), HiperfError::NO_ERR); std::string stringOut = stdoutRecord.Stop(); } diff --git a/test/unittest/common/native/subcommand_record_test.cpp b/test/unittest/common/native/subcommand_record_test.cpp index 61e3468b878d678e3637a18e5f6a8faef3220942..e7e22311d4d976ed327b6a3e7fccddfb3ed016b8 100644 --- a/test/unittest/common/native/subcommand_record_test.cpp +++ b/test/unittest/common/native/subcommand_record_test.cpp @@ -316,7 +316,7 @@ HWTEST_F(SubCommandRecordTest, ReportCommand, TestSize.Level1) EXPECT_EQ(value, "0"); EXPECT_EQ(eventRecord->GetParamValue("ERROR_MESSAGE", value), VALUE_PARSED_SUCCEED); - EXPECT_EQ(value, "NO_ERROR"); + EXPECT_EQ(value, "NO_ERR"); } // system wide diff --git a/test/unittest/common/native/subcommand_test.cpp b/test/unittest/common/native/subcommand_test.cpp index a1d575425a53d989330acb24f07e91295edb26c7..4151b534a177ca4ae03fb51eb3b8bfaeb2a042a3 100644 --- a/test/unittest/common/native/subcommand_test.cpp +++ b/test/unittest/common/native/subcommand_test.cpp @@ -35,7 +35,7 @@ public: SubcommandObj() : SubCommand("subcomm", "test subcomm", "ut test subcomm") {} HiperfError OnSubCommand(std::vector& args) override { - return HiperfError::NO_ERROR; + return HiperfError::NO_ERR; } };