1# Copyright (c) 2022 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 14cflags = [ 15 "-DCOAP_SUPPORT_SOCKET_BROADCAST", 16 "-DCOAP_USER_DEFAULT_PORT=5684", 17] 18 19if (defined(ohos_lite)) { 20 import("//build/lite/config/component/lite_component.gni") 21 cflags += [ 22 "-Wall", 23 "-fPIC", 24 "-std=c99", 25 ] 26 cflags_cc = cflags 27 ldflags = [ "-fPIC" ] 28 config("libcoap_config") { 29 include_dirs = [ 30 "include", 31 "//third_party/bounds_checking_function/include", 32 ] 33 defines = [ "_GNU_SOURCE" ] 34 } 35 source_set("libcoap_src") { 36 sources = [ 37 "src/address.c", 38 "src/async.c", 39 "src/block.c", 40 "src/coap_asn1.c", 41 "src/coap_cache.c", 42 "src/coap_debug.c", 43 "src/coap_event.c", 44 "src/coap_gnutls.c", 45 "src/coap_hashkey.c", 46 "src/coap_io.c", 47 "src/coap_mbedtls.c", 48 "src/coap_notls.c", 49 "src/coap_openssl.c", 50 "src/coap_prng.c", 51 "src/coap_session.c", 52 "src/coap_tcp.c", 53 "src/coap_time.c", 54 "src/coap_tinydtls.c", 55 "src/encode.c", 56 "src/mem.c", 57 "src/net.c", 58 "src/option.c", 59 "src/pdu.c", 60 "src/resource.c", 61 "src/str.c", 62 "src/subscribe.c", 63 "src/uri.c", 64 ] 65 configs += [ ":libcoap_config" ] 66 } 67 static_library("libcoap_static") { 68 deps = [ 69 ":libcoap_src", 70 "//third_party/bounds_checking_function:libsec_static", 71 ] 72 public_configs = [ ":libcoap_config" ] 73 } 74 75 shared_library("libcoap") { 76 deps = [ 77 ":libcoap_src", 78 "//third_party/bounds_checking_function:libsec_shared", 79 ] 80 public_configs = [ ":libcoap_config" ] 81 } 82} else { 83 import("//build/ohos.gni") 84 cflags_cc = cflags 85 86 config("libcoap_config") { 87 include_dirs = [ 88 "include", 89 "//third_party/bounds_checking_function/include", 90 ] 91 } 92 93 ohos_source_set("libcoap_src") { 94 sources = [ 95 "src/address.c", 96 "src/async.c", 97 "src/block.c", 98 "src/coap_asn1.c", 99 "src/coap_cache.c", 100 "src/coap_debug.c", 101 "src/coap_event.c", 102 "src/coap_gnutls.c", 103 "src/coap_hashkey.c", 104 "src/coap_io.c", 105 "src/coap_mbedtls.c", 106 "src/coap_notls.c", 107 "src/coap_openssl.c", 108 "src/coap_prng.c", 109 "src/coap_session.c", 110 "src/coap_tcp.c", 111 "src/coap_time.c", 112 "src/coap_tinydtls.c", 113 "src/encode.c", 114 "src/mem.c", 115 "src/net.c", 116 "src/option.c", 117 "src/pdu.c", 118 "src/resource.c", 119 "src/str.c", 120 "src/subscribe.c", 121 "src/uri.c", 122 ] 123 configs = [ ":libcoap_config" ] 124 } 125 126 ohos_static_library("libcoap_static") { 127 deps = [ 128 ":libcoap_src", 129 "//third_party/bounds_checking_function:libsec_static", 130 ] 131 public_configs = [ ":libcoap_config" ] 132 } 133 134 ohos_shared_library("libcoap") { 135 deps = [ 136 ":libcoap_src", 137 "//third_party/bounds_checking_function:libsec_shared", 138 ] 139 public_configs = [ ":libcoap_config" ] 140 subsystem_name = "communication" 141 if (defined(oem_commercial_build) && oem_commercial_build) { 142 part_name = "softbus" 143 } else { 144 defines = [ "STANDARD_SYSTEM_ENABLE" ] 145 part_name = "dsoftbus_standard" 146 } 147 } 148} 149