boot_serial: Unify zcbor include paths
Moves zcbor files to a subdirectory and replaces differing
include path styles to be unified.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
diff --git a/boot/boot_serial/pkg.yml b/boot/boot_serial/pkg.yml
index 19f9a32..aaaf703 100644
--- a/boot/boot_serial/pkg.yml
+++ b/boot/boot_serial/pkg.yml
@@ -31,6 +31,7 @@
- "@apache-mynewt-core/encoding/base64"
- "@mcuboot/boot/mynewt/flash_map_backend"
- "@mcuboot/boot/mynewt/boot_uart"
+ - "@mcuboot/boot/zcbor"
- "@apache-mynewt-core/util/crc"
pkg.req_apis:
diff --git a/boot/boot_serial/src/serial_recovery_cbor.c b/boot/boot_serial/src/serial_recovery_cbor.c
index cda489f..b54fac4 100644
--- a/boot/boot_serial/src/serial_recovery_cbor.c
+++ b/boot/boot_serial/src/serial_recovery_cbor.c
@@ -15,12 +15,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
-
-#ifdef __ZEPHYR__
#include <zcbor_decode.h>
-#else
-#include "zcbor_decode.h"
-#endif
#include "serial_recovery_cbor.h"
diff --git a/boot/boot_serial/src/serial_recovery_cbor.h b/boot/boot_serial/src/serial_recovery_cbor.h
index 90499ff..6bec4e7 100644
--- a/boot/boot_serial/src/serial_recovery_cbor.h
+++ b/boot/boot_serial/src/serial_recovery_cbor.h
@@ -18,12 +18,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
-
-#ifdef __ZEPHYR__
#include <zcbor_decode.h>
-#else
-#include "zcbor_decode.h"
-#endif
#include "serial_recovery_cbor_types.h"
diff --git a/boot/boot_serial/src/serial_recovery_cbor_types.h b/boot/boot_serial/src/serial_recovery_cbor_types.h
index ebf0cd1..57b1095 100644
--- a/boot/boot_serial/src/serial_recovery_cbor_types.h
+++ b/boot/boot_serial/src/serial_recovery_cbor_types.h
@@ -18,12 +18,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
-
-#ifdef __ZEPHYR__
#include <zcbor_decode.h>
-#else
-#include "zcbor_decode.h"
-#endif
#ifdef __cplusplus
extern "C" {
diff --git a/boot/boot_serial/src/serial_recovery_echo.c b/boot/boot_serial/src/serial_recovery_echo.c
index d1aa105..8b10a01 100644
--- a/boot/boot_serial/src/serial_recovery_echo.c
+++ b/boot/boot_serial/src/serial_recovery_echo.c
@@ -8,12 +8,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
-
-#ifdef __ZEPHYR__
#include <zcbor_decode.h>
-#else
-#include "zcbor_decode.h"
-#endif
#include "serial_recovery_echo.h"
diff --git a/boot/boot_serial/src/serial_recovery_echo.h b/boot/boot_serial/src/serial_recovery_echo.h
index b96ae04..9a5d691 100644
--- a/boot/boot_serial/src/serial_recovery_echo.h
+++ b/boot/boot_serial/src/serial_recovery_echo.h
@@ -11,12 +11,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
-
-#ifdef __ZEPHYR__
#include <zcbor_decode.h>
-#else
-#include "zcbor_decode.h"
-#endif
#include "serial_recovery_echo_types.h"
diff --git a/boot/boot_serial/src/serial_recovery_echo_types.h b/boot/boot_serial/src/serial_recovery_echo_types.h
index ef42d5e..0473fea 100644
--- a/boot/boot_serial/src/serial_recovery_echo_types.h
+++ b/boot/boot_serial/src/serial_recovery_echo_types.h
@@ -11,12 +11,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
-
-#ifdef __ZEPHYR__
#include <zcbor_decode.h>
-#else
-#include "zcbor_decode.h"
-#endif
/** Which value for --default-max-qty this file was created with.
*
diff --git a/boot/espressif/CMakeLists.txt b/boot/espressif/CMakeLists.txt
index f9588d5..90dd749 100644
--- a/boot/espressif/CMakeLists.txt
+++ b/boot/espressif/CMakeLists.txt
@@ -72,6 +72,7 @@
set(MCUBOOT_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
set(BOOTUTIL_DIR ${MCUBOOT_ROOT_DIR}/boot/bootutil)
set(BOOT_SERIAL_DIR ${MCUBOOT_ROOT_DIR}/boot/boot_serial)
+set(ZCBOR_DIR ${MCUBOOT_ROOT_DIR}/boot/zcbor)
set(ESPRESSIF_PORT_DIR ${CMAKE_CURRENT_LIST_DIR})
# Find imgtool.
@@ -144,6 +145,7 @@
${BOOTUTIL_DIR}/src/swap_scratch.c
${BOOTUTIL_DIR}/src/tlv.c
)
+set(bootutil_paths)
set(CFLAGS
"-Wno-frame-address"
@@ -220,9 +222,12 @@
list(APPEND bootutil_srcs
${BOOT_SERIAL_DIR}/src/boot_serial.c
${BOOT_SERIAL_DIR}/src/serial_recovery_cbor.c
- ${BOOT_SERIAL_DIR}/src/zcbor_decode.c
- ${BOOT_SERIAL_DIR}/src/zcbor_encode.c
- ${BOOT_SERIAL_DIR}/src/zcbor_common.c
+ ${ZCBOR_DIR}/src/zcbor_decode.c
+ ${ZCBOR_DIR}/src/zcbor_encode.c
+ ${ZCBOR_DIR}/src/zcbor_common.c
+ )
+ list(APPEND bootutil_paths
+ ${ZCBOR_DIR}/include
)
list(APPEND port_srcs
${CMAKE_CURRENT_LIST_DIR}/port/${MCUBOOT_TARGET}/serial_adapter.c
@@ -249,6 +254,7 @@
${BOOT_SERIAL_DIR}/include
${CRYPTO_INC}
${CMAKE_CURRENT_LIST_DIR}/include
+ ${bootutil_paths}
)
target_link_libraries(
diff --git a/boot/boot_serial/src/zcbor_common.h b/boot/zcbor/include/zcbor_common.h
similarity index 100%
rename from boot/boot_serial/src/zcbor_common.h
rename to boot/zcbor/include/zcbor_common.h
diff --git a/boot/boot_serial/src/zcbor_debug.h b/boot/zcbor/include/zcbor_debug.h
similarity index 100%
rename from boot/boot_serial/src/zcbor_debug.h
rename to boot/zcbor/include/zcbor_debug.h
diff --git a/boot/boot_serial/src/zcbor_decode.h b/boot/zcbor/include/zcbor_decode.h
similarity index 100%
rename from boot/boot_serial/src/zcbor_decode.h
rename to boot/zcbor/include/zcbor_decode.h
diff --git a/boot/boot_serial/src/zcbor_encode.h b/boot/zcbor/include/zcbor_encode.h
similarity index 100%
rename from boot/boot_serial/src/zcbor_encode.h
rename to boot/zcbor/include/zcbor_encode.h
diff --git a/boot/zcbor/pkg.yml b/boot/zcbor/pkg.yml
new file mode 100644
index 0000000..f51acce
--- /dev/null
+++ b/boot/zcbor/pkg.yml
@@ -0,0 +1,27 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+pkg.name: boot/zcbor
+pkg.description: Library for encoding and decoding data to/from cbor.
+pkg.author: "Nordic Semiconductor"
+pkg.homepage: "https://github.com/NordicSemiconductor/zcbor"
+pkg.keywords:
+ - zcbor
+
+#pkg.src_dirs: src
diff --git a/boot/boot_serial/src/zcbor_common.c b/boot/zcbor/src/zcbor_common.c
similarity index 100%
rename from boot/boot_serial/src/zcbor_common.c
rename to boot/zcbor/src/zcbor_common.c
diff --git a/boot/boot_serial/src/zcbor_decode.c b/boot/zcbor/src/zcbor_decode.c
similarity index 99%
rename from boot/boot_serial/src/zcbor_decode.c
rename to boot/zcbor/src/zcbor_decode.c
index ba357e1..c99fc83 100644
--- a/boot/boot_serial/src/zcbor_decode.c
+++ b/boot/zcbor/src/zcbor_decode.c
@@ -13,8 +13,8 @@
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
-#include "zcbor_decode.h"
-#include "zcbor_common.h"
+#include <zcbor_decode.h>
+#include <zcbor_common.h>
/** Return value length from additional value.
diff --git a/boot/boot_serial/src/zcbor_encode.c b/boot/zcbor/src/zcbor_encode.c
similarity index 100%
rename from boot/boot_serial/src/zcbor_encode.c
rename to boot/zcbor/src/zcbor_encode.c