• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2#coding=utf-8
3
4#
5# Copyright (c) 2022 Huawei Device Co., Ltd.
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10#     http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
19from elf_file_mgr import ElfFileMgr
20
21def __createArgParser():
22	import argparse
23
24	parser = argparse.ArgumentParser(description='Check architecture information from compiled output files.')
25
26	parser.add_argument('-i', '--input',
27						help='input asset files root directory', required=True)
28
29	parser.add_argument('-r', '--rules', action='append',
30						help='rules directory', required=False)
31
32	parser.add_argument('-n', '--no-fail',
33						help='force to pass all rules', required=False)
34
35	return parser
36
37def _deps_guard_module(out_path, args=None):
38	mgr = ElfFileMgr(out_path)
39	mgr.scan_all_files()
40
41	from rules_checker import check_all_rules
42
43	passed = check_all_rules(mgr, args)
44	if passed:
45		print("All rules passed")
46		return
47
48	raise Exception("ERROR: deps_guard failed.")
49
50def _startup_guard_module(out_path, args):
51    import sys
52    import os
53    for path in sys.path:
54        if path.endswith("developtools/integration_verification/tools/deps_guard"):
55            sys.path.append(os.path.join(
56                path, "../startup_guard"))
57            break
58
59    from startup_guard import startup_guard
60
61    startup_guard(out_path, args)
62
63def deps_guard(out_path, args=None):
64    _deps_guard_module(out_path, args)
65    _startup_guard_module(out_path, args)
66
67if __name__ == '__main__':
68
69	parser = __createArgParser()
70	args = parser.parse_args()
71
72	deps_guard(args.input, args)
73