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. 13import("//build/config/arm.gni") 14import("//build/ohos.gni") 15import("./lzma.gni") 16 17config("lzma_config_common") { 18 include_dirs = [ "C" ] 19 cflags = [ 20 "-D_IS_TRY_USE_HW_SHA=0", 21 "-DZ7_AFFINITY_DISABLE", 22 "-Wall", 23 "-Werror", 24 "-Wno-empty-body", 25 "-Wno-enum-conversion", 26 "-Wno-logical-op-parentheses", 27 "-Wno-self-assign", 28 "-Wno-implicit-function-declaration", 29 ] 30 visibility = [ ":*" ] 31} 32 33config("lzma_config_host") { 34 defines = [] 35 defines += [ "target_cpu=${target_cpu}" ] 36 defines += [ "host_toolchain=${host_toolchain}" ] 37 defines += [ "current_toolchain=${current_toolchain}" ] 38 defines += [ "default_toolchain=${default_toolchain}" ] 39} 40 41# on device 42ohos_source_set("lzma_source_arm") { 43 configs = [ ":lzma_config_common" ] 44 public_configs = [ ":lzma_config_common" ] 45 46 include_dirs = [ "Asm/arm" ] 47 cflags = [ "-march=armv7-a" ] 48 ldflags = [ "-lpthread" ] 49 50 sources = common_c_source 51} 52ohos_source_set("lzma_source_riscv64") { 53 configs = [ ":lzma_config_common" ] 54 public_configs = [ ":lzma_config_common" ] 55 cflags = [ "-march=rv64gc" ] 56 sources = common_c_source 57} 58 59# on device 60ohos_source_set("lzma_source_arm64") { 61 branch_protector_ret = "pac_ret" 62 configs = [ ":lzma_config_common" ] 63 public_configs = [ ":lzma_config_common" ] 64 65 include_dirs = [ "Asm/arm64" ] 66 cflags = [ "-march=armv8-a+crc" ] 67 68 sources = common_c_source 69 sources += arm64_asm_source 70} 71 72# on host 73ohos_source_set("lzma_source_x86_host") { 74 configs = [ 75 ":lzma_config_common", 76 ":lzma_config_host", 77 ] 78 public_configs = [ 79 ":lzma_config_common", 80 ":lzma_config_host", 81 ] 82 83 include_dirs = [ "Asm/x86" ] 84 85 sources = common_c_source 86} 87 88#on host 89ohos_source_set("lzma_source_arm64_host") { 90 configs = [ 91 ":lzma_config_common", 92 ":lzma_config_host", 93 ] 94 public_configs = [ 95 ":lzma_config_common", 96 ":lzma_config_host", 97 ] 98 99 include_dirs = [ "Asm/arm64" ] 100 101 sources = common_c_source 102 sources += arm64_asm_source 103} 104 105#on host 106ohos_source_set("lzma_source_riscv64_host") { 107 configs = [ 108 ":lzma_config_common", 109 ":lzma_config_host", 110 ] 111 public_configs = [ 112 ":lzma_config_common", 113 ":lzma_config_host", 114 ] 115 116 sources = common_c_source 117} 118 119# on device 120ohos_shared_library("lzma_shared") { 121 branch_protector_ret = "pac_ret" 122 public_configs = [ ":lzma_config_common" ] 123 124 if (target_cpu == "arm") { 125 deps = [ ":lzma_source_arm" ] 126 } else if (target_cpu == "arm64") { 127 deps = [ ":lzma_source_arm64" ] 128 } else if (target_cpu == "riscv64") { 129 deps = [ ":lzma_source_riscv64" ] 130 } 131 innerapi_tags = [ 132 "chipsetsdk_indirect", 133 "platformsdk_indirect", 134 ] 135 output_name = "lzma" 136 install_images = [ 137 "system", 138 "updater", 139 ] 140 part_name = "lzma" 141 subsystem_name = "thirdparty" 142} 143 144#on host 145ohos_static_library("lzma_static") { 146 public_configs = [ 147 ":lzma_config_common", 148 ":lzma_config_host", 149 ] 150 151 if (current_cpu == "arm64") { 152 deps = [ ":lzma_source_arm64_host" ] 153 } else if (current_cpu == "x86_64" || current_cpu == "x64") { 154 deps = [ ":lzma_source_x86_host" ] 155 } else if (current_cpu == "riscv64") { 156 deps = [ ":lzma_source_riscv64_host" ] 157 } 158 159 part_name = "lzma" 160 subsystem_name = "thirdparty" 161} 162 163group("lzma") { 164 deps = [ 165 ":lzma_shared", 166 ":lzma_static", 167 ] 168} 169