diff --git a/mqtt/BUILD.gn b/mqtt/BUILD.gn index 83607420709100c4c867eae84acb2c5483f7aee9..0a7c2fe36c63674d6d764ddb7f2e9c172b8ee52b 100755 --- a/mqtt/BUILD.gn +++ b/mqtt/BUILD.gn @@ -2,18 +2,38 @@ # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v2.0 -# and Eclipse Distribution License v1.0 which accompany this distribution. +# and Eclipse Distribution License v1.0 which accompany this distribution. # -# The Eclipse Public License is available at +# The Eclipse Public License is available at # https://www.eclipse.org/legal/epl-2.0/ -# and the Eclipse Distribution License is available at +# and the Eclipse Distribution License is available at # http://www.eclipse.org/org/documents/edl-v10.php. -import ("//build/ohos.gni") +import("//build/ohos.gni") -mqtt_path = "//third_party/mqtt" +paho_mqtt_path = "//third_party/mqtt/paho.mqtt.c" mqtt_part_name = "mqtt" -mqtt_subsystem_name = "thirdparty" +mqtt_subsystem_name = "thirdparty" + +declare_args() { + enable_mqtt_test = false +} + +group("libmqtt") { + deps = [ + ":paho-mqtt3a", + ":paho-mqtt3as", + ":paho-mqtt3c", + ":paho-mqtt3cs", + ] + + if (enable_mqtt_test) { + deps += [ + ":mqtt_samples", + ":mqtt_test", + ] + } +} config("mqtt_config") { cflags = [ @@ -39,50 +59,54 @@ config("mqtt_config") { } } - ohos_source_set("mqtt_commom_dynamic") { sources = [ - "${mqtt_path}/src/MQTTTime.c", - "${mqtt_path}/src/MQTTProtocolClient.c", - "${mqtt_path}/src/Clients.c", - "${mqtt_path}/src/utf-8.c", - "${mqtt_path}/src/MQTTPacket.c", - "${mqtt_path}/src/MQTTPacketOut.c", - "${mqtt_path}/src/Messages.c", - "${mqtt_path}/src/Tree.c", - "${mqtt_path}/src/Socket.c", - "${mqtt_path}/src/Log.c", - "${mqtt_path}/src/MQTTPersistence.c", - "${mqtt_path}/src/Thread.c", - "${mqtt_path}/src/MQTTProtocolOut.c", - "${mqtt_path}/src/MQTTPersistenceDefault.c", - "${mqtt_path}/src/SocketBuffer.c", - "${mqtt_path}/src/LinkedList.c", - "${mqtt_path}/src/MQTTProperties.c", - "${mqtt_path}/src/MQTTReasonCodes.c", - "${mqtt_path}/src/Base64.c", - "${mqtt_path}/src/SHA1.c", - "${mqtt_path}/src/WebSocket.c", - "${mqtt_path}/src/Proxy.c", + "${paho_mqtt_path}/src/Base64.c", + "${paho_mqtt_path}/src/Clients.c", + "${paho_mqtt_path}/src/LinkedList.c", + "${paho_mqtt_path}/src/Log.c", + "${paho_mqtt_path}/src/MQTTPacket.c", + "${paho_mqtt_path}/src/MQTTPacketOut.c", + "${paho_mqtt_path}/src/MQTTPersistence.c", + "${paho_mqtt_path}/src/MQTTPersistenceDefault.c", + "${paho_mqtt_path}/src/MQTTProperties.c", + "${paho_mqtt_path}/src/MQTTProtocolClient.c", + "${paho_mqtt_path}/src/MQTTProtocolOut.c", + "${paho_mqtt_path}/src/MQTTReasonCodes.c", + "${paho_mqtt_path}/src/MQTTTime.c", + "${paho_mqtt_path}/src/Messages.c", + "${paho_mqtt_path}/src/Proxy.c", + "${paho_mqtt_path}/src/SHA1.c", + "${paho_mqtt_path}/src/Socket.c", + "${paho_mqtt_path}/src/SocketBuffer.c", + "${paho_mqtt_path}/src/Thread.c", + "${paho_mqtt_path}/src/Tree.c", + "${paho_mqtt_path}/src/WebSocket.c", + "${paho_mqtt_path}/src/utf-8.c", ] if (!defined(PAHO_HIGH_PERFORMANCE)) { sources += [ - "${mqtt_path}/src/StackTrace.c", - "${mqtt_path}/src/Heap.c", + "${paho_mqtt_path}/src/Heap.c", + "${paho_mqtt_path}/src/StackTrace.c", ] - } - include_dirs = [ "${mqtt_path}/src" ] + include_dirs = [ + "adapted/src", + "${paho_mqtt_path}/src", + ] configs = [ ":mqtt_config" ] } ohos_shared_library("paho-mqtt3a") { - include_dirs = [ "${mqtt_path}/src" ] + include_dirs = [ + "adapted/src", + "${paho_mqtt_path}/src", + ] configs = [ ":mqtt_config" ] sources = [ - "${mqtt_path}/src/MQTTAsync.c", - "${mqtt_path}/src/MQTTAsyncUtils.c", + "${paho_mqtt_path}/src/MQTTAsync.c", + "${paho_mqtt_path}/src/MQTTAsyncUtils.c", ] deps = [ ":mqtt_commom_dynamic" ] install_images = [ "system" ] @@ -92,9 +116,12 @@ ohos_shared_library("paho-mqtt3a") { } ohos_shared_library("paho-mqtt3c") { - include_dirs = [ "${mqtt_path}/src" ] + include_dirs = [ + "adapted/src", + "${paho_mqtt_path}/src", + ] configs = [ ":mqtt_config" ] - sources = [ "${mqtt_path}/src/MQTTClient.c" ] + sources = [ "${paho_mqtt_path}/src/MQTTClient.c" ] deps = [ ":mqtt_commom_dynamic" ] install_images = [ "system" ] install_enable = true @@ -103,12 +130,15 @@ ohos_shared_library("paho-mqtt3c") { } ohos_shared_library("paho-mqtt3as") { - include_dirs = [ "${mqtt_path}/src" ] + include_dirs = [ + "adapted/src", + "${paho_mqtt_path}/src", + ] configs = [ ":mqtt_config" ] sources = [ - "${mqtt_path}/src/MQTTAsync.c", - "${mqtt_path}/src/MQTTAsyncUtils.c", - "${mqtt_path}/src/SSLSocket.c", + "${paho_mqtt_path}/src/MQTTAsync.c", + "${paho_mqtt_path}/src/MQTTAsyncUtils.c", + "${paho_mqtt_path}/src/SSLSocket.c", ] deps = [ ":mqtt_commom_dynamic", @@ -121,11 +151,14 @@ ohos_shared_library("paho-mqtt3as") { } ohos_shared_library("paho-mqtt3cs") { - include_dirs = [ "${mqtt_path}/src" ] + include_dirs = [ + "adapted/src", + "${paho_mqtt_path}/src", + ] configs = [ ":mqtt_config" ] sources = [ - "${mqtt_path}/src/MQTTClient.c", - "${mqtt_path}/src/SSLSocket.c", + "${paho_mqtt_path}/src/MQTTClient.c", + "${paho_mqtt_path}/src/SSLSocket.c", ] deps = [ ":mqtt_commom_dynamic", @@ -137,19 +170,294 @@ ohos_shared_library("paho-mqtt3cs") { subsystem_name = "${mqtt_subsystem_name}" } -group("mqtt") -{ +group("mqtt_samples") { + deps = [ + ":MQTTAsync_publish", + ":MQTTAsync_subscribe", + ":MQTTClient_publish", + ":MQTTClient_publish_async", + ":MQTTClient_subscribe", + ":paho_c_pub", + ":paho_c_sub", + ":paho_cs_pub", + ":paho_cs_sub", + ] +} + +config("mqtt_samples_config") { + cflags = [ + "-Wno-unused-variable", + "-Wno-error", + ] + defines = [ "PAHO_MQTT_IMPORTS" ] +} + +template("swanlink_mqtt_samples") { + ohos_executable(target_name) { + include_dirs = [ "${paho_mqtt_path}/src" ] + configs = [ ":mqtt_samples_config" ] + part_name = "${mqtt_part_name}" + subsystem_name = "${mqtt_subsystem_name}" + forward_variables_from(invoker, "*") + } +} + +swanlink_mqtt_samples("MQTTAsync_publish") { + sources = [ "${paho_mqtt_path}/src/samples/MQTTAsync_publish.c" ] + deps = [ ":paho-mqtt3a" ] +} + +swanlink_mqtt_samples("MQTTAsync_subscribe") { + sources = [ "${paho_mqtt_path}/src/samples/MQTTAsync_subscribe.c" ] + deps = [ ":paho-mqtt3a" ] +} + +swanlink_mqtt_samples("MQTTClient_publish") { + sources = [ "${paho_mqtt_path}/src/samples/MQTTClient_publish.c" ] + deps = [ ":paho-mqtt3c" ] +} + +swanlink_mqtt_samples("MQTTClient_publish_async") { + sources = [ "${paho_mqtt_path}/src/samples/MQTTClient_publish_async.c" ] + deps = [ ":paho-mqtt3c" ] +} + +swanlink_mqtt_samples("MQTTClient_subscribe") { + sources = [ "${paho_mqtt_path}/src/samples/MQTTClient_subscribe.c" ] + deps = [ ":paho-mqtt3c" ] +} + +swanlink_mqtt_samples("paho_c_pub") { + sources = [ + "${paho_mqtt_path}/src/samples/paho_c_pub.c", + "${paho_mqtt_path}/src/samples/pubsub_opts.c", + ] + deps = [ + ":mqtt_commom_dynamic", + ":paho-mqtt3as", + ] +} + +swanlink_mqtt_samples("paho_c_sub") { + sources = [ + "${paho_mqtt_path}/src/samples/paho_c_sub.c", + "${paho_mqtt_path}/src/samples/pubsub_opts.c", + ] + deps = [ + ":mqtt_commom_dynamic", + ":paho-mqtt3as", + ] +} + +swanlink_mqtt_samples("paho_cs_pub") { + sources = [ + "${paho_mqtt_path}/src/samples/paho_cs_pub.c", + "${paho_mqtt_path}/src/samples/pubsub_opts.c", + ] deps = [ - "${mqtt_path}:paho-mqtt3a", - "${mqtt_path}:paho-mqtt3c", - "${mqtt_path}:paho-mqtt3as", - "${mqtt_path}:paho-mqtt3cs", + ":mqtt_commom_dynamic", + ":paho-mqtt3cs", ] } -group("mqtt_tests") { +swanlink_mqtt_samples("paho_cs_sub") { + sources = [ + "${paho_mqtt_path}/src/samples/paho_cs_sub.c", + "${paho_mqtt_path}/src/samples/pubsub_opts.c", + ] deps = [ - "${mqtt_path}/src/samples:mqtt_samples", - "${mqtt_path}/test:mqtt_test", + ":mqtt_commom_dynamic", + ":paho-mqtt3cs", ] } + +group("mqtt_test") { + deps = [ + ":sync_client_test", + ":test1", + ":test10", + ":test11", + ":test15", + ":test2", + ":test3", + ":test4", + ":test45", + ":test5", + ":test6", + ":test9", + ":test95", + ":test_mqtt4async", + ":test_mqtt4sync", + ] +} + +config("mqtt_test_config") { + cflags = [ + "-Wno-sign-compare", + "-Wno-unused-variable", + "-Wno-format", + "-Wno-error", + ] +} + +ohos_source_set("mqtt_test_thread") { + include_dirs = [ "${paho_mqtt_path}/src" ] + configs = [ ":mqtt_test_config" ] + defines = [ + "NOSTACKTRACE", + "NOLOG_MESSAGES", + ] + sources = [ "${paho_mqtt_path}/src/Thread.c" ] +} + +ohos_source_set("mqtt_test_dynamic") { + include_dirs = [ "${paho_mqtt_path}/src" ] + configs = [ ":mqtt_test_config" ] + sources = [ + "${paho_mqtt_path}/src/Base64.c", + "${paho_mqtt_path}/src/Clients.c", + "${paho_mqtt_path}/src/LinkedList.c", + "${paho_mqtt_path}/src/Log.c", + "${paho_mqtt_path}/src/MQTTPacket.c", + "${paho_mqtt_path}/src/MQTTPacketOut.c", + "${paho_mqtt_path}/src/MQTTPersistence.c", + "${paho_mqtt_path}/src/MQTTPersistenceDefault.c", + "${paho_mqtt_path}/src/MQTTProperties.c", + "${paho_mqtt_path}/src/MQTTProtocolClient.c", + "${paho_mqtt_path}/src/MQTTProtocolOut.c", + "${paho_mqtt_path}/src/MQTTReasonCodes.c", + "${paho_mqtt_path}/src/MQTTTime.c", + "${paho_mqtt_path}/src/Messages.c", + "${paho_mqtt_path}/src/Proxy.c", + "${paho_mqtt_path}/src/SHA1.c", + "${paho_mqtt_path}/src/Socket.c", + "${paho_mqtt_path}/src/SocketBuffer.c", + "${paho_mqtt_path}/src/Tree.c", + "${paho_mqtt_path}/src/WebSocket.c", + "${paho_mqtt_path}/src/utf-8.c", + ] + + if (!defined(PAHO_HIGH_PERFORMANCE)) { + sources += [ + "${paho_mqtt_path}/src/Heap.c", + "${paho_mqtt_path}/src/StackTrace.c", + ] + } +} + +template("swanlink_mqtt_test") { + ohos_executable(target_name) { + include_dirs = [ "${paho_mqtt_path}/src" ] + configs = [ ":mqtt_test_config" ] + part_name = "${mqtt_part_name}" + subsystem_name = "${mqtt_subsystem_name}" + forward_variables_from(invoker, "*") + } +} + +swanlink_mqtt_test("test1") { + sources = [ "${paho_mqtt_path}/test/test1.c" ] + deps = [ + ":mqtt_test_thread", + ":paho-mqtt3c", + ] +} + +swanlink_mqtt_test("test15") { + sources = [ "${paho_mqtt_path}/test/test15.c" ] + deps = [ + ":mqtt_test_dynamic", + ":mqtt_test_thread", + ":paho-mqtt3c", + ] +} + +swanlink_mqtt_test("test10") { + sources = [ "${paho_mqtt_path}/test/test10.c" ] + deps = [ + ":mqtt_test_dynamic", + ":mqtt_test_thread", + ":paho-mqtt3c", + ] +} + +swanlink_mqtt_test("test2") { + sources = [ "${paho_mqtt_path}/test/test2.c" ] + deps = [ + ":mqtt_test_thread", + ":paho-mqtt3c", + ] +} + +swanlink_mqtt_test("sync_client_test") { + sources = [ "${paho_mqtt_path}/test/sync_client_test.c" ] + deps = [ + ":mqtt_test_thread", + ":paho-mqtt3c", + ] +} + +swanlink_mqtt_test("test_mqtt4sync") { + sources = [ "${paho_mqtt_path}/test/test_mqtt4sync.c" ] + deps = [ + ":mqtt_test_thread", + ":paho-mqtt3c", + ] +} + +swanlink_mqtt_test("test3") { + sources = [ "${paho_mqtt_path}/test/test3.c" ] + deps = [ ":paho-mqtt3cs" ] +} + +swanlink_mqtt_test("test4") { + sources = [ "${paho_mqtt_path}/test/test4.c" ] + deps = [ ":paho-mqtt3a" ] +} + +swanlink_mqtt_test("test45") { + sources = [ "${paho_mqtt_path}/test/test45.c" ] + deps = [ + ":mqtt_test_dynamic", + ":mqtt_test_thread", + ":paho-mqtt3a", + ] +} + +swanlink_mqtt_test("test6") { + sources = [ "${paho_mqtt_path}/test/test6.c" ] + deps = [ ":paho-mqtt3a" ] +} + +swanlink_mqtt_test("test9") { + sources = [ "${paho_mqtt_path}/test/test9.c" ] + deps = [ ":paho-mqtt3a" ] +} + +swanlink_mqtt_test("test95") { + sources = [ "${paho_mqtt_path}/test/test95.c" ] + deps = [ + ":mqtt_test_dynamic", + ":mqtt_test_thread", + ":paho-mqtt3a", + ] +} + +swanlink_mqtt_test("test_mqtt4async") { + sources = [ "${paho_mqtt_path}/test/test_mqtt4async.c" ] + deps = [ ":paho-mqtt3a" ] +} + +swanlink_mqtt_test("test11") { + sources = [ "${paho_mqtt_path}/test/test11.c" ] + deps = [ + ":mqtt_test_dynamic", + ":mqtt_test_thread", + ":paho-mqtt3a", + ] +} + +swanlink_mqtt_test("test5") { + sources = [ "${paho_mqtt_path}/test/test5.c" ] + deps = [ ":paho-mqtt3as" ] +} diff --git a/mqtt/adapted/src/samples/BUILD.gn b/mqtt/adapted/src/samples/BUILD.gn deleted file mode 100755 index 3c3631f013b8d08ea03240cdb66239eaa75c453a..0000000000000000000000000000000000000000 --- a/mqtt/adapted/src/samples/BUILD.gn +++ /dev/null @@ -1,118 +0,0 @@ -# Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# and Eclipse Distribution License v1.0 which accompany this distribution. -# -# The Eclipse Public License is available at -# https://www.eclipse.org/legal/epl-2.0/ -# and the Eclipse Distribution License is available at -# http://www.eclipse.org/org/documents/edl-v10.php. - -import ("//build/ohos.gni") - -mqtt_path = "//third_party/mqtt" -mqtt_part_name = "mqtt" -mqtt_subsystem_name = "thirdparty" - -config("mqtt_samples_config") { - cflags = [ - "-Wno-unused-variable", - "-Wno-error", - ] - defines = [ "PAHO_MQTT_IMPORTS" ] -} - -template("swanlink_mqtt_samples") { - ohos_executable(target_name) { - include_dirs = [ "${mqtt_path}/src" ] - configs = [ ":mqtt_samples_config" ] - part_name = "${mqtt_part_name}" - subsystem_name = "${mqtt_subsystem_name}" - forward_variables_from(invoker, "*") - } -} - -swanlink_mqtt_samples("MQTTAsync_publish") { - sources = [ "${mqtt_path}/src/samples/MQTTAsync_publish.c" ] - deps = [ "${mqtt_path}:paho-mqtt3a" ] -} - -swanlink_mqtt_samples("MQTTAsync_subscribe") { - sources = [ "${mqtt_path}/src/samples/MQTTAsync_subscribe.c" ] - deps = [ "${mqtt_path}:paho-mqtt3a" ] -} - -swanlink_mqtt_samples("MQTTClient_publish") { - sources = [ "${mqtt_path}/src/samples/MQTTClient_publish.c" ] - deps = [ "${mqtt_path}:paho-mqtt3c" ] -} - -swanlink_mqtt_samples("MQTTClient_publish_async") { - sources = [ "${mqtt_path}/src/samples/MQTTClient_publish_async.c" ] - deps = [ "${mqtt_path}:paho-mqtt3c" ] -} - -swanlink_mqtt_samples("MQTTClient_subscribe") { - sources = [ "${mqtt_path}/src/samples/MQTTClient_subscribe.c" ] - deps = [ "${mqtt_path}:paho-mqtt3c" ] -} - -swanlink_mqtt_samples("paho_c_pub") { - sources = [ - "${mqtt_path}/src/samples/paho_c_pub.c", - "${mqtt_path}/src/samples/pubsub_opts.c", - ] - deps = [ - "${mqtt_path}:mqtt_commom_dynamic", - "${mqtt_path}:paho-mqtt3as", - ] -} - -swanlink_mqtt_samples("paho_c_sub") { - sources = [ - "${mqtt_path}/src/samples/paho_c_sub.c", - "${mqtt_path}/src/samples/pubsub_opts.c", - ] - deps = [ - "${mqtt_path}:mqtt_commom_dynamic", - "${mqtt_path}:paho-mqtt3as" - ] -} - -swanlink_mqtt_samples("paho_cs_pub") { - sources = [ - "${mqtt_path}/src/samples/paho_cs_pub.c", - "${mqtt_path}/src/samples/pubsub_opts.c", - ] - deps = [ - "${mqtt_path}:mqtt_commom_dynamic", - "${mqtt_path}:paho-mqtt3cs", - ] -} - -swanlink_mqtt_samples("paho_cs_sub") { - sources = [ - "${mqtt_path}/src/samples/paho_cs_sub.c", - "${mqtt_path}/src/samples/pubsub_opts.c", - ] - deps = [ - "${mqtt_path}:mqtt_commom_dynamic", - "${mqtt_path}:paho-mqtt3cs", - ] -} - -group("mqtt_samples") -{ - deps = [ - ":MQTTAsync_publish", - ":MQTTAsync_subscribe", - ":MQTTClient_publish", - ":MQTTClient_publish_async", - ":MQTTClient_subscribe", - ":paho_c_pub", - ":paho_c_sub", - ":paho_cs_pub", - ":paho_cs_sub", - ] -} \ No newline at end of file diff --git a/mqtt/bundle.json b/mqtt/bundle.json index 7a37ffbaff0845fbc9af4ca54f7fe45c9b66da18..cdba89b480aa589730a06669559d7ba46d44bb5a 100755 --- a/mqtt/bundle.json +++ b/mqtt/bundle.json @@ -25,7 +25,7 @@ "third_party": [] }, "build": { - "sub_component": ["//third_party/mqtt:mqtt"], + "sub_component": ["//third_party/mqtt:libmqtt"], "inner_kits": [], "test": [] } diff --git a/mqtt/docs/rom_integrate.md b/mqtt/docs/rom_integrate.md index 206a4bb6e65d2785414c761cf5b3376fb17d2325..96ddae6ea652e0e6cb4d6e80c2aa4b44d71f2c10 100755 --- a/mqtt/docs/rom_integrate.md +++ b/mqtt/docs/rom_integrate.md @@ -43,7 +43,7 @@ - 三方库源码下载 - 将mqtt-1.3.12源码下载到mqtt目录并将代码拷贝出来。 + 将mqtt-1.3.12源码下载到mqtt目录。 ```shell cd ~/OpenHarmony/third_party/mqtt @@ -86,7 +86,7 @@ }, { "component": "mqtt", - "features": [] + "features": [ "enable_mqtt_test=true" ] } ] }