| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // |
| 3 | // Copyright (C) 2024 The Android Open Source Project |
| 4 | |
| 5 | package { |
| 6 | default_applicable_licenses: ["Android-Apache-2.0"], |
| 7 | } |
| 8 | |
| 9 | soong_config_module_type { |
| 10 | name: "optee_client_cflags_cc_defaults", |
| 11 | module_type: "cc_defaults", |
| 12 | config_namespace: "optee_client", |
| 13 | bool_variables: [ |
| 14 | "cfg_debug", |
| 15 | "cfg_werror", |
| 16 | ], |
| 17 | properties: ["cflags"], |
| 18 | } |
| 19 | |
| 20 | optee_client_cflags_cc_defaults { |
| 21 | name: "optee_client_cflags_defaults", |
| 22 | cflags: [ |
| 23 | "-c", |
| 24 | "-fPIC", |
| 25 | "-Wall", |
| 26 | "-Wbad-function-cast", |
| 27 | "-Wcast-align", |
| 28 | "-Werror-implicit-function-declaration", |
| 29 | "-Wextra", |
| 30 | "-Wfloat-equal", |
| 31 | "-Wformat-nonliteral", |
| 32 | "-Wformat-security", |
| 33 | "-Wformat=2", |
| 34 | "-Winit-self", |
| 35 | "-Wmissing-declarations", |
| 36 | "-Wmissing-format-attribute", |
| 37 | "-Wmissing-include-dirs", |
| 38 | "-Wmissing-noreturn", |
| 39 | "-Wmissing-prototypes", |
| 40 | "-Wnested-externs", |
| 41 | "-Wpointer-arith", |
| 42 | "-Wshadow", |
| 43 | "-Wstrict-prototypes", |
| 44 | "-Wswitch-default", |
| 45 | "-Wwrite-strings", |
| 46 | ], |
| 47 | soong_config_variables: { |
| 48 | cfg_debug: { |
| 49 | cflags: [ |
| 50 | "-DDEBUG", |
| 51 | "-O0", |
| 52 | "-g", |
| 53 | ], |
| 54 | }, |
| 55 | cfg_werror: { |
| 56 | cflags: ["-Werror"], |
| 57 | }, |
| 58 | }, |
| 59 | } |
| 60 | |
| 61 | soong_config_module_type { |
| 62 | name: "optee_client_libteec_cc_defaults", |
| 63 | module_type: "cc_defaults", |
| 64 | config_namespace: "optee_client", |
| 65 | bool_variables: [ |
| 66 | "cfg_tee_benchmark", |
| 67 | ], |
| 68 | value_variables: [ |
| 69 | "cfg_tee_client_log_level", |
| 70 | "cfg_tee_client_log_file", |
| 71 | "cfg_tee_fs_parent_path", |
| 72 | ], |
| 73 | properties: [ |
| 74 | "cflags", |
| 75 | "defaults", |
| 76 | "srcs", |
| 77 | ], |
| 78 | } |
| 79 | |
| 80 | optee_client_libteec_cc_defaults { |
| 81 | name: "optee_client_libteec_log_file_defaults", |
| 82 | soong_config_variables: { |
| 83 | cfg_tee_fs_parent_path: { |
| 84 | cflags: ["-DTEEC_LOG_FILE=\"%s/teec.log\""], |
| 85 | conditions_default: { |
| 86 | cflags: ["-DTEEC_LOG_FILE=\"/data/vendor/tee/teec.log\""], |
| 87 | }, |
| 88 | }, |
| 89 | }, |
| 90 | } |
| 91 | |
| 92 | optee_client_libteec_cc_defaults { |
| 93 | name: "optee_client_libteec_defaults", |
| 94 | soong_config_variables: { |
| 95 | cfg_tee_benchmark: { |
| 96 | cflags: ["-DCFG_TEE_BENCHMARK"], |
| 97 | srcs: ["teec_benchmark.c"], |
| 98 | }, |
| 99 | cfg_tee_client_log_level: { |
| 100 | cflags: ["-DDEBUGLEVEL_%s"], |
| 101 | conditions_default: { |
| 102 | cflags: ["-DDEBUGLEVEL_2"], |
| 103 | }, |
| 104 | }, |
| 105 | cfg_tee_client_log_file: { |
| 106 | cflags: ["-DTEEC_LOG_FILE=\"%s\""], |
| 107 | conditions_default: { |
| 108 | defaults: ["optee_client_libteec_log_file_defaults"], |
| 109 | }, |
| 110 | }, |
| 111 | cfg_tee_fs_parent_path: { |
| 112 | cflags: ["-DTEE_FS_PARENT_PATH=\"%s\""], |
| 113 | conditions_default: { |
| 114 | cflags: ["-DTEE_FS_PARENT_PATH=\"/data/vendor/tee\""], |
| 115 | }, |
| 116 | }, |
| 117 | }, |
| 118 | } |
| 119 | |
| 120 | cc_library_shared { |
| 121 | name: "libteec", |
| 122 | vendor: true, |
| 123 | compile_multilib: "both", |
| 124 | defaults: [ |
| 125 | "optee_client_cflags_defaults", |
| 126 | "optee_client_libteec_defaults", |
| 127 | ], |
| 128 | cflags: [ |
| 129 | "-DBINARY_PREFIX=\"TEEC\"", |
| 130 | ], |
| 131 | srcs: [ |
| 132 | "libteec/src/tee_client_api.c", |
| 133 | "libteec/src/teec_trace.c", |
| 134 | ], |
| 135 | local_include_dirs: [ |
| 136 | "libteec/include", |
| 137 | "libteec/src", |
| 138 | ], |
| 139 | export_include_dirs: ["libteec/include"], |
| 140 | } |
| 141 | |
| 142 | cc_library_shared { |
| 143 | name: "libckteec", |
| 144 | vendor: true, |
| 145 | compile_multilib: "both", |
| 146 | defaults: ["optee_client_cflags_defaults"], |
| 147 | srcs: [ |
| 148 | "libckteec/src/ck_debug.c", |
| 149 | "libckteec/src/ck_helpers.c", |
| 150 | "libckteec/src/invoke_ta.c", |
| 151 | "libckteec/src/pkcs11_api.c", |
| 152 | "libckteec/src/pkcs11_processing.c", |
| 153 | "libckteec/src/pkcs11_token.c", |
| 154 | "libckteec/src/serialize_ck.c", |
| 155 | "libckteec/src/serializer.c", |
| 156 | ], |
| 157 | shared_libs: ["libteec"], |
| 158 | local_include_dirs: [ |
| 159 | "libckteec/include", |
| 160 | "libteec/include", |
| 161 | ], |
| 162 | export_include_dirs: ["libckteec/include"], |
| 163 | } |
| 164 | |
| 165 | soong_config_module_type { |
| 166 | name: "optee_client_tee_supplicant_cc_defaults", |
| 167 | module_type: "cc_defaults", |
| 168 | config_namespace: "optee_client", |
| 169 | bool_variables: [ |
| 170 | "cfg_ftrace_support", |
| 171 | "cfg_gp_sockets", |
| 172 | "cfg_ta_gprof_support", |
| 173 | "cfg_tee_supp_plugins", |
| 174 | "rpmb_emu", |
| 175 | ], |
| 176 | value_variables: [ |
| 177 | "cfg_tee_client_load_path", |
| 178 | "cfg_tee_fs_parent_path", |
| 179 | "cfg_tee_plugin_load_path", |
| 180 | "cfg_tee_supp_log_level", |
| 181 | ], |
| 182 | properties: [ |
| 183 | "cflags", |
| 184 | "defaults", |
| 185 | "ldflags", |
| 186 | "srcs", |
| 187 | ], |
| 188 | } |
| 189 | |
| 190 | optee_client_tee_supplicant_cc_defaults { |
| 191 | name: "optee_client_tee_supplicant_plugin_load_path_defaults", |
| 192 | multilib: { |
| 193 | lib32: { |
| 194 | cflags: ["-DTEE_PLUGIN_LOAD_PATH=\"/vendor/lib/tee-supplicant/plugins/\""], |
| 195 | ldflags: ["-Wl,-rpath=/vendor/lib/tee-supplicant/plugins/"], |
| 196 | }, |
| 197 | lib64: { |
| 198 | cflags: ["-DTEE_PLUGIN_LOAD_PATH=\"/vendor/lib64/tee-supplicant/plugins/\""], |
| 199 | ldflags: ["-Wl,-rpath=/vendor/lib64/tee-supplicant/plugins/"], |
| 200 | }, |
| 201 | }, |
| 202 | } |
| 203 | |
| 204 | optee_client_tee_supplicant_cc_defaults { |
| 205 | name: "optee_client_tee_supplicant_plugin_defaults", |
| 206 | soong_config_variables: { |
| 207 | cfg_tee_plugin_load_path: { |
| 208 | cflags: ["-DTEE_PLUGIN_LOAD_PATH=\"%s\""], |
| 209 | ldflags: ["-Wl,-rpath=%s"], |
| 210 | conditions_default: { |
| 211 | defaults: ["optee_client_tee_supplicant_plugin_load_path_defaults"], |
| 212 | }, |
| 213 | }, |
| 214 | }, |
| 215 | } |
| 216 | |
| 217 | optee_client_tee_supplicant_cc_defaults { |
| 218 | name: "optee_client_tee_supplicant_prof_defaults", |
| 219 | srcs: ["tee-supplicant/src/prof.c"], |
| 220 | } |
| 221 | |
| 222 | optee_client_tee_supplicant_cc_defaults { |
| 223 | name: "optee_client_tee_supplicant_defaults", |
| 224 | soong_config_variables: { |
| 225 | cfg_ftrace_support: { |
| 226 | cflags: ["-DCFG_FTRACE_SUPPORT"], |
| 227 | defaults: ["optee_client_tee_supplicant_prof_defaults"], |
| 228 | }, |
| 229 | cfg_gp_sockets: { |
| 230 | cflags: ["-DCFG_GP_SOCKETS=1"], |
| 231 | srcs: ["tee-supplicant/src/tee_socket.c"], |
| 232 | }, |
| 233 | cfg_ta_gprof_support: { |
| 234 | cflags: ["-DCFG_TA_GPROF_SUPPORT"], |
| 235 | defaults: ["optee_client_tee_supplicant_prof_defaults"], |
| 236 | }, |
| 237 | cfg_tee_client_load_path: { |
| 238 | cflags: ["-DTEEC_LOAD_PATH=\"%s\""], |
| 239 | conditions_default: { |
| 240 | cflags: ["-DTEEC_LOAD_PATH=\"/vendor/lib\""], |
| 241 | }, |
| 242 | }, |
| 243 | cfg_tee_fs_parent_path: { |
| 244 | cflags: ["-DTEE_FS_PARENT_PATH=\"%s\""], |
| 245 | conditions_default: { |
| 246 | cflags: ["-DTEE_FS_PARENT_PATH=\"/data/vendor/tee\""], |
| 247 | }, |
| 248 | }, |
| 249 | cfg_tee_supp_log_level: { |
| 250 | cflags: ["-DDEBUGLEVEL_%s"], |
| 251 | conditions_default: { |
| 252 | cflags: ["-DDEBUGLEVEL_2"], |
| 253 | }, |
| 254 | }, |
| 255 | cfg_tee_supp_plugins: { |
| 256 | srcs: ["tee-supplicant/src/plugin.c"], |
| 257 | cflags: ["-DTEE_SUPP_PLUGINS"], |
| 258 | defaults: ["optee_client_tee_supplicant_plugin_defaults"], |
| 259 | }, |
| 260 | rpmb_emu: { |
| 261 | cflags: ["-DRPMB_EMU=1"], |
| 262 | srcs: [ |
| 263 | "tee-supplicant/src/hmac_sha2.c", |
| 264 | "tee-supplicant/src/sha2.c", |
| 265 | ], |
| 266 | }, |
| 267 | }, |
| 268 | } |
| 269 | |
| 270 | cc_binary { |
| 271 | name: "tee-supplicant", |
| 272 | vendor: true, |
| 273 | defaults: [ |
| 274 | "optee_client_cflags_defaults", |
| 275 | "optee_client_tee_supplicant_defaults", |
| 276 | ], |
| 277 | cflags: [ |
| 278 | "-DBINARY_PREFIX=\"TEES\"", |
| 279 | "-pthread", |
| 280 | ], |
| 281 | srcs: [ |
| 282 | "tee-supplicant/src/handle.c", |
| 283 | "tee-supplicant/src/rpmb.c", |
| 284 | "tee-supplicant/src/tee_supp_fs.c", |
| 285 | "tee-supplicant/src/tee_supplicant.c", |
| 286 | "tee-supplicant/src/teec_ta_load.c", |
| 287 | ], |
| 288 | shared_libs: ["libteec"], |
| 289 | local_include_dirs: [ |
| 290 | "libteec/include", |
| 291 | "libteec/src", |
| 292 | "tee-supplicant/src", |
| 293 | ], |
| 294 | } |