From 1037cb2c0491988335c8c48397cbfd32fb5debbe Mon Sep 17 00:00:00 2001 From: "ethan.du" Date: Fri, 22 Nov 2019 17:38:06 +0800 Subject: [PATCH] optimize makefile --- CMakeLists.txt | 4 ++-- Makefile | 2 +- samples/CMakeLists.txt | 8 ++++---- samples/dev_model/dev_model_sample.c | 15 ++++++--------- samples/ota/ota_sample.c | 15 ++++++--------- samples/samples.mk | 8 ++++---- .../download_file_sample.c} | 0 .../upload_file_sample.c} | 0 .../file_upload.c => upload_file/upload_file.c} | 0 tools/scripts/rules-final.mk | 4 ++-- 10 files changed, 25 insertions(+), 31 deletions(-) rename samples/{http/http_download.c => upload_file/download_file_sample.c} (100%) rename samples/{http/http_upload.c => upload_file/upload_file_sample.c} (100%) rename src/{http/file_upload.c => upload_file/upload_file.c} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d26fd02..949dc89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,8 +110,8 @@ endif () if (ENABLE_FEATURE_UPLOAD_FILE) message("ENABLE_FEATURE_UPLOAD_FILE = y") - AUX_SOURCE_DIRECTORY(src/http FILE_UPLOAD_SRC) - set(src_iot_sdk ${src_iot_sdk} ${FILE_UPLOAD_SRC}) + AUX_SOURCE_DIRECTORY(src/upload_file UPLOAD_FILE_SRC) + set(src_iot_sdk ${src_iot_sdk} ${UPLOAD_FILE_SRC}) else () message("ENABLE_FEATURE_UPLOAD_FILE = n") endif () diff --git a/Makefile b/Makefile index fa7d94f..c1d3e50 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ $(call CompLib_Map, OTA_ENABLED, src/ota/src) $(call CompLib_Map, DEVICE_MODEL_ENABLED, src/dev_model/src) -$(call CompLib_Map, FILE_UPLOAD_ENABLED, src/http) +$(call CompLib_Map, FILE_UPLOAD_ENABLED, src/upload_file) IOTSDK_SRC_FILES := \ diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 95ebcbd..6906cac 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -32,9 +32,9 @@ if (ENABLE_FEATURE_AUTH_MODE_DYNAMIC) endif () if (ENABLE_FEATURE_UPLOAD_FILE) - add_executable(http_download http/http_download.c) - add_dependencies(http_download iot_sdk iot_platform) + add_executable(download_file_sample upload_file/download_file_sample.c) + add_dependencies(download_file_sample iot_sdk iot_platform) - add_executable(http_upload http/http_upload.c) - add_dependencies(http_upload iot_sdk iot_platform) + add_executable(upload_file_sample upload_file/upload_file_sample.c) + add_dependencies(upload_file_sample iot_sdk iot_platform) endif () \ No newline at end of file diff --git a/samples/dev_model/dev_model_sample.c b/samples/dev_model/dev_model_sample.c index e5fbbb6..51d5f7d 100644 --- a/samples/dev_model/dev_model_sample.c +++ b/samples/dev_model/dev_model_sample.c @@ -32,9 +32,6 @@ static void event_handler(void *pClient, void *handle_context, MQTTEventMsg *msg) { - uintptr_t packet_id = 0; - packet_id = (uintptr_t)msg->msg; - switch(msg->event_type) { case MQTT_EVENT_UNDEF: LOG_INFO("undefined event occur.\n"); @@ -49,27 +46,27 @@ static void event_handler(void *pClient, void *handle_context, MQTTEventMsg *msg break; case MQTT_EVENT_SUBSCRIBE_SUCCESS: - LOG_INFO("subscribe success, packet-id=%u.\n", (unsigned int)packet_id); + LOG_INFO("subscribe success.\n"); break; case MQTT_EVENT_SUBSCRIBE_TIMEOUT: - LOG_INFO("subscribe wait ack timeout, packet-id=%u.\n", (unsigned int)packet_id); + LOG_INFO("subscribe wait ack timeout.\n"); break; case MQTT_EVENT_SUBSCRIBE_NACK: - LOG_INFO("subscribe nack, packet-id=%u.\n", (unsigned int)packet_id); + LOG_INFO("subscribe nack.\n"); break; case MQTT_EVENT_PUBLISH_SUCCESS: - LOG_INFO("publish success, packet-id=%u.\n", (unsigned int)packet_id); + LOG_INFO("publish success.\n"); break; case MQTT_EVENT_PUBLISH_TIMEOUT: - LOG_INFO("publish timeout, packet-id=%u.\n", (unsigned int)packet_id); + LOG_INFO("publish timeout.\n"); break; case MQTT_EVENT_PUBLISH_NACK: - LOG_INFO("publish nack, packet-id=%u.\n", (unsigned int)packet_id); + LOG_INFO("publish nack.\n"); break; default: diff --git a/samples/ota/ota_sample.c b/samples/ota/ota_sample.c index e8c9bf3..c204d34 100644 --- a/samples/ota/ota_sample.c +++ b/samples/ota/ota_sample.c @@ -33,9 +33,6 @@ static void event_handler(void *pClient, void *handle_context, MQTTEventMsg *msg) { - uintptr_t packet_id = 0; - packet_id = (uintptr_t)msg->msg; - switch(msg->event_type) { case MQTT_EVENT_UNDEF: LOG_INFO("undefined event occur.\n"); @@ -50,27 +47,27 @@ static void event_handler(void *pClient, void *handle_context, MQTTEventMsg *msg break; case MQTT_EVENT_SUBSCRIBE_SUCCESS: - LOG_INFO("subscribe success, packet-id=%u.\n", (unsigned int)packet_id); + LOG_INFO("subscribe success.\n"); break; case MQTT_EVENT_SUBSCRIBE_TIMEOUT: - LOG_INFO("subscribe wait ack timeout, packet-id=%u.\n", (unsigned int)packet_id); + LOG_INFO("subscribe wait ack timeout.\n"); break; case MQTT_EVENT_SUBSCRIBE_NACK: - LOG_INFO("subscribe nack, packet-id=%u.\n", (unsigned int)packet_id); + LOG_INFO("subscribe nack.\n"); break; case MQTT_EVENT_PUBLISH_SUCCESS: - LOG_INFO("publish success, packet-id=%u.\n", (unsigned int)packet_id); + LOG_INFO("publish success.\n"); break; case MQTT_EVENT_PUBLISH_TIMEOUT: - LOG_INFO("publish timeout, packet-id=%u.\n", (unsigned int)packet_id); + LOG_INFO("publish timeout.\n"); break; case MQTT_EVENT_PUBLISH_NACK: - LOG_INFO("publish nack, packet-id=%u.\n", (unsigned int)packet_id); + LOG_INFO("publish nack.\n"); break; default: LOG_INFO("Should NOT arrive here.\n"); diff --git a/samples/samples.mk b/samples/samples.mk index 601e96c..e9ce382 100644 --- a/samples/samples.mk +++ b/samples/samples.mk @@ -65,16 +65,16 @@ dev_model_sample: endif ifneq (,$(filter -DFILE_UPLOAD_ENABLED,$(CFLAGS))) -http_download: +download_file_sample: $(TOP_Q) \ - $(PLATFORM_CC) $(CFLAGS) $(SAMPLE_DIR)/http/$@.c $(LDFLAGS) -o $@ + $(PLATFORM_CC) $(CFLAGS) $(SAMPLE_DIR)/upload_file/$@.c $(LDFLAGS) -o $@ $(TOP_Q) \ mv $@ $(FINAL_DIR)/bin -http_upload: +upload_file_sample: $(TOP_Q) \ - $(PLATFORM_CC) $(CFLAGS) $(SAMPLE_DIR)/http/$@.c $(LDFLAGS) -o $@ + $(PLATFORM_CC) $(CFLAGS) $(SAMPLE_DIR)/upload_file/$@.c $(LDFLAGS) -o $@ $(TOP_Q) \ mv $@ $(FINAL_DIR)/bin diff --git a/samples/http/http_download.c b/samples/upload_file/download_file_sample.c similarity index 100% rename from samples/http/http_download.c rename to samples/upload_file/download_file_sample.c diff --git a/samples/http/http_upload.c b/samples/upload_file/upload_file_sample.c similarity index 100% rename from samples/http/http_upload.c rename to samples/upload_file/upload_file_sample.c diff --git a/src/http/file_upload.c b/src/upload_file/upload_file.c similarity index 100% rename from src/http/file_upload.c rename to src/upload_file/upload_file.c diff --git a/tools/scripts/rules-final.mk b/tools/scripts/rules-final.mk index 4aaa320..2b975f3 100644 --- a/tools/scripts/rules-final.mk +++ b/tools/scripts/rules-final.mk @@ -16,6 +16,6 @@ endif $(TOP_Q) \ rm -rf ${TEMP_DIR} -.PHONY: mqtt_sample ota_sample shadow_sample dynamic_auth_sample dev_model_sample samples_final smart_bracelet_heart_rate_shadow_sample smart_bracelet_walk_step_shadow_sample +.PHONY: mqtt_sample ota_sample shadow_sample dynamic_auth_sample dev_model_sample samples_final smart_bracelet_heart_rate_shadow_sample smart_bracelet_walk_step_shadow_sample download_file_sample upload_file_sample -final : mqtt_sample ota_sample shadow_sample dynamic_auth_sample dev_model_sample samples_final smart_bracelet_heart_rate_shadow_sample smart_bracelet_walk_step_shadow_sample \ No newline at end of file +final : mqtt_sample ota_sample shadow_sample dynamic_auth_sample dev_model_sample samples_final smart_bracelet_heart_rate_shadow_sample smart_bracelet_walk_step_shadow_sample download_file_sample upload_file_sample \ No newline at end of file