Add nwcore and nwssl root libraries
All checks were successful
Source release / source-package (push) Successful in 1m4s

This commit is contained in:
Patch Bot
2026-06-04 18:47:56 +00:00
committed by Mario Fetka
parent 4813aa317a
commit 01ed39c1b0
7 changed files with 180 additions and 0 deletions

View File

@@ -274,6 +274,12 @@ add_subdirectory(third_party/libsodium)
set(BUILD_SHARED_LIBS ${_MARS_NWE_SAVED_BUILD_SHARED_LIBS})
add_subdirectory(third_party/matrixssl)
# mars-nwe base libraries. nwcore owns common project infrastructure such as
# logging; nwssl is the temporary SSL/Crypto abstraction on top of MatrixSSL
# OpenSSL-compat until the native API is complete.
add_subdirectory(src/core)
add_subdirectory(src/ssl)
if(ENABLE_DIRECTORY)
set(TINYLDAP_OUTPUT_NAME nwdirectory CACHE STRING "" FORCE)
set(TINYLDAP_BUILD_SHARED ON CACHE BOOL "" FORCE)
@@ -310,6 +316,8 @@ message(STATUS "Install new DOS utilities: ${MARS_NWE_INSTALL_NEW_DOSUTILS}")
message(STATUS "Build DOS utilities: ${MAINTAINER_BUILD} (maintainer build)")
message(STATUS "Build nwdirectory: ${ENABLE_DIRECTORY}")
message(STATUS "Build MatrixSSL programs: ${MARS_NWE_BUILD_MATRIXSSL_PROGRAMS}")
message(STATUS "Build nwcore: ON")
message(STATUS "Build nwssl: ON")
message(STATUS "Maintainer build: ${MAINTAINER_BUILD}")
message(STATUS "Packet Burst support: ${ENABLE_BURSTMODE}")

14
include/core/core.h Normal file
View File

@@ -0,0 +1,14 @@
#ifndef MARS_NWE_CORE_H
#define MARS_NWE_CORE_H
#ifdef __cplusplus
extern "C" {
#endif
const char *nwcore_version(void);
#ifdef __cplusplus
}
#endif
#endif /* MARS_NWE_CORE_H */

15
include/nwssl/nwssl.h Normal file
View File

@@ -0,0 +1,15 @@
#ifndef MARS_NWE_NWSSL_H
#define MARS_NWE_NWSSL_H
#ifdef __cplusplus
extern "C" {
#endif
const char *nwssl_version(void);
int nwssl_init(void);
#ifdef __cplusplus
}
#endif
#endif /* MARS_NWE_NWSSL_H */

66
src/core/CMakeLists.txt Normal file
View File

@@ -0,0 +1,66 @@
find_package(Threads REQUIRED)
set(NWCORE_ZLOG_DIR
"${CMAKE_SOURCE_DIR}/third_party/zlog"
CACHE PATH "Path to bundled zlog source tree")
if(NOT EXISTS "${NWCORE_ZLOG_DIR}/src/zlog.h")
message(FATAL_ERROR "Bundled zlog is required. Run: git submodule update --init --recursive third_party/zlog")
endif()
file(GLOB NWCORE_ZLOG_SOURCES CONFIGURE_DEPENDS
"${NWCORE_ZLOG_DIR}/src/*.c")
list(REMOVE_ITEM NWCORE_ZLOG_SOURCES
"${NWCORE_ZLOG_DIR}/src/zlog_win.c"
"${NWCORE_ZLOG_DIR}/src/zlog-chk-conf.c")
set(NWCORE_BUILD_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/nwcore")
file(MAKE_DIRECTORY "${NWCORE_BUILD_INCLUDE_DIR}")
configure_file(
"${CMAKE_SOURCE_DIR}/include/core/core.h"
"${NWCORE_BUILD_INCLUDE_DIR}/core.h"
COPYONLY)
configure_file(
"${NWCORE_ZLOG_DIR}/src/zlog.h"
"${NWCORE_BUILD_INCLUDE_DIR}/zlog.h"
COPYONLY)
add_library(nwcore SHARED
core.c
${NWCORE_ZLOG_SOURCES})
add_library(mars_nwe::core ALIAS nwcore)
set_target_properties(nwcore PROPERTIES
OUTPUT_NAME nwcore
VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
SOVERSION "${VERSION_MAJOR}")
target_compile_features(nwcore PRIVATE c_std_99)
target_compile_definitions(nwcore PRIVATE
_GNU_SOURCE
MARS_NWE_VERSION_STRING="${MARS_NWE_VERSION}")
target_include_directories(nwcore
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE
"${NWCORE_ZLOG_DIR}/src")
target_link_libraries(nwcore PUBLIC Threads::Threads)
install(TARGETS nwcore
EXPORT mars-nwe-core-targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(DIRECTORY "${NWCORE_BUILD_INCLUDE_DIR}/"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/nwcore")
install(EXPORT mars-nwe-core-targets
NAMESPACE mars_nwe::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/mars-nwe")

10
src/core/core.c Normal file
View File

@@ -0,0 +1,10 @@
#include <core/core.h>
#ifndef MARS_NWE_VERSION_STRING
#define MARS_NWE_VERSION_STRING "unknown"
#endif
const char *nwcore_version(void)
{
return MARS_NWE_VERSION_STRING;
}

51
src/ssl/CMakeLists.txt Normal file
View File

@@ -0,0 +1,51 @@
set(NWSSL_BUILD_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/nwssl")
set(NWSSL_OPENSSL_COMPAT_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include")
file(MAKE_DIRECTORY "${NWSSL_BUILD_INCLUDE_DIR}" "${NWSSL_OPENSSL_COMPAT_INCLUDE_DIR}/openssl")
configure_file(
"${CMAKE_SOURCE_DIR}/include/nwssl/nwssl.h"
"${NWSSL_BUILD_INCLUDE_DIR}/nwssl.h"
COPYONLY)
# Temporary OpenSSL compatibility surface for legacy mars-nwe code. MatrixSSL's
# reduced OpenSSL layer intentionally does not provide md5.h, so expose a small
# MD5 wrapper here until callers move to the real nwssl API.
file(WRITE "${NWSSL_OPENSSL_COMPAT_INCLUDE_DIR}/openssl/md5.h" "#pragma once\n#include <stddef.h>\n#include <stdint.h>\n#include <crypto/cryptoApi.h>\ntypedef psMd5_t MD5_CTX;\nstatic inline int MD5_Init(MD5_CTX *c) { return psMd5Init(c) >= 0 ? 1 : 0; }\nstatic inline int MD5_Update(MD5_CTX *c, const void *data, size_t len) { psMd5Update(c, (const unsigned char *)data, (uint32_t)len); return 1; }\nstatic inline int MD5_Final(unsigned char *md, MD5_CTX *c) { psMd5Final(c, md); return 1; }\n")
add_library(nwssl SHARED nwssl.c)
add_library(mars_nwe::ssl ALIAS nwssl)
set_target_properties(nwssl PROPERTIES
OUTPUT_NAME nwssl
VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
SOVERSION "${VERSION_MAJOR}")
target_compile_features(nwssl PRIVATE c_std_99)
target_compile_definitions(nwssl PRIVATE
_GNU_SOURCE
MARS_NWE_VERSION_STRING="${MARS_NWE_VERSION}")
target_include_directories(nwssl
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE
"${CMAKE_SOURCE_DIR}/include")
target_link_libraries(nwssl
PUBLIC
OpenSSL::SSL
OpenSSL::Crypto)
install(TARGETS nwssl
EXPORT mars-nwe-ssl-targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(DIRECTORY "${NWSSL_BUILD_INCLUDE_DIR}/"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/nwssl")
install(EXPORT mars-nwe-ssl-targets
NAMESPACE mars_nwe::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/mars-nwe")

16
src/ssl/nwssl.c Normal file
View File

@@ -0,0 +1,16 @@
#include <nwssl/nwssl.h>
#include <openssl/ssl.h>
#ifndef MARS_NWE_VERSION_STRING
#define MARS_NWE_VERSION_STRING "unknown"
#endif
const char *nwssl_version(void)
{
return MARS_NWE_VERSION_STRING;
}
int nwssl_init(void)
{
return SSL_library_init();
}