• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# Copyright (c) 2024 Huawei Device Co., Ltd.
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
17import enum
18from typedef.diff.diff import DiffType
19
20
21class CheckCompatibilityErrorMessage(enum.Enum):
22    API_CHANGE_INCOMPATIBLE_01 = ('API check error of [api compatibility errors]:Deleting [$$] API is prohibited.'
23                                  'Please resolve it.')
24    API_CHANGE_INCOMPATIBLE_02 = ('API check error of [api compatibility errors]:Changing API name [$$] to API name '
25                                  '[&&] is prohibited.Please resolve it.')
26    API_CHANGE_INCOMPATIBLE_03 = ('API check error of [api compatibility errors]:Deleting [$$] file is prohibited.'
27                                  'Please resolve it.')
28    API_CHANGE_INCOMPATIBLE_04 = ('API check error of [api compatibility errors]:Changing [$$] file path is prohibited.'
29                                  'Please resolve it.')
30    API_CHANGE_INCOMPATIBLE_05 = ('API check error of [api compatibility errors]:Changing function name [$$] to '
31                                  'function name [&&] is prohibited.Please resolve it.')
32    API_CHANGE_INCOMPATIBLE_06 = ('API check error of [api compatibility errors]:Changing function return type [$$] '
33                                  'to function return type [&&] is prohibited.Please resolve it.')
34    API_CHANGE_INCOMPATIBLE_07 = ('API check error of [api compatibility errors]:Changing function param location [$$] '
35                                  'to function param location [&&] is prohibited.Please resolve it.')
36    API_CHANGE_INCOMPATIBLE_08 = ('API check error of [api compatibility errors]:Adding new function param [&&] is '
37                                  'prohibited.Please resolve it.')
38    API_CHANGE_INCOMPATIBLE_09 = ('API check error of [api compatibility errors]:Deleting function param [$$] is '
39                                  'prohibited.Please resolve it.')
40    API_CHANGE_INCOMPATIBLE_10 = ('API check error of [api compatibility errors]:Changing function param type [$$] '
41                                  'to function param type [&&] is prohibited.Please resolve it.')
42    API_CHANGE_INCOMPATIBLE_11 = ('API check error of [api compatibility errors]:Changing variable name [$$] to '
43                                  'variable name [&&] is prohibited.Please resolve it.')
44    API_CHANGE_INCOMPATIBLE_12 = ('API check error of [api compatibility errors]:Changing const name [$$] to const '
45                                  'name [&&] is prohibited.Please resolve it.')
46    API_CHANGE_INCOMPATIBLE_13 = ('API check error of [api compatibility errors]:Changing variable type [$$] to '
47                                  'variable type [&&] is prohibited.Please resolve it.')
48    API_CHANGE_INCOMPATIBLE_14 = ('API check error of [api compatibility errors]:Changing const type [$$] to const '
49                                  'type [&&] is prohibited.Please resolve it.')
50    API_CHANGE_INCOMPATIBLE_15 = ('API check error of [api compatibility errors]:Changing variable [$$] to const [&&] '
51                                  'is prohibited.Please resolve it.')
52    API_CHANGE_INCOMPATIBLE_16 = ('API check error of [api compatibility errors]:Changing const [$$] to variable [&&] '
53                                  'is prohibited.Please resolve it.')
54    API_CHANGE_INCOMPATIBLE_17 = ('API check error of [api compatibility errors]:Changing variable value [$$] to '
55                                  'variable value [&&] is prohibited.Please resolve it.')
56    API_CHANGE_INCOMPATIBLE_18 = ('API check error of [api compatibility errors]:Changing const value [$$] to const '
57                                  'value [&&] is prohibited.Please resolve it.')
58    API_CHANGE_INCOMPATIBLE_19 = ('API check error of [api compatibility errors]:Deleting variable [$$] is prohibited.'
59                                  'Please resolve it.')
60    API_CHANGE_INCOMPATIBLE_20 = ('API check error of [api compatibility errors]:Deleting const [$$] is prohibited.'
61                                  'Please resolve it.')
62    API_CHANGE_INCOMPATIBLE_21 = ('API check error of [api compatibility errors]:Changing macro name [$$] to macro '
63                                  'name [&&] is prohibited.Please resolve it.')
64    API_CHANGE_INCOMPATIBLE_22 = ('API check error of [api compatibility errors]:Changing macro value [$$] to macro '
65                                  'value [&&] is prohibited.Please resolve it.')
66    API_CHANGE_INCOMPATIBLE_23 = ('API check error of [api compatibility errors]:Deleting macro define [$$] is '
67                                  'prohibited.Please resolve it.')
68    API_CHANGE_INCOMPATIBLE_24 = ('API check error of [api compatibility errors]:Changing enum name [$$] to enum name '
69                                  '[&&] is prohibited.Please resolve it.')
70    API_CHANGE_INCOMPATIBLE_25 = ('API check error of [api compatibility errors]:Changing enum member name [$$] to '
71                                  'enum member name [&&] is prohibited.Please resolve it.')
72    API_CHANGE_INCOMPATIBLE_26 = ('API check error of [api compatibility errors]:Changing enum member value [$$] to '
73                                  'enum member name [&&] is prohibited.Please resolve it.')
74    API_CHANGE_INCOMPATIBLE_27 = ('API check error of [api compatibility errors]:Deleting enum [$$] is prohibited.'
75                                  'Please resolve it.')
76    API_CHANGE_INCOMPATIBLE_28 = ('API check error of [api compatibility errors]:Deleting enum member [$$] is '
77                                  'prohibited.Please resolve it.')
78    API_CHANGE_INCOMPATIBLE_29 = ('API check error of [api compatibility errors]:Changing struct name [$$] to struct '
79                                  'name [&&] is prohibited.Please resolve it.')
80    API_CHANGE_INCOMPATIBLE_30 = ('API check error of [api compatibility errors]:Adding struct member [&&] is '
81                                  'prohibited.Please resolve it.')
82    API_CHANGE_INCOMPATIBLE_31 = ('API check error of [api compatibility errors]:Deleting struct member [$$] is '
83                                  'prohibited.Please resolve it.')
84    API_CHANGE_INCOMPATIBLE_32 = ('API check error of [api compatibility errors]:Changing struct member type [$$] to '
85                                  'struct member type [&&] is prohibited.Please resolve it.')
86    API_CHANGE_INCOMPATIBLE_33 = ('API check error of [api compatibility errors]:Changing struct member name [$$] to '
87                                  'struct member name [&&] is prohibited.Please resolve it.')
88    API_CHANGE_INCOMPATIBLE_34 = ('API check error of [api compatibility errors]:Deleting struct [$$] is prohibited.'
89                                  'Please resolve it.')
90    API_CHANGE_INCOMPATIBLE_35 = ('API check error of [api compatibility errors]:Changing struct since [$$] to '
91                                  'struct since [&&] is prohibited.Please resolve it.')
92    API_CHANGE_INCOMPATIBLE_36 = ('API check error of [api compatibility errors]:Changing union name [$$] to '
93                                  'union name [&&] is prohibited.Please resolve it.')
94    API_CHANGE_INCOMPATIBLE_37 = ('API check error of [api compatibility errors]:Adding union member [&&] is '
95                                  'prohibited.Please resolve it.')
96    API_CHANGE_INCOMPATIBLE_38 = ('API check error of [api compatibility errors]:Deleting union member [$$] is '
97                                  'prohibited.Please resolve it.')
98    API_CHANGE_INCOMPATIBLE_39 = ('API check error of [api compatibility errors]:Changing union member type [$$] to '
99                                  'union member type [&&] is prohibited.Please resolve it.')
100    API_CHANGE_INCOMPATIBLE_40 = ('API check error of [api compatibility errors]:Changing union member name [$$] to '
101                                  'union member name [&&] is prohibited.Please resolve it.')
102    API_CHANGE_INCOMPATIBLE_41 = ('API check error of [api compatibility errors]:Deleting union [$$] is prohibited.'
103                                  'Please resolve it.')
104    API_CHANGE_INCOMPATIBLE_42 = ('API check error of [api compatibility errors]:Changing union since [$$] to union '
105                                  'since [&&] is prohibited.Please resolve it.')
106    API_CHANGE_INCOMPATIBLE_43 = ('API check error of [api compatibility errors]:Changing the @library in comments '
107                                  'from no to [&&] is prohibited.Please resolve it.')
108    API_CHANGE_INCOMPATIBLE_44 = ('API check error of [api compatibility errors]:Changing the @library in comments '
109                                  'from [$$] to no is prohibited.Please resolve it.')
110    API_CHANGE_INCOMPATIBLE_45 = ('API check error of [api compatibility errors]:Changing the @library in comments '
111                                  'from [$$] to [&&] is prohibited.Please resolve it.')
112    API_CHANGE_INCOMPATIBLE_46 = ('API check error of [api compatibility errors]:Changing the @permission in comments '
113                                  'is prohibited.Add and relation permission.Please resolve it.')
114    API_CHANGE_INCOMPATIBLE_47 = ('API check error of [api compatibility errors]:Changing the @permission in comments '
115                                  'is prohibited.Reduce or relation permission.Please resolve it.')
116    API_CHANGE_INCOMPATIBLE_48 = ('API check error of [api compatibility errors]:Changing the @permission in comments '
117                                  'is prohibited.Permission value change.Please resolve it.')
118    API_CHANGE_INCOMPATIBLE_49 = ('API check error of [api compatibility errors]:Changing the @syscap in comments '
119                                  'from no to [&&] is prohibited.Please resolve it.')
120    API_CHANGE_INCOMPATIBLE_50 = ('API check error of [api compatibility errors]:Changing the @syscap in comments '
121                                  'from [$$] to no is prohibited.Please resolve it.')
122    API_CHANGE_INCOMPATIBLE_51 = ('API check error of [api compatibility errors]:Changing the @syscap in comments '
123                                  'from [$$] to [&&] is prohibited.Please resolve it.')
124
125    @classmethod
126    def get_rule_message(cls, rule):
127        return cls[rule].value if rule in cls.__members__ else 'None'
128
129
130check_compatibility_command_message = [
131    member.name for name_compatibility_tool,
132    member in CheckCompatibilityErrorMessage.__members__.items()
133]
134
135
136match_diff_and_check_scene_dict = {
137    DiffType.REDUCE_API.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_01.name,
138    DiffType.REDUCE_FILE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_03.name,
139    DiffType.FUNCTION_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_05.name,
140    DiffType.FUNCTION_RETURN_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_06.name,
141    DiffType.FUNCTION_PARAM_POS_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_07.name,
142    DiffType.FUNCTION_PARAM_ADD.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_08.name,
143    DiffType.FUNCTION_PARAM_REDUCE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_09.name,
144    DiffType.FUNCTION_PARAM_TYPE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_10.name,
145    DiffType.VARIABLE_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_11.name,
146    DiffType.CONSTANT_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_12.name,
147    DiffType.VARIABLE_TYPE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_13.name,
148    DiffType.CONSTANT_TYPE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_14.name,
149    DiffType.VARIABLE_CHANGE_TO_CONSTANT.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_15.name,
150    DiffType.CONSTANT_CHANGE_TO_VARIABLE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_16.name,
151    DiffType.VARIABLE_VALUE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_17.name,
152    DiffType.CONSTANT_VALUE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_18.name,
153    DiffType.DEFINE_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_21.name,
154    DiffType.DEFINE_TEXT_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_22.name,
155    DiffType.ENUM_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_24.name,
156    DiffType.ENUM_MEMBER_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_25.name,
157    DiffType.ENUM_MEMBER_VALUE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_26.name,
158    DiffType.ENUM_MEMBER_REDUCE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_28.name,
159    DiffType.STRUCT_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_29.name,
160    DiffType.STRUCT_MEMBER_ADD.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_30.name,
161    DiffType.STRUCT_MEMBER_REDUCE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_31.name,
162    DiffType.STRUCT_MEMBER_TYPE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_32.name,
163    DiffType.STRUCT_MEMBER_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_33.name,
164    DiffType.UNION_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_36.name,
165    DiffType.UNION_MEMBER_ADD.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_37.name,
166    DiffType.UNION_MEMBER_REDUCE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_38.name,
167    DiffType.UNION_MEMBER_TYPE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_39.name,
168    DiffType.UNION_MEMBER_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_40.name,
169    DiffType.DOC_TAG_LIBRARY_NA_TO_HAVE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_43.name,
170    DiffType.DOC_TAG_LIBRARY_HAVE_TO_NA.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_44.name,
171    DiffType.DOC_TAG_LIBRARY_A_TO_B.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_45.name,
172    DiffType.DOC_TAG_PERMISSION_RANGE_SMALLER: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_47.name,
173    DiffType.DOC_TAG_PERMISSION_RANGE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_48.name,
174    DiffType.DOC_TAG_SYSCAP_NA_TO_HAVE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_49.name,
175    DiffType.DOC_TAG_SYSCAP_HAVE_TO_NA.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_50.name,
176    DiffType.DOC_TAG_SYSCAP_A_TO_B.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_51.name,
177}
178