1# Copyright (c) 2021 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//build/config/python.gni") 15import("//build/ohos/ndk/ndk.gni") 16import("//build/ohos/sdk/sdk.gni") 17 18package_info_name = "oh-uni-package" 19if (defined(ext_ndk_config_file) && ext_ndk_config_file != "") { 20 ext_ndk_target = rebase_path(ext_ndk_config_file) 21 import(ext_ndk_target) 22 package_info_name = "uni-package" 23} else { 24 import("//build/ohos/ndk/ndk_targets.gni") 25} 26 27package_info_file = "$ndk_os_irrelevant_out_dir/$package_info_name.json" 28 29package_info = { 30 path = "native" 31 displayName = "Native" 32 version = current_ndk_version 33 if (release_type != "") { 34 releaseType = release_type 35 } 36 if (meta_version != "") { 37 meta = { 38 metaVersion = meta_version 39 } 40 } 41 if (defined(ext_ndk_config_file) && ext_ndk_config_file != "") { 42 platformVersion = platform_version 43 } 44 apiVersion = api_version 45} 46write_file(package_info_file, package_info, "json") 47 48action_with_pydeps("_collect_ndk_syscap") { 49 deps = all_ndk_targets_list 50 script = "//build/ohos/ndk/collect_ndk_syscap.py" 51 depfile = "$target_gen_dir/$target_name.d" 52 _ndk_syscap_desc_file = 53 "${ndk_os_irrelevant_out_dir}/ndk_system_capability.json" 54 _native_syscap_config_file = 55 "${ndk_os_irrelevant_out_dir}/nativeapi_syscap_config.json" 56 outputs = [ _ndk_syscap_desc_file ] 57 args = [ 58 "--depfile", 59 rebase_path(depfile, root_build_dir), 60 "--system-capability-file", 61 rebase_path(_ndk_syscap_desc_file, root_build_dir), 62 "--system-capability-header-config", 63 rebase_path(_native_syscap_config_file, root_build_dir), 64 "--targets-build-config", 65 ] 66 foreach(_ndk_target, all_ndk_targets_list) { 67 _target_bc_file = get_label_info(_ndk_target, "target_gen_dir") + "/" + 68 get_label_info(_ndk_target, "name") + ".build_config" 69 args += [ rebase_path(_target_bc_file, root_build_dir) ] 70 } 71} 72 73group("all_ndk_targets") { 74 deps = [ ":_collect_ndk_syscap" ] 75} 76 77ndk_targets = [ 78 ":ndk_doxygen", 79 ":all_ndk_targets", 80 ":merge_ndk_notice", 81 ":verify_ndk_notice_file", 82] 83 84group("ohos_ndk") { 85 deps = ndk_targets 86 if (archive_ndk) { 87 deps += [ ":archive_ndk" ] 88 } 89} 90 91group("ndk_doxygen") { 92 deps = [ 93 ":create_docs_portal_and_archive", 94 ":generate_ndk_docs", 95 ] 96} 97 98# doxygen always generates index.html 99ndk_doxygen_output = "$ndk_docs_out_dir/html" 100ndk_docs_portal = "$ndk_docs_out_dir/index.html" 101 102action_with_pydeps("generate_ndk_docs") { 103 deps = [ ":all_ndk_targets" ] 104 script = "//build/ohos/ndk/generate_ndk_docs.py" 105 depfile = "$target_gen_dir/$target_name.d" 106 107 doxygen_file = "//build/ohos/ndk/Doxyfile" 108 inputs = [ doxygen_file ] 109 110 version = current_ndk_version 111 working_dir = "$ndk_headers_out_dir" 112 113 outputs = [ ndk_doxygen_output ] 114 115 args = [ 116 "--depfile", 117 rebase_path(depfile, root_build_dir), 118 "--working-dir", 119 rebase_path(working_dir, root_build_dir), 120 "--version", 121 version, 122 "--output", 123 rebase_path(ndk_doxygen_output, root_build_dir), 124 "--doxygen-file", 125 rebase_path(doxygen_file, root_build_dir), 126 "--record-path", 127 rebase_path("$target_gen_dir/" + get_path_info(ndk_doxygen_output, "file") + 128 ".md5.stamp", 129 root_build_dir), 130 ] 131} 132 133action_with_pydeps("create_docs_portal_and_archive") { 134 deps = [ ":generate_ndk_docs" ] 135 script = "//build/ohos/ndk/create_ndk_docs_portal.py" 136 depfile = "$target_gen_dir/$target_name.d" 137 args = [ 138 "--depfile", 139 rebase_path(depfile, root_build_dir), 140 "--doxygen-output", 141 rebase_path(ndk_doxygen_output + "/index.html", root_build_dir), 142 "--record-path", 143 rebase_path("$target_gen_dir/" + get_path_info(ndk_docs_portal, "file") + 144 ".md5.stamp", 145 root_build_dir), 146 "--portal-path", 147 rebase_path(ndk_docs_portal, root_build_dir), 148 ] 149 outputs = [ ndk_docs_portal ] 150} 151 152ohos_ndk_copy("ndk_cmake_files") { 153 dest_dir = "$ndk_os_irrelevant_out_dir/build" 154 sources = [ "./cmake" ] 155} 156 157action_with_pydeps("merge_ndk_notice") { 158 deps = [ ":all_ndk_targets" ] 159 script = "//build/ohos/notice/merge_notice_files.py" 160 depfile = "$target_gen_dir/$target_name.d" 161 162 outputs = [ 163 ndk_notice_txt, 164 ndk_notice_gz, 165 ] 166 167 args = [ 168 "--image-name", 169 "ndk", 170 "--notice-root-dir", 171 rebase_path(ndk_notice_dir, root_build_dir), 172 "--output-notice-txt", 173 rebase_path(ndk_notice_txt, root_build_dir), 174 "--output-notice-gz", 175 rebase_path(ndk_notice_gz, root_build_dir), 176 "--notice-title", 177 "Notices for files and software contained in sdk-native in this directory:", 178 "--static-library-notice-dir", 179 rebase_path(static_libraries_notice_dir, root_build_dir), 180 "--target-cpu", 181 target_cpu, 182 "--depfile", 183 rebase_path(depfile, root_build_dir), 184 ] 185} 186 187action("verify_ndk_notice_file") { 188 deps = [ ":merge_ndk_notice" ] 189 190 script = "//build/core/build_scripts/verify_notice.sh" 191 _verify_result = "${target_out_dir}/ndk_notice_verify_result.out" 192 193 outputs = [ _verify_result ] 194 195 args = [ 196 rebase_path(ndk_notice_txt, root_build_dir), 197 rebase_path(_verify_result, root_build_dir), 198 rebase_path(target_out_dir, root_build_dir), 199 ] 200} 201 202group("archive_ndk") { 203 deps = [] 204 if (ndk_platform == "default") { 205 if (host_os == "mac") { 206 deps += [ ":archive_darwin_ndk" ] 207 } else { 208 deps += [ 209 ":archive_linux_ndk", 210 ":archive_windows_ndk", 211 ] 212 } 213 } else if (ndk_platform == "win") { 214 deps += [ ":archive_windows_ndk" ] 215 } else if (ndk_platform == "mac") { 216 deps += [ ":archive_darwin_ndk" ] 217 } else if (ndk_platform == "linux") { 218 deps += [ ":archive_linux_ndk" ] 219 } 220} 221 222action_with_pydeps("archive_windows_ndk") { 223 deps = ndk_targets 224 script = "//build/ohos/ndk/archive_ndk.py" 225 depfile = "$target_gen_dir/$target_name.d" 226 _output = "$ohos_sdk_out_dir/${windows_system}/${ndk_zip_prefix}-${windows_system}-${arch}-${current_ndk_version}" 227 if (release_type != "") { 228 _output += "-${release_type}.zip" 229 } else { 230 _output += ".zip" 231 } 232 233 args = [ 234 "--os-irrelevant-dir", 235 rebase_path(ndk_os_irrelevant_out_dir, root_build_dir), 236 "--output", 237 rebase_path(_output, root_build_dir), 238 "--depfile", 239 rebase_path(depfile, root_build_dir), 240 "--os-specific-dir", 241 rebase_path("$ndk_windows_specific_out_dir", root_build_dir), 242 "--notice-file", 243 rebase_path(ndk_notice_txt, root_build_dir), 244 "--prefix", 245 ndk_zip_prefix, 246 "--record-path", 247 rebase_path( 248 "$target_gen_dir/" + get_path_info(_output, "file") + ".md5.stamp", 249 root_build_dir), 250 "--platform", 251 "windows", 252 ] 253 outputs = [ _output ] 254} 255 256action_with_pydeps("archive_linux_ndk") { 257 deps = ndk_targets 258 script = "//build/ohos/ndk/archive_ndk.py" 259 depfile = "$target_gen_dir/$target_name.d" 260 _output = "$ohos_sdk_out_dir/${linux_system}/${ndk_zip_prefix}-${linux_system}-${arch}-${current_ndk_version}" 261 if (release_type != "") { 262 _output += "-${release_type}.zip" 263 } else { 264 _output += ".zip" 265 } 266 267 args = [ 268 "--os-irrelevant-dir", 269 rebase_path(ndk_os_irrelevant_out_dir, root_build_dir), 270 "--output", 271 rebase_path(_output, root_build_dir), 272 "--depfile", 273 rebase_path(depfile, root_build_dir), 274 "--notice-file", 275 rebase_path(ndk_notice_txt, root_build_dir), 276 "--os-specific-dir", 277 rebase_path("$ndk_linux_specific_out_dir", root_build_dir), 278 "--prefix", 279 ndk_zip_prefix, 280 "--record-path", 281 rebase_path( 282 "$target_gen_dir/" + get_path_info(_output, "file") + ".md5.stamp", 283 root_build_dir), 284 ] 285 outputs = [ _output ] 286} 287 288action_with_pydeps("archive_darwin_ndk") { 289 deps = ndk_targets 290 script = "//build/ohos/ndk/archive_ndk.py" 291 depfile = "$target_gen_dir/$target_name.d" 292 _output = "$ohos_sdk_out_dir/${darwin_system}/${ndk_zip_prefix}-${darwin_system}-${arch}-${current_ndk_version}" 293 if (release_type != "") { 294 _output += "-${release_type}.zip" 295 } else { 296 _output += ".zip" 297 } 298 299 args = [ 300 "--os-irrelevant-dir", 301 rebase_path(ndk_os_irrelevant_out_dir, root_build_dir), 302 "--output", 303 rebase_path(_output, root_build_dir), 304 "--depfile", 305 rebase_path(depfile, root_build_dir), 306 "--notice-file", 307 rebase_path(ndk_notice_txt, root_build_dir), 308 "--os-specific-dir", 309 rebase_path("$ndk_darwin_specific_out_dir", root_build_dir), 310 "--prefix", 311 ndk_zip_prefix, 312 "--record-path", 313 rebase_path( 314 "$target_gen_dir/" + get_path_info(_output, "file") + ".md5.stamp", 315 root_build_dir), 316 ] 317 outputs = [ _output ] 318} 319