Dependencies

Third-Party Libraries in the NYRA Framework

The NYRA framework incorporates several third-party libraries. Some are used primarily for testing, while others are built into the NYRA runtime. Below is an overview of these libraries, along with any custom modifications needed for use in the NYRA framework.


Google gn

Google ninja


Jansson

  • Version: 2.14

  • License: MIT

  • Usage: Used in the NYRA framework core to parse and generate JSON data.

  • Details: See third_party/jansson.


libuv

  • Version: 1.49.2

  • License: MIT

  • Usage: One of the event loop libraries in the NYRA runtime.

  • Details: See third_party/libuv.


msgpack-c

  • Version: 6.0.0

  • License: Boost Software License, Version 1.0

  • Usage: A MessagePack library for C.

  • Details: See third_party/msgpack.


libwebsockets

  • Version: 4.3.2

  • License: MIT

  • Usage: Canonical networking library from libwebsockets.org.

  • Details: See third_party/libwebsockets.

Required Patch #1 (CMakeLists.txt)

--- /home/wei/MyData/Temp/libwebsockets-4.3.2/CMakeLists.txt
+++ libwebsockets/CMakeLists.txt
@@ -851,6 +851,7 @@
  add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
  # Fail the build if any warnings
  add_compile_options(/W3 /WX)
+ add_compile_options(/Zc:preprocessor /wd4819)
  # Unbreak MSVC broken preprocessor __VA_ARGS__ behaviour
  if (MSVC_VERSION GREATER 1925)
   add_compile_options(/Zc:preprocessor /wd5105)

Required Patch #2 (Enable External Variables from mbedtls on Windows)

diff --git a/third_party/libwebsockets/cmake/lws_config.h.in b/third_party/libwebsockets/cmake/lws_config.h.in
index f3f4a9d79..e8d36c3ae 100644
--- a/third_party/libwebsockets/cmake/lws_config.h.in
+++ b/third_party/libwebsockets/cmake/lws_config.h.in
@@ -238,3 +238,9 @@
 #cmakedefine LWS_WITH_PLUGINS_API
 #cmakedefine LWS_HAVE_RTA_PREF

+// NOTE (Liu): The libwebsockets library will use external variables from mbedtls
+// if 'LWS_WITH_MBEDTLS' is enabled. On Windows, variable declarations in the header
+// file must start with '__declspec(dllimport)', otherwise, the
+// symbols cannot be accessed.
+// Refer to third_party/mbedtls/include/mbedtls/export.h.
+#define USING_SHARED_MBEDTLS
diff --git a/third_party/libwebsockets/lib/tls/mbedtls/wrapper/platform/ssl_pm.c b/third_party/libwebsockets/lib/tls/mbedtls/wrapper/platform/ssl_pm.c
index e8a0cb2d4..84a164e90 100755
--- a/third_party/libwebsockets/lib/tls/mbedtls/wrapper/platform/ssl_pm.c
+++ b/third_party/libwebsockets/lib/tls/mbedtls/wrapper/platform/ssl_pm.c
@@ -183,7 +183,12 @@ int ssl_pm_new(SSL *ssl)
         mbedtls_ssl_conf_min_version(&ssl_pm->conf, MBEDTLS_SSL_MAJOR_VERSION_3, version);
     } else {
         mbedtls_ssl_conf_max_version(&ssl_pm->conf, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3);
-    mbedtls_ssl_conf_min_version(&ssl_pm->conf, MBEDTLS_SSL_MAJOR_VERSION_3, 1);
+
+    // NOTE: mbedtls added 'ssl_conf_version_check()' since v3.1.0, and
+    // mbedtls only enables TLS 1.2 by default. So the 'min_tls_version' and
+    // 'max_tls_version' must be '0x303', or 'mbedtls_ssl_setup' will
+    // fail.
+    mbedtls_ssl_conf_min_version(&ssl_pm->conf, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3);
     }

     mbedtls_ssl_conf_rng(&ssl_pm->conf, mbedtls_ctr_drbg_random, &ssl_pm->ctr_drbg);

Fix for Linking mbedtls on Windows

If your CMake version is above 3.24, apply this patch (since find_package supports the GLOBAL keyword from 3.24 onwards):

diff --git a/third_party/libwebsockets/lib/tls/mbedtls/CMakeLists.txt b/third_party/libwebsockets/lib/tls/mbedtls/CMakeLists.txt
index e34151724..79b15089d 100644
--- a/third_party/libwebsockets/lib/tls/mbedtls/CMakeLists.txt
+++ b/third_party/libwebsockets/lib/tls/mbedtls/CMakeLists.txt
-        find_library(MBEDTLS_LIBRARY mbedtls)
-        find_library(MBEDX509_LIBRARY mbedx509)
-        find_library(MBEDCRYPTO_LIBRARY mbedcrypto)
+        # find_library(MBEDTLS_LIBRARY mbedtls)
+        # find_library(MBEDX509_LIBRARY mbedx509)
+        # find_library(MBEDCRYPTO_LIBRARY mbedcrypto)
+
+        # set(LWS_MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}" "${MBEDCRYPTO_LIBRARY}")
+
+        # Set the custom search path.
+        set(MBEDTLS_DIR "${MBEDTLS_BUILD_PATH}/cmake")
+
+        // NOTE (Liu): We should use 'find_package' rather than 'find_library'
+        // to search for the mbedtls libraries. 'find_library' only finds a
+        // single library (shared or static) without extra settings from mbedtls.
+
-        set(LWS_MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}" "${MBEDCRYPTO_LIBRARY}")
+        // The 'lib/tls/CMakeLists.txt' depends on the mbedtls libraries, so we set the scope to 'GLOBAL' here.
+        find_package(MbedTLS GLOBAL)
+        set(LWS_MBEDTLS_LIBRARIES MbedTLS::mbedcrypto MbedTLS::mbedx509 MbedTLS::mbedtls
diff --git a/third_party/libwebsockets/BUILD.gn b/third_party/libwebsockets/BUILD.gn
index 4c89c2e2e..e6d641b9c 100644
--- a/third_party/libwebsockets/BUILD.gn
+++ b/third_party/libwebsockets/BUILD.gn
@@ -84,6 +84,10 @@ cmake_project("websockets") {
   }

   options += [
+  // The libwebsockets will use the 'MBEDTLS_BUILD_PATH' variable to set the
+  // search path of 'find_package'.
+  "MBEDTLS_BUILD_PATH=" + rebase_path("$root_gen_dir/cmake/mbedtls"),
+

Then remove #define USING_SHARED_MBEDTLS in third_party/libwebsockets/cmake/lws_config.h.in.


curl

  • Version: 8.1.2

  • License: MIT-like

  • Usage: Command-line tool & library for data transfers across many protocols.

  • Details: See third_party/curl.

Patch for Shared Library Name in CMakeLists.txt

if(WIN32)
  if(BUILD_SHARED_LIBS)
    if(MSVC)
      # Add "_imp" as a suffix before the extension to avoid conflicting with
      # the statically linked "libcurl.lib"
      # set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_imp.lib")
      set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX ".lib")
    endif()
  endif()
endif()

Export Curl_ws_done in lib/ws.h

CURL_EXTERN void Curl_ws_done(struct Curl_easy *data);
// ^^^^^^^^ ensure this is exposed to prevent memory leaks

clingo

  • Version: 5.6.2

  • License: MIT

  • Usage: A grounder and solver for logic programs.

  • Details: See third_party/clingo.


FFmpeg

  • Version: 6.0

  • License: GPL or LGPL

    • FFmpeg is mostly LGPL with some optional GPL-licensed components. See the LICENSE file for details.

  • Usage: Used in FFmpeg extensions, primarily for testing.

  • Details: See third_party/ffmpeg.


libbacktrace

  • Version: 1.0

  • License: BSD

  • Usage: Produces symbolic backtraces in C/C++ programs.

  • Note: Heavily modified to match NYRA naming conventions and folder structure. See core/src/nyra_utils/backtrace.


uthash

  • Version: 2.3.0

  • License: BSD

  • Usage: Hash tables and more, via C macros.

  • Note: Heavily modified to match NYRA naming and folder structure. See core/include/nyra_utils/container/*.


uuid4

  • License: MIT / WTFPLv2

  • Usage: UUID v4 generation in C.

  • Note: Heavily modified to match NYRA naming conventions. See core/src/nyra_utils/lib/sys/general/uuid.c.


zf_log

  • License: MIT

  • Usage: Core logging library for C/ObjC/C++.

  • Note: Heavily modified to match NYRA naming conventions and folder structure. See core/src/nyra_utils/log.

Last updated