1# Copyright (c) 2020 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/lite/config/subsystem/aafwk/path.gni") 15import("//build/lite/ndk/ndk.gni") 16 17if (ohos_build_ndk_target_host == "linux-x86_64" && 18 ohos_build_compiler == "gcc") { 19 copy("compiler") { 20 sources = [ 21 "//prebuilts/gcc/linux-x86/arm/arm-linux-ohoseabi-gcc/arm-linux-musleabi", 22 "//prebuilts/gcc/linux-x86/arm/arm-linux-ohoseabi-gcc/arm-linux-ohoseabi", 23 "//prebuilts/gcc/linux-x86/arm/arm-linux-ohoseabi-gcc/bin", 24 "//prebuilts/gcc/linux-x86/arm/arm-linux-ohoseabi-gcc/host_bin", 25 "//prebuilts/gcc/linux-x86/arm/arm-linux-ohoseabi-gcc/lib", 26 "//prebuilts/gcc/linux-x86/arm/arm-linux-ohoseabi-gcc/libexec", 27 "//prebuilts/gcc/linux-x86/arm/arm-linux-ohoseabi-gcc/runtime_musl", 28 "//prebuilts/gcc/linux-x86/arm/arm-linux-ohoseabi-gcc/target", 29 ] 30 outputs = [ "$ndk_linux_toolchains_out_dir/{{source_file_part}}" ] 31 } 32} 33 34if (ohos_build_compiler == "clang") { 35 copy("compiler") { 36 sources = [ 37 "//prebuilts/clang/ohos/$ohos_build_ndk_target_host/llvm/NOTICE", 38 "//prebuilts/clang/ohos/$ohos_build_ndk_target_host/llvm/bin", 39 "//prebuilts/clang/ohos/$ohos_build_ndk_target_host/llvm/include", 40 "//prebuilts/clang/ohos/$ohos_build_ndk_target_host/llvm/lib", 41 "//prebuilts/clang/ohos/$ohos_build_ndk_target_host/llvm/libexec", 42 "//prebuilts/clang/ohos/$ohos_build_ndk_target_host/llvm/share", 43 ] 44 if (ohos_build_ndk_target_host == "linux-x86_64") { 45 outputs = [ "$ndk_linux_toolchains_out_dir/{{source_file_part}}" ] 46 } else if (ohos_build_ndk_target_host == "windows-x86_64") { 47 outputs = [ "$ndk_windows_toolchains_out_dir/{{source_file_part}}" ] 48 } 49 } 50} 51 52ndk_toolchains("build_script") { 53 src_type = "file" 54 src_dir = [ 55 "//build/lite/ndk/build/BUILD.gn", 56 "//build/lite/ndk/build/build.py", 57 "//build/lite/ndk/README.md", 58 "//build/lite/ndk/build/.gn", 59 ] 60 dest_dir = [ 61 "$root_out_dir/ndk", 62 "$root_out_dir/ndk", 63 "$root_out_dir/ndk", 64 "$root_out_dir/ndk/build", 65 ] 66} 67 68ndk_toolchains("source") { 69 src_dir = [ 70 "//build/lite/ndk/sample", 71 "//build/lite/ndk/build/config", 72 "//build/lite/ndk/build/toolchain", 73 ] 74 dest_dir = [ 75 "$root_out_dir/ndk/sample", 76 "$root_out_dir/ndk/build/config", 77 "$root_out_dir/ndk/build/toolchain", 78 ] 79 if (ohos_build_compiler == "clang") { 80 src_dir += [ 81 "$root_out_dir/sysroot/usr/lib", 82 "$root_out_dir/sysroot/usr/include", 83 ] 84 dest_dir += [ 85 "$root_out_dir/ndk/sysroot/usr/lib", 86 "$root_out_dir/ndk/sysroot/usr/include", 87 ] 88 } 89 if (host_os == "win") { 90 src_dir += [ "//prebuilts/build-tools/win-x86/bin" ] 91 } else { 92 src_dir += [ "//prebuilts/build-tools/linux-x86/bin" ] 93 } 94 dest_dir += [ "$root_out_dir/ndk/prebuilts/build-tools/bin" ] 95} 96 97group("ndk_build") { 98 deps = [ 99 ":build_script", 100 ":source", 101 "//base/startup/bootstrap_lite/services:bootstrap_lite_ndk", 102 "//base/startup/syspara_lite/frameworks/parameter:parameter_notes", 103 "//base/update/sys_installer_lite/frameworks:update_api", 104 "//build/lite/config/subsystem/hiviewdfx:hilog_ndk", 105 "//commonlibrary/utils_lite:native_api", 106 ] 107 if (ohos_kernel_type != "liteos_m") { 108 deps += [ 109 "${aafwk_lite_path}/frameworks/ability_lite:ability_notes", 110 "${appexecfwk_lite_path}/frameworks/bundle_lite:bundle_notes", 111 "//base/security/permission_lite/interfaces/kits:permission_notes", 112 "//base/sensors/sensor_lite/interfaces/kits/native:sensors_api", 113 "//base/startup/init_lite/interfaces/kits/token:token_notes", 114 "//build/lite/config/component/cJSON:cjson_ndk", 115 "//drivers/hdf_core/adapter/khdf/liteos/ndk:hdf_api", 116 "//foundation/arkui/ui_lite:ui_lite_ndk", 117 "//foundation/graphic/graphic_utils_lite:graphic_utils_lite_ndk", 118 "//foundation/graphic/graphic_utils_lite:lite_graphic_hals_ndk", 119 "//foundation/graphic/surface_lite:surface_lite_ndk", 120 "//foundation/multimedia/media_lite/services:media_ndk", 121 "//foundation/systemabilitymgr/samgr_lite:samgr_lite_ndk", 122 "//foundation/window/window_manager_lite:window_manager_lite_ndk", 123 "//third_party/mbedtls:mbedtls_ndk", 124 "//third_party/wpa_supplicant/wpa_supplicant-2.9:wpa_supplicant", 125 ] 126 } else { 127 deps += [ 128 "$ohos_vendor_adapter_dir/hals/communication/wifi_lite/wifiservice:wifiservice_ndk", 129 "//base/hiviewdfx/hilog_lite/frameworks/mini:hilog_lite_ndk", 130 "//base/iothardware/peripheral:iothardware_ndk", 131 ] 132 } 133} 134 135action("ndk") { 136 if (ohos_build_ndk) { 137 deps = [ "doc" ] 138 script = "//build/lite//ndk/archive_ndk.py" 139 depfile = "${target_gen_dir}/${target_name}.d" 140 ndk_name = "$ohos_build_ndk_target_host-$ohos_build_compiler-$ohos_build_ndk_version" 141 args = [ 142 "--src_dir", 143 rebase_path("$root_build_dir/ndk"), 144 "--name", 145 ndk_name, 146 "--dest_dir", 147 rebase_path("$root_build_dir/packages/ndk"), 148 ] 149 outputs = [ "$root_build_dir/packages/ndk/$ndk_name.zip" ] 150 } 151} 152