Improve libconfig compile.

This commit is contained in:
fancy 2023-11-11 18:27:33 -08:00
parent f008337684
commit 882af7f6b0
4 changed files with 14 additions and 14 deletions

0
external/libconfig/build_libconfig.sh vendored Normal file → Executable file
View File

View File

@ -4,7 +4,7 @@
#include <gtest/gtest.h>
namespace ConfigTest
{
// ../output_files/test/bin/LogTest --gtest_filter=ConfigTest.Demo
// ../output_files/test/bin/ConfigTest --gtest_filter=ConfigTest.Demo
TEST(ConfigTest, Demo)
{
CreateLogModule();

View File

@ -21,7 +21,7 @@ aux_source_directory(./src SRC_FILES)
set(TARGET_NAME ConfigBase)
add_library(${TARGET_NAME} STATIC ${SRC_FILES})
target_link_libraries(${TARGET_NAME} StatusCode Log config)
target_link_libraries(${TARGET_NAME} StatusCode Log config++)
if ("${CLANG_TIDY_SUPPORT}" MATCHES "true")
add_custom_target(
@ -45,15 +45,15 @@ endif()
# build libconfig before make libConfig.a
add_custom_command(
OUTPUT ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs/libconfig.a
OUTPUT ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs/libconfig++.a
COMMAND echo "Build libconfig-1.7.3. CMAKE_C_COMPILER = ${CMAKE_C_COMPILER}"
# COMMAND tar zxvf libconfig-1.7.3.tar.gz
COMMAND sh build_libconfig.sh ${TARGET_PLATFORM} ${CROSS_COMPILER_PATH} ${CMAKE_C_COMPILER}
WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/libconfig
)
add_custom_target(
config
DEPENDS ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs/libconfig.a
config++
DEPENDS ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs/libconfig++.a
)
# add_custom_command(

View File

@ -16,24 +16,24 @@
#include "ILog.h"
#include "SharedDataCode.h"
#include <cstring>
static const char *SHARED_DATA_NAME = "shared_data";
static const char *SHARED_DATA_NAME = "shared_data";
constexpr short THERE_TWO_USER_DATA_HEADER = 2;
SharedDataCpp::SharedDataCpp(const SHARER_NAME &sharerName, const char *path, const int &projectId)
: SharedMemory(path, projectId), mSharerName(sharerName)
{
mPrimaryReadSize = 0;
mMinorReadSize = 0;
mSharedMemeory = nullptr;
mMinorReadSize = 0;
mSharedMemeory = nullptr;
}
void SharedDataCpp::MakeSharedMemory(const unsigned int readableSize, const unsigned int writableSize)
{
if (SHARER_NAME_PRIMARY == mSharerName) {
mPrimaryReadSize = readableSize;
mMinorReadSize = writableSize;
mMinorReadSize = writableSize;
}
else if (SHARER_NAME_MINOR == mSharerName) {
mPrimaryReadSize = writableSize;
mMinorReadSize = readableSize;
mMinorReadSize = readableSize;
}
else {
LogError("Make shared memory failed.\n");
@ -170,11 +170,11 @@ SharedData *NewSharedDataImpl(const SHARER_NAME &name, const char *path, const i
SharedDataImpl *impl = (SharedDataImpl *)malloc(sizeof(SharedDataImpl));
SharedDataImpl tmp;
memcpy((void *)impl, (void *)&tmp, sizeof(SharedDataImpl));
impl->mHeader.mCheckName = SHARED_DATA_NAME;
impl->mBase.mMakeSharedData = MakeSharedData;
impl->mHeader.mCheckName = SHARED_DATA_NAME;
impl->mBase.mMakeSharedData = MakeSharedData;
impl->mBase.mGetReadableData = GetSharedReadableMemory;
impl->mBase.mSetWritableData = SetSharedWritableMemory;
impl->mBase.mFree = SharedDataImplFree;
impl->mSharedData = std::make_shared<SharedDataCpp>(name, path, projectId);
impl->mBase.mFree = SharedDataImplFree;
impl->mSharedData = std::make_shared<SharedDataCpp>(name, path, projectId);
return (SharedData *)(((char *)impl) + sizeof(SharedDataHeader));
}