From 6abd3c1dd6e9d0f3dce28b01eddcd9bbdc8a66d1 Mon Sep 17 00:00:00 2001 From: ctw-ian Date: Thu, 12 Oct 2023 15:17:16 +0800 Subject: [PATCH] Support fundamental verifier of arkcompiler Issue:https://gitee.com/openharmony/arkcompiler_runtime_core/issues/I87KN4 Signed-off-by: ctw-ian Change-Id: I2d8b35559653de1214e025ff057759733dd81a50 --- BUILD.gn | 4 +++ bundle.json | 3 ++- verifier/BUILD.gn | 32 +++++++++++++++++++++++ verifier/verifier.cpp | 18 +++++++++++++ verifier/verifier.h | 21 +++++++++++++++ verifier/verify.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 verifier/BUILD.gn create mode 100644 verifier/verifier.cpp create mode 100644 verifier/verifier.h create mode 100644 verifier/verify.cpp diff --git a/BUILD.gn b/BUILD.gn index 48f56d32b8..64547508c5 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -21,6 +21,10 @@ group("arkcompiler_params") { deps = [ "libpandafile:arkcompiler_params" ] } +group("ark_device_tools") { + deps = [ "$ark_root/verifier:ark_verifier" ] +} + group("ark_packages") { deps = [] if (host_os != "mac") { diff --git a/bundle.json b/bundle.json index 62049bcc94..663822a1c5 100644 --- a/bundle.json +++ b/bundle.json @@ -36,7 +36,8 @@ "sub_component": [ "//arkcompiler/runtime_core:arkcompiler_params", "//arkcompiler/runtime_core/arkplatform:arkplatform_packages", - "//arkcompiler/runtime_core/static_core:ark_packages" + "//arkcompiler/runtime_core/static_core:ark_packages", + "//arkcompiler/runtime_core:ark_device_tools" ], "inner_kits": [ { diff --git a/verifier/BUILD.gn b/verifier/BUILD.gn new file mode 100644 index 0000000000..a46016d1df --- /dev/null +++ b/verifier/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//arkcompiler/runtime_core/ark_config.gni") + +ohos_executable("ark_verifier") { + sources = [ "verify.cpp" ] + + include_dirs = [ + "$target_gen_dir", + "$root_gen_dir/libpandabase", + ] + + configs = [ + "$ark_root:ark_config", + "$ark_root/libpandabase:arkbase_public_config", + ] + + install_enable = true + part_name = "runtime_core" + subsystem_name = "arkcompiler" +} diff --git a/verifier/verifier.cpp b/verifier/verifier.cpp new file mode 100644 index 0000000000..b508fdfb57 --- /dev/null +++ b/verifier/verifier.cpp @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace panda::verifier { + +} // namespace panda::verifier \ No newline at end of file diff --git a/verifier/verifier.h b/verifier/verifier.h new file mode 100644 index 0000000000..80ffd7ae56 --- /dev/null +++ b/verifier/verifier.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +namespace panda::verifier { +class Verifier { + +}; +} // namespace name diff --git a/verifier/verify.cpp b/verifier/verify.cpp new file mode 100644 index 0000000000..2c4897f176 --- /dev/null +++ b/verifier/verify.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "utils/pandargs.h" + +void PrintHelp(panda::PandArgParser &pa_parser) +{ + std::cerr << "Usage:" << std::endl; + std::cerr << "ark_disasm [options] input_file output_file" << std::endl << std::endl; + std::cerr << "Supported options:" << std::endl << std::endl; + std::cerr << pa_parser.GetHelpString() << std::endl; +} + +bool Verify([[maybe_unused]] const std::string &input_file) +{ + return true; +} + +bool PorcessArgs(panda::PandArgParser &pa_parser, const panda::PandArg &input_file, int argc, + const char **argv) +{ + if (!pa_parser.Parse(argc, argv)) { + PrintHelp(pa_parser); + return false; + } + + if (input_file.GetValue().empty()) { + PrintHelp(pa_parser); + return false; + } + + return true; +} + +int main(int argc, const char **argv) +{ + panda::PandArg help("help", false, "Print this message and exit"); + panda::PandArg input_file("input_file", "", "Path to the abc file"); + + panda::PandArgParser pa_parser; + pa_parser.Add(&help); + pa_parser.Add(&input_file); + + if (!PorcessArgs(pa_parser, input_file, argc, argv)) { + return 1; + } + + return Verify(input_file.GetValue()) ? 0 : 1; +} \ No newline at end of file -- Gitee