Support verifier interface in oh image

Issue:https://gitee.com/openharmony/arkcompiler_runtime_core/issues/I8DMPF

Signed-off-by: ctw-ian <chentingwei2@huawei.com>
Change-Id: I4c7d6ca8946bed9dce82e635e838cc3d794d1fe7
This commit is contained in:
ctw-ian 2023-10-24 15:38:46 +08:00
parent 2795864226
commit 3a5607902c
7 changed files with 115 additions and 17 deletions

View File

@ -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") {

View File

@ -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": [

View File

@ -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
include_dirs = [
"$target_gen_dir",
"$root_gen_dir/libpandabase",
]
deps = [ "$ark_root/libpandafile:libarkfile_static" ]
configs = [
"$ark_root:ark_config",
"$ark_root/libpandabase:arkbase_public_config",
]
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" ]
if (!is_standard_system) {
relative_install_dir = "ark"
}
output_extension = "so"
install_enable = true
part_name = "runtime_core"

View File

@ -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<const panda_file::File> 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

View File

@ -13,9 +13,19 @@
* limitations under the License.
*/
#ifndef VERIFIER_VERIFIER_H
#define VERIFIER_VERIFIER_H
#include <string>
namespace panda::verifier {
class Verifier {
public:
Verifier() = default;
~Verifier() = default;
bool Verify(const std::string &filename_in);
};
} // namespace name
#endif

View File

@ -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<std::string> &input_file, int argc,
const char **argv)
{

32
verifier/verify.h Normal file
View File

@ -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 <string>
bool Verify([[maybe_unused]] const std::string &input_file)
{
panda::verifier::Verifier vf {};
if (vf.Verify(input_file)) {
return true;
}
return false;
}
#endif