diff --git a/BUILD.gn b/BUILD.gn index 2b28102077338503adb5f70dfe98ff35d4f55423..2f7647a0dbfedf4940009241809ca8c7b77589f9 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -21,8 +21,11 @@ group("arkcompiler_params") { deps = [ "libpandafile:arkcompiler_params" ] } -group("ark_device_tools") { - deps = [ "$ark_root/verifier:ark_verifier" ] +group("ark_device_packages") { + deps = [ + "$ark_root/verifier:ark_verifier", + "$ark_root/verifier:libarkverifier", + ] } group("ark_packages") { diff --git a/bundle.json b/bundle.json index 83b44fc0dbde6b568f2594e142a70b929fdc1dac..10df1a1ead3e358bc2c33ee7abeb06ea02502a6e 100644 --- a/bundle.json +++ b/bundle.json @@ -37,7 +37,7 @@ "//arkcompiler/runtime_core:arkcompiler_params", "//arkcompiler/runtime_core/arkplatform:arkplatform_packages", "//arkcompiler/runtime_core/static_core:ark_packages", - "//arkcompiler/runtime_core:ark_device_tools" + "//arkcompiler/runtime_core:ark_device_packages" ], "inner_kits": [ { @@ -137,6 +137,13 @@ "header_files": [], "header_base": "//arkcompiler/runtime_core/static_core/compiler" } + }, + { + "name": "//arkcompiler/runtime_core/verifier:libarkverifier", + "header": { + "header_files": [], + "header_base": "//arkcompiler/runtime_core/verifier" + } } ], "test": [ diff --git a/verifier/BUILD.gn b/verifier/BUILD.gn index a46016d1df0e07c8a54d18a555c572f144e4cafe..65e7dc0f5407417129f9f1849f3f3354311bbd21 100644 --- a/verifier/BUILD.gn +++ b/verifier/BUILD.gn @@ -13,18 +13,51 @@ import("//arkcompiler/runtime_core/ark_config.gni") +arkverifier_sources = [ + "verifier.cpp", + "verify.cpp", + "verify.h", +] + +arkverifier_configs = [ + "$ark_root:ark_config", + "$ark_root/libpandabase:arkbase_public_config", + "$ark_root/libpandafile:arkfile_public_config", + ":arkverifier_public_config", +] + +config("arkverifier_public_config") { + include_dirs = [ "$ark_root/verifier" ] +} + ohos_executable("ark_verifier") { - sources = [ "verify.cpp" ] + sources = arkverifier_sources + + deps = [ "$ark_root/libpandafile:libarkfile_static" ] + + configs = arkverifier_configs + + public_configs = [ ":arkverifier_public_config" ] + + install_enable = true + part_name = "runtime_core" + subsystem_name = "arkcompiler" +} + +ohos_shared_library("libarkverifier") { + sources = arkverifier_sources + + deps = [ "$ark_root/libpandafile:libarkfile_static" ] + + configs = arkverifier_configs + + public_configs = [ ":arkverifier_public_config" ] - include_dirs = [ - "$target_gen_dir", - "$root_gen_dir/libpandabase", - ] + if (!is_standard_system) { + relative_install_dir = "ark" + } - configs = [ - "$ark_root:ark_config", - "$ark_root/libpandabase:arkbase_public_config", - ] + output_extension = "so" install_enable = true part_name = "runtime_core" diff --git a/verifier/verifier.cpp b/verifier/verifier.cpp index b508fdfb57b28401caf479e4f62b817583676758..b7b9bf8cdfa00e2cdefdaf2ba868357642a7f082 100644 --- a/verifier/verifier.cpp +++ b/verifier/verifier.cpp @@ -13,6 +13,23 @@ * limitations under the License. */ +#include "verifier.h" + +#include "file.h" + namespace panda::verifier { +bool Verifier::Verify(const std::string &filename_in) +{ + std::unique_ptr file; + auto file_to_verify = panda_file::File::Open(filename_in); + file.swap(file_to_verify); + + if (file == nullptr) { + return false; + } + + return true; +} + } // namespace panda::verifier \ No newline at end of file diff --git a/verifier/verifier.h b/verifier/verifier.h index 80ffd7ae5683562e1f60baba909e53965a3abc3e..bc9bcabf250288c05e6024d7b01d4e9bab53fc5f 100644 --- a/verifier/verifier.h +++ b/verifier/verifier.h @@ -13,9 +13,19 @@ * limitations under the License. */ +#ifndef VERIFIER_VERIFIER_H +#define VERIFIER_VERIFIER_H + +#include namespace panda::verifier { class Verifier { +public: + Verifier() = default; + ~Verifier() = default; + bool Verify(const std::string &filename_in); }; } // namespace name + +#endif \ No newline at end of file diff --git a/verifier/verify.cpp b/verifier/verify.cpp index 2c4897f17642af7ad809e1dad50a73f201cc9890..d4694d5b7cacda7bab29c9238b1369d9dc432db2 100644 --- a/verifier/verify.cpp +++ b/verifier/verify.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#include "verify.h" #include "utils/pandargs.h" void PrintHelp(panda::PandArgParser &pa_parser) @@ -23,11 +24,6 @@ void PrintHelp(panda::PandArgParser &pa_parser) 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) { diff --git a/verifier/verify.h b/verifier/verify.h new file mode 100644 index 0000000000000000000000000000000000000000..7b2cc0495062509019dbbe74a690f952a2deea04 --- /dev/null +++ b/verifier/verify.h @@ -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. + */ +#ifndef VERIFIER_VERIFY_H +#define VERIFIER_VERIFY_H + +#include "verifier.h" + +#include + +bool Verify([[maybe_unused]] const std::string &input_file) +{ + panda::verifier::Verifier vf {}; + if (vf.Verify(input_file)) { + return true; + } + + return false; +} + +#endif \ No newline at end of file