1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 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 17 #ifndef ANDROID_HARDWARE_VERSION_MACRO_H 18 #define ANDROID_HARDWARE_VERSION_MACRO_H 19 20 #if !defined(MAJOR_VERSION) || !defined(MINOR_VERSION) 21 #error "MAJOR_VERSION and MINOR_VERSION must be defined" 22 #endif 23 24 /** Allows macro expansion for x and add surrounding `<>`. 25 * Is intended to be used for version dependant includes as 26 * `#include` do not macro expand if starting with < or " 27 * Example usage: 28 * #include PATH(path/to/FILE_VERSION/file) 29 * @note: uses the implementation-define "Computed Includes" feature. 30 */ 31 #define PATH(x) <x> 32 33 #define CONCAT_3(a, b, c) a##b##c 34 #define EXPAND_CONCAT_3(a, b, c) CONCAT_3(a, b, c) 35 /** The directory name of the version: <major>.<minor> */ 36 #define FILE_VERSION EXPAND_CONCAT_3(MAJOR_VERSION, ., MINOR_VERSION) 37 38 #define CONCAT_4(a, b, c, d) a##b##c##d 39 #define EXPAND_CONCAT_4(a, b, c, d) CONCAT_4(a, b, c, d) 40 /** The c++ namespace of the version: V<major>_<minor> */ 41 #define CPP_VERSION EXPAND_CONCAT_4(V, MAJOR_VERSION, _, MINOR_VERSION) 42 43 #endif // ANDROID_HARDWARE_VERSION_MACRO_H 44