|
| 1 | +# Copyright 2025 meator |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +project( |
| 16 | + 'android-tools-static', |
| 17 | + 'c', 'cpp', |
| 18 | + version: files('VERSION.txt'), |
| 19 | + license: 'Apache-2.0', |
| 20 | + default_options: [ |
| 21 | + # android-tools and its dependencies produce a crap ton of warnings. |
| 22 | + # since this project won't attempt to fix them (it is just a build system |
| 23 | + # port), do not enable extensive warnings. |
| 24 | + 'warning_level=0', |
| 25 | + 'c_std=gnu11', |
| 26 | + 'cpp_std=gnu++20', |
| 27 | + ], |
| 28 | + # The protobuf wrap is the wrap which requires the newest Meson. |
| 29 | + # meson_version is set to the highest requirement of any of its wraps. |
| 30 | + meson_version: '>=0.63.0' |
| 31 | +) |
| 32 | + |
| 33 | +if meson.get_compiler('cpp').get_id() == 'msvc' |
| 34 | + error( |
| 35 | + 'android-tools is not compatible with native MSVC! A Cygwin-like', |
| 36 | + 'environmentis needed to compile this project (for example Cygwin, MSYS2).' |
| 37 | + ) |
| 38 | +endif |
| 39 | + |
| 40 | +if host_machine.endian() == 'big' |
| 41 | + error( |
| 42 | + 'One of android-tools\' internal dependencies, BoringSSL, is incompatible', |
| 43 | + 'with big endian systems such as ppc and ppc64 (but not ppc64le). Please', |
| 44 | + 'see the following link for more info:', |
| 45 | + 'https://boringssl.googlesource.com/boringssl/+/9cffd74fdb65c69506a0ce1b19420a67ad0cb19e/include/openssl/target.h#58' |
| 46 | + ) |
| 47 | +endif |
| 48 | + |
| 49 | +# Android provides it's own version of mke2fs which is incompatible with |
| 50 | +# the version shipped by e2fsprogs. To prevent a name clash we install |
| 51 | +# androids version of mke2fs under a different name. This name can be |
| 52 | +# configured here. |
| 53 | +# |
| 54 | +# See also: https://bugs.archlinux.org/task/56955 |
| 55 | +android_mke2fs_name = 'mke2fs.android' |
| 56 | + |
| 57 | +if host_machine.system() == 'darwin' |
| 58 | + add_project_arguments( |
| 59 | + '-D_DARWIN_C_SOURCE', '-D__DARWIN_C_LEVEL=__DARWIN_C_FULL', |
| 60 | + language: ['c', 'cpp'] |
| 61 | + ) |
| 62 | +endif |
| 63 | + |
| 64 | +CXX = meson.get_compiler('cpp') |
| 65 | +CC = meson.get_compiler('c') |
| 66 | +foreach comp_data: [['c', CC], ['cpp', CXX]] |
| 67 | + lang = comp_data[0] |
| 68 | + comp = comp_data[1] |
| 69 | + |
| 70 | + if comp.has_argument('-ftrivial-auto-var-init=zero') |
| 71 | + add_project_arguments('-ftrivial-auto-var-init=zero', language: lang) |
| 72 | + else |
| 73 | + if comp.has_multi_arguments( |
| 74 | + '-ftrivial-auto-var-init=zero', |
| 75 | + '-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang' |
| 76 | + ) |
| 77 | + add_project_arguments( |
| 78 | + '-ftrivial-auto-var-init=zero', |
| 79 | + '-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang', |
| 80 | + language: lang |
| 81 | + ) |
| 82 | + endif |
| 83 | + endif |
| 84 | +endforeach |
| 85 | + |
| 86 | +# Android seems to use various attributes supported by clang but not by |
| 87 | +# GCC which causes it to emit lots of warnings. Since these attributes |
| 88 | +# don't seem to effect runtime behaviour simply disable the warnings. |
| 89 | +foreach lang: ['c', 'cpp'] |
| 90 | + if meson.get_compiler(lang).get_argument_syntax() == 'gcc' |
| 91 | + add_project_arguments('-Wno-attributes', language: lang) |
| 92 | + endif |
| 93 | +endforeach |
| 94 | + |
| 95 | +# libfsmgr (required by fastboot) requires a 64-bit off_t for lseek. On |
| 96 | +# 32-bit glibc platforms this is not the case by default. |
| 97 | +add_global_arguments( |
| 98 | + '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE64_SOURCE', |
| 99 | + language: ['c', 'cpp'] |
| 100 | +) |
| 101 | + |
| 102 | +version_header = files('version.h.in') |
| 103 | +subdir('meson') |
| 104 | +version_header_inc = include_directories('meson') |
| 105 | + |
| 106 | +subdir('vendor') |
| 107 | + |
| 108 | +subdir('completions') |
| 109 | + |
| 110 | +if get_option('generate_sbom_data') |
| 111 | + nmeum_patches = [] |
| 112 | + foreach dirname, patchlist: nmeum_submodule_patches |
| 113 | + foreach patch: patchlist |
| 114 | + nmeum_patches += dirname / patch |
| 115 | + endforeach |
| 116 | + endforeach |
| 117 | + |
| 118 | + added_patches = [] |
| 119 | + foreach dirname, patchlist: added_submodule_patches |
| 120 | + foreach patch: patchlist |
| 121 | + added_patches += dirname / patch |
| 122 | + endforeach |
| 123 | + endforeach |
| 124 | + |
| 125 | + configure_file( |
| 126 | + command: [ |
| 127 | + 'SBOM_scripts/save_args.py', |
| 128 | + '@OUTPUT@', |
| 129 | + nmeum_patches |
| 130 | + ], |
| 131 | + install_dir: get_option('licensedir'), |
| 132 | + output: 'nmeum_patches.bin', |
| 133 | + ) |
| 134 | + |
| 135 | + configure_file( |
| 136 | + command: [ |
| 137 | + 'SBOM_scripts/save_args.py', |
| 138 | + '@OUTPUT@', |
| 139 | + added_patches |
| 140 | + ], |
| 141 | + install_dir: get_option('licensedir'), |
| 142 | + output: 'added_patches.bin', |
| 143 | + ) |
| 144 | +endif |
0 commit comments