Use pre-built files for packaging
[platform/upstream/connectedhomeip.git] / out / host / gen / include / CHIPVersion.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    All rights reserved.
5  *
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
19 /**
20  *    \@file
21  *      This file defines constants and macros for introspecting and
22  *      manipulating CHIP versions.
23  *
24  *      !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!
25  *
26  *      DO NOT EDIT THIS FILE! This file is automatically-generated by
27  *      the '${program}' script.
28  *
29  *      The constants and macros defined here may be used to, for ,
30  *      example, conditionally-compile older, newer, or changed CHIP
31  *      APIs based on the CHIP version. For example:
32  *
33  *          \@code
34  *          #if CHIP_VERSION_CODE >= CHIP_VERSION_CODE_ENCODE(1, 5, 0)
35  *              ...
36  *          #else
37  *              ...
38  *          #endif
39  *          \@endcode
40  *
41  */
42
43 #ifndef CHIP_VERSION_H_
44 #define CHIP_VERSION_H_
45
46 #define _CHIP_VERSION_CODE_MAJOR_WIDTH     8
47 #define _CHIP_VERSION_CODE_MINOR_WIDTH     8
48 #define _CHIP_VERSION_CODE_PATCH_WIDTH     8
49
50 #define _CHIP_VERSION_CODE_MAJOR_MASK     ((1 << _CHIP_VERSION_CODE_MAJOR_WIDTH)  - 1)
51 #define _CHIP_VERSION_CODE_MINOR_MASK     ((1 << _CHIP_VERSION_CODE_MINOR_WIDTH)  - 1)
52 #define _CHIP_VERSION_CODE_PATCH_MASK     ((1 << _CHIP_VERSION_CODE_PATCH_WIDTH)  - 1)
53
54 #define _CHIP_VERSION_CODE_MAJOR_SHIFT    24
55 #define _CHIP_VERSION_CODE_MINOR_SHIFT    16
56 #define _CHIP_VERSION_CODE_PATCH_SHIFT     8
57
58 /**
59  *  \@def CHIP_VERSION_CODE_ENCODE(major, minor, patch)
60  *
61  *  \@brief
62  *    Encode a CHIP version code from its constituent \@a major, \@a minor, and \@a patch
63  *    components.
64  *
65  *    This macro may be used in conjunction with CHIP_VERSION_CODE to, for
66  *    example, conditionally-compile older, newer, or changed CHIP APIs based
67  *    on the CHIP version. For example:
68  *
69  *        \@code
70  *        #if CHIP_VERSION_CODE >= CHIP_VERSION_CODE_ENCODE(1, 5, 0)
71  *            ...
72  *        #else
73  *            ...
74  *        #endif
75  *        \@endcode
76  *
77  */
78 #define CHIP_VERSION_CODE_ENCODE(major, minor, patch)                                    \
79     ((((major)  & _CHIP_VERSION_CODE_MAJOR_MASK)  << _CHIP_VERSION_CODE_MAJOR_SHIFT)  | \
80      (((minor)  & _CHIP_VERSION_CODE_MINOR_MASK)  << _CHIP_VERSION_CODE_MINOR_SHIFT)  | \
81      (((patch)  & _CHIP_VERSION_CODE_PATCH_MASK)  << _CHIP_VERSION_CODE_PATCH_SHIFT))
82
83 /**
84  *  \@def CHIP_VERSION_CODE_DECODE_MAJOR(code)
85  *
86  *  \@brief
87  *    Decode a CHIP major version component from a CHIP version \@a code.
88  *
89  */
90 #define CHIP_VERSION_CODE_DECODE_MAJOR(code)  (((code) >> _CHIP_VERSION_CODE_MAJOR_SHIFT)  & _CHIP_VERSION_CODE_MAJOR_MASK)
91
92 /**
93  *  \@def CHIP_VERSION_CODE_DECODE_MINOR(code)
94  *
95  *  \@brief
96  *    Decode a CHIP minor version component from a CHIP version \@a code.
97  *
98  */
99 #define CHIP_VERSION_CODE_DECODE_MINOR(code)  (((code) >> _CHIP_VERSION_CODE_MINOR_SHIFT)  & _CHIP_VERSION_CODE_MINOR_MASK)
100
101 /**
102  *  \@def CHIP_VERSION_CODE_DECODE_PATCH(code)
103  *
104  *  \@brief
105  *    Decode a CHIP patch version component from a CHIP version \@a code.
106  *
107  */
108 #define CHIP_VERSION_CODE_DECODE_PATCH(code)  (((code) >> _CHIP_VERSION_CODE_PATCH_SHIFT)  & _CHIP_VERSION_CODE_PATCH_MASK)
109
110 /**
111  *  \@def CHIP_VERSION_MAJOR
112  *
113  *  \@brief
114  *    The CHIP version major component, as an unsigned integer.
115  *
116  */
117 #define CHIP_VERSION_MAJOR               0
118
119 /**
120  *  \@def CHIP_VERSION_MINOR
121  *
122  *  \@brief
123  *    The CHIP version minor component, as an unsigned integer.
124  *
125  */
126 #define CHIP_VERSION_MINOR               0
127
128 /**
129  *  \@def CHIP_VERSION_PATCH
130  *
131  *  \@brief
132  *    The CHIP version patch component, as an unsigned integer.
133  *
134  */
135 #define CHIP_VERSION_PATCH               0
136
137 /**
138  *  \@def CHIP_VERSION_EXTRA
139  *
140  *  \@brief
141  *    The CHIP version extra component, as a quoted C string.
142  *
143  */
144 #define CHIP_VERSION_EXTRA               ""
145
146 /**
147  *  \@def CHIP_VERSION_STRING
148  *
149  *  \@brief
150  *    The CHIP version, as a quoted C string.
151  *
152  */
153 #define CHIP_VERSION_STRING              "0.0.0"
154
155 /**
156  *  \@def CHIP_VERSION_CODE
157  *
158  *  \@brief
159  *    The CHIP version, including the major, minor, and patch components,
160  *    encoded as an unsigned integer.
161  *
162  *    This macro may be used in conjunction with CHIP_VERSION_CODE_ENCODE
163  *    to, for example, conditionally-compile older, newer, or changed CHIP
164  *    APIs based on the CHIP version. For example:
165  *
166  *        \@code
167  *        #if CHIP_VERSION_CODE >= CHIP_VERSION_CODE_ENCODE(1, 5, 0)
168  *            ...
169  *        #else
170  *            ...
171  *        #endif
172  *        \@endcode
173  *
174  */
175 #define CHIP_VERSION_CODE                CHIP_VERSION_CODE_ENCODE( \
176           CHIP_VERSION_MAJOR,                                      \
177           CHIP_VERSION_MINOR,                                      \
178           CHIP_VERSION_PATCH                                       \
179         )
180
181 #endif /* CHIP_VERSION_H_ */