Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
335589a02d | ||
|
|
8825da8881 | ||
|
|
7827bb0408 | ||
|
|
7e10ca27d5 | ||
|
|
bd5f0acc18 | ||
|
|
2aed6fd98f | ||
|
|
64f208f615 | ||
|
|
910602d3f8 | ||
|
|
d7fd259d43 | ||
|
|
dfd0b4efb7 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -11,3 +11,7 @@ build/
|
|||||||
core.*
|
core.*
|
||||||
version.txt
|
version.txt
|
||||||
demo/test_handle_logger
|
demo/test_handle_logger
|
||||||
|
cmake-build-debug
|
||||||
|
GPATH
|
||||||
|
GRTAGS
|
||||||
|
GTAGS
|
||||||
|
|||||||
104
.gitlab-ci.yml
104
.gitlab-ci.yml
@@ -1,42 +1,86 @@
|
|||||||
image: "git.mesalab.cn:7443/mesa_framework/framework-build-env:master"
|
image: "git.mesalab.cn:7443/mesa_platform/build-env:master"
|
||||||
|
variables:
|
||||||
|
GIT_STRATEGY: "clone"
|
||||||
|
BUILD_PADDING_PREFIX: /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX/
|
||||||
|
INSTALL_PREFIX: "/opt/MESA/lib/"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
#- test
|
|
||||||
#- package
|
|
||||||
- release
|
|
||||||
|
|
||||||
variables:
|
.build_by_travis:
|
||||||
ARTIFACTS_JOB: "build"
|
before_script:
|
||||||
|
- mkdir -p $BUILD_PADDING_PREFIX/$CI_PROJECT_NAMESPACE/
|
||||||
build:
|
- ln -s $CI_PROJECT_DIR $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
|
||||||
|
- cd $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
|
||||||
|
- chmod +x ./ci/travis.sh
|
||||||
|
script:
|
||||||
|
- yum makecache
|
||||||
|
- ./ci/travis.sh
|
||||||
|
- cd build
|
||||||
|
tags:
|
||||||
|
- share
|
||||||
|
|
||||||
|
branch_build_debug:
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
extends: .build_by_travis
|
||||||
- mkdir -p build
|
|
||||||
- cd build
|
|
||||||
- cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PREFIX_PATH=$BUILD_PREFIX
|
|
||||||
- make
|
|
||||||
- make package
|
|
||||||
tags:
|
|
||||||
- share
|
|
||||||
variables:
|
variables:
|
||||||
BUILD_TYPE: "Debug"
|
BUILD_TYPE: Debug
|
||||||
BUILD_PREFIX: "/opt/MESA/"
|
except:
|
||||||
only:
|
- /^develop.*$/i
|
||||||
|
- /^master.*$/i
|
||||||
- tags
|
- tags
|
||||||
- pushes
|
|
||||||
- master
|
|
||||||
|
|
||||||
|
branch_build_release:
|
||||||
|
stage: build
|
||||||
|
variables:
|
||||||
|
BUILD_TYPE: RelWithDebInfo
|
||||||
|
extends: .build_by_travis
|
||||||
|
except:
|
||||||
|
- /^develop.*$/i
|
||||||
|
- /^master.*$/i
|
||||||
|
- tags
|
||||||
|
|
||||||
|
develop_build_debug:
|
||||||
|
stage: build
|
||||||
|
extends: .build_by_travis
|
||||||
|
variables:
|
||||||
|
BUILD_TYPE: Debug
|
||||||
|
PACKAGE: 1
|
||||||
artifacts:
|
artifacts:
|
||||||
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME-debug"
|
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-debug"
|
||||||
paths:
|
paths:
|
||||||
- ./build/*.rpm
|
- build/*.rpm
|
||||||
|
only:
|
||||||
|
- /^develop.*$/i
|
||||||
|
- /^master.*$/i
|
||||||
|
|
||||||
release:
|
develop_build_release:
|
||||||
stage: release
|
stage: build
|
||||||
tags:
|
extends: .build_by_travis
|
||||||
- share
|
variables:
|
||||||
|
BUILD_TYPE: RelWithDebInfo
|
||||||
|
PACKAGE: 1
|
||||||
|
artifacts:
|
||||||
|
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-release"
|
||||||
|
paths:
|
||||||
|
- build/*.rpm
|
||||||
|
only:
|
||||||
|
- /^develop.*$/i
|
||||||
|
- /^master.*$/i
|
||||||
|
|
||||||
|
|
||||||
|
release_build_release:
|
||||||
|
stage: build
|
||||||
|
variables:
|
||||||
|
BUILD_TYPE: RelWithDebInfo
|
||||||
|
PACKAGE: 1
|
||||||
|
UPLOAD: 1
|
||||||
|
PULP3_REPO_NAME: framework-stable-x86_64.el7
|
||||||
|
PULP3_DIST_NAME: framework-stable-x86_64.el7
|
||||||
|
extends: .build_by_travis
|
||||||
|
artifacts:
|
||||||
|
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-release"
|
||||||
|
paths:
|
||||||
|
- build/*.rpm
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
- master
|
|
||||||
script:
|
|
||||||
- /bin/bash -x ./autorelease.sh $CI_API_V4_URL $CI_PROJECT_URL $CI_PROJECT_ID $CI_TOKEN $CI_COMMIT_TAG $ARTIFACTS_JOB $CI_PROJECT_NAME
|
|
||||||
@@ -4,6 +4,9 @@ set(lib_name MESA_handle_logger)
|
|||||||
|
|
||||||
project (${lib_name})
|
project (${lib_name})
|
||||||
|
|
||||||
|
set(LIB_MAJOR_VERSION 1)
|
||||||
|
set(LIB_MINOR_VERSION 1)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
||||||
include(Version)
|
include(Version)
|
||||||
|
|
||||||
@@ -12,56 +15,50 @@ set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -Wall)
|
|||||||
set(CMAKE_INSTALL_PREFIX /opt/MESA)
|
set(CMAKE_INSTALL_PREFIX /opt/MESA)
|
||||||
|
|
||||||
#for ASAN
|
#for ASAN
|
||||||
option(ENABLE_SANITIZE_ADDRESS "Enable AddressSanitizer" FALSE)
|
set(ASAN_OPTION "OFF" CACHE STRING " set asan type chosen by the user, using OFF as default")
|
||||||
option(ENABLE_SANITIZE_THREAD "Enable ThreadSanitizer" FALSE)
|
set_property(CACHE ASAN_OPTION PROPERTY STRINGS OFF ADDRESS THREAD)
|
||||||
|
message(STATUS "ASAN_OPTION='${ASAN_OPTION}'")
|
||||||
|
|
||||||
if(ENABLE_SANITIZE_ADDRESS)
|
if(ASAN_OPTION MATCHES "ADDRESS")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
set(CMAKE_C_FLAGS "${CMAKADDRESS} -g -DCMAKE_BUILD_TYPE=Debug -fsanitize=address -fno-omit-frame-pointer")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DCMAKE_BUILD_TYPE=Debug -fsanitize=address -fno-omit-frame-pointer")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lasan")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lasan")
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lasan")
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lasan")
|
||||||
elseif(ENABLE_SANITIZE_THREAD)
|
elseif(ASAN_OPTION MATCHES "THREAD")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -DCMAKE_BUILD_TYPE=Debug -fsanitize=thread -fno-omit-frame-pointer")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DCMAKE_BUILD_TYPE=Debug -fsanitize=thread -fno-omit-frame-pointer")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lasan")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lasan")
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lasan")
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lasan")
|
||||||
endif()
|
endif()
|
||||||
# end of for ASAN
|
# end of for ASAN
|
||||||
|
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/inc/)
|
include_directories(${PROJECT_SOURCE_DIR}/inc/)
|
||||||
|
|
||||||
file(GLOB SRC
|
|
||||||
"src/*.c"
|
|
||||||
"src/*.cpp"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Shared Library Output
|
# Shared Library Output
|
||||||
add_library(${lib_name}_shared SHARED ${SRC})
|
add_library(${lib_name}_shared SHARED src/MESA_handle_logger.c)
|
||||||
if(DEFINED MESA_SHARED_INSTALL_DIR)
|
if(DEFINED MESA_SHARED_INSTALL_DIR)
|
||||||
set_target_properties(${lib_name}_shared PROPERTIES OUTPUT_NAME ${lib_name} LIBRARY_OUTPUT_DIRECTORY ${MESA_SHARED_INSTALL_DIR})
|
set_target_properties(${lib_name}_shared PROPERTIES OUTPUT_NAME ${lib_name} LIBRARY_OUTPUT_DIRECTORY ${MESA_SHARED_INSTALL_DIR})
|
||||||
else()
|
else()
|
||||||
set_target_properties(${lib_name}_shared PROPERTIES OUTPUT_NAME ${lib_name})
|
set_target_properties(${lib_name}_shared PROPERTIES OUTPUT_NAME ${lib_name})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#set_target_properties(${lib_name}_shared PROPERTIES VERSION ${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION})
|
||||||
|
#set_target_properties(${lib_name}_shared PROPERTIES SOVERSION ${LIB_MAJOR_VERSION})
|
||||||
|
|
||||||
|
|
||||||
# static Library Output
|
# static Library Output
|
||||||
add_library(${lib_name}_static STATIC ${SRC})
|
add_library(${lib_name}_static STATIC src/MESA_handle_logger.c)
|
||||||
set_target_properties(${lib_name}_static PROPERTIES OUTPUT_NAME ${lib_name})
|
set_target_properties(${lib_name}_static PROPERTIES OUTPUT_NAME ${lib_name})
|
||||||
|
|
||||||
set(CMAKE_INSTALL_PREFIX /opt/MESA)
|
set(CMAKE_INSTALL_PREFIX /opt/MESA)
|
||||||
|
|
||||||
install(TARGETS ${lib_name}_shared LIBRARY DESTINATION
|
install(TARGETS ${lib_name}_shared LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib COMPONENT LIBRARIES)
|
||||||
${CMAKE_INSTALL_PREFIX}/lib)
|
install(FILES inc/${lib_name}.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MESA COMPONENT HEADER)
|
||||||
install(FILES inc/${lib_name}.h DESTINATION
|
|
||||||
${CMAKE_INSTALL_PREFIX}/include/MESA COMPONENT devel)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
file(GLOB DEMO
|
add_executable(${lib_name}_demo demo/test_handle_logger.c)
|
||||||
"demo/*.c"
|
|
||||||
"demo/*.cpp"
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(${lib_name}_demo ${DEMO})
|
|
||||||
target_link_libraries(${lib_name}_demo rt pthread ${lib_name}_static)
|
target_link_libraries(${lib_name}_demo rt pthread ${lib_name}_static)
|
||||||
|
|
||||||
include(Package)
|
include(Package)
|
||||||
|
|||||||
9
README
9
README
@@ -4,13 +4,16 @@
|
|||||||
*Author:yangwei@iie.ac.cn
|
*Author:yangwei@iie.ac.cn
|
||||||
*History:
|
*History:
|
||||||
2014-03-24 created by yw
|
2014-03-24 created by yw
|
||||||
1)first version
|
1)第一个动态库版本
|
||||||
|
|
||||||
2014-04-16 modified by yw
|
2014-04-16 modified by yw
|
||||||
1)strict inspection parameters, compatible with g++ 4.4.4
|
1) 支持g++ 4.4.4编译
|
||||||
|
|
||||||
2014-05-29 update by yw
|
2014-05-29 update by yw
|
||||||
1)create directory is supported
|
1)支持创建用户指定的日志目录
|
||||||
|
|
||||||
|
2019-2-18 update by yw
|
||||||
|
1)性能优化,句柄中存储文件fp,定期flush至文件
|
||||||
-------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------
|
||||||
NOTICE:
|
NOTICE:
|
||||||
1)compatible with g++, extern with c;
|
1)compatible with g++, extern with c;
|
||||||
|
|||||||
48
ci/get-nprocessors.sh
Normal file
48
ci/get-nprocessors.sh
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright 2017 Google Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions are
|
||||||
|
# met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above
|
||||||
|
# copyright notice, this list of conditions and the following disclaimer
|
||||||
|
# in the documentation and/or other materials provided with the
|
||||||
|
# distribution.
|
||||||
|
# * Neither the name of Google Inc. nor the names of its
|
||||||
|
# contributors may be used to endorse or promote products derived from
|
||||||
|
# this software without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
# This file is typically sourced by another script.
|
||||||
|
# if possible, ask for the precise number of processors,
|
||||||
|
# otherwise take 2 processors as reasonable default; see
|
||||||
|
# https://docs.travis-ci.com/user/speeding-up-the-build/#Makefile-optimization
|
||||||
|
if [ -x /usr/bin/getconf ]; then
|
||||||
|
NPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN)
|
||||||
|
else
|
||||||
|
NPROCESSORS=2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# as of 2017-09-04 Travis CI reports 32 processors, but GCC build
|
||||||
|
# crashes if parallelized too much (maybe memory consumption problem),
|
||||||
|
# so limit to 4 processors for the time being.
|
||||||
|
if [ $NPROCESSORS -gt 4 ] ; then
|
||||||
|
echo "$0:Note: Limiting processors to use by make from $NPROCESSORS to 4."
|
||||||
|
NPROCESSORS=4
|
||||||
|
fi
|
||||||
3
ci/perpare_pulp3_netrc.sh
Normal file
3
ci/perpare_pulp3_netrc.sh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
set -evx
|
||||||
|
echo "machine ${PULP3_SERVER_URL}\nlogin ${PULP3_SERVER_LOGIN}\npassword ${PULP3_SERVER_PASSWORD}\n" > ~/.netrc
|
||||||
61
ci/travis.sh
Normal file
61
ci/travis.sh
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
set -evx
|
||||||
|
|
||||||
|
chmod +x ci/get-nprocessors.sh
|
||||||
|
. ci/get-nprocessors.sh
|
||||||
|
|
||||||
|
# if possible, ask for the precise number of processors,
|
||||||
|
# otherwise take 2 processors as reasonable default; see
|
||||||
|
# https://docs.travis-ci.com/user/speeding-up-the-build/#Makefile-optimization
|
||||||
|
if [ -x /usr/bin/getconf ]; then
|
||||||
|
NPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN)
|
||||||
|
else
|
||||||
|
NPROCESSORS=2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# as of 2017-09-04 Travis CI reports 32 processors, but GCC build
|
||||||
|
# crashes if parallelized too much (maybe memory consumption problem),
|
||||||
|
# so limit to 4 processors for the time being.
|
||||||
|
if [ $NPROCESSORS -gt 4 ] ; then
|
||||||
|
echo "$0:Note: Limiting processors to use by make from $NPROCESSORS to 4."
|
||||||
|
NPROCESSORS=4
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Tell make to use the processors. No preceding '-' required.
|
||||||
|
MAKEFLAGS="j${NPROCESSORS}"
|
||||||
|
export MAKEFLAGS
|
||||||
|
|
||||||
|
env | sort
|
||||||
|
|
||||||
|
# Set default values to OFF for these variables if not specified.
|
||||||
|
: "${NO_EXCEPTION:=OFF}"
|
||||||
|
: "${NO_RTTI:=OFF}"
|
||||||
|
: "${COMPILER_IS_GNUCXX:=OFF}"
|
||||||
|
|
||||||
|
# Install dependency from YUM
|
||||||
|
#yum install -y mrzcpd framework numactl-devel zlib-devel librdkafka-devel systemd-devel
|
||||||
|
mkdir build || true
|
||||||
|
cd build
|
||||||
|
|
||||||
|
cmake3 -DCMAKE_CXX_FLAGS=$CXX_FLAGS \
|
||||||
|
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
|
||||||
|
-DENABLE_DEVEL=$ENABLE_DEVEL_SWITCH \
|
||||||
|
..
|
||||||
|
|
||||||
|
make
|
||||||
|
|
||||||
|
if [ -n "${PACKAGE}" ]; then
|
||||||
|
make package
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${UPLOAD}" ]; then
|
||||||
|
cp ~/rpm_upload_tools.py ./
|
||||||
|
python3 rpm_upload_tools.py ${PULP3_REPO_NAME} ${PULP3_DIST_NAME} *.rpm
|
||||||
|
fi
|
||||||
|
|
||||||
|
#if [ -n "${UPLOAD_SYMBOL_FILES}" ]; then
|
||||||
|
# rpm -i tfe*debuginfo*.rpm
|
||||||
|
# cp /usr/lib/debug/opt/tsg/tfe/bin/tfe.debug /tmp/tfe.debuginfo.${CI_COMMIT_SHORT_SHA}
|
||||||
|
# sentry-cli upload-dif -t elf /tmp/tfe.debuginfo.${CI_COMMIT_SHORT_SHA}
|
||||||
|
#fi
|
||||||
@@ -1,36 +1,54 @@
|
|||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
set(CPACK_PACKAGE_NAME "${lib_name}-debug")
|
set(MY_RPM_NAME_PREFIX "lib${lib_name}-debug")
|
||||||
else()
|
else()
|
||||||
set(CPACK_PACKAGE_NAME ${lib_name})
|
set(MY_RPM_NAME_PREFIX "lib${lib_name}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "Package: ${CPACK_PACKAGE_NAME}")
|
message(STATUS "Package: ${MY_RPM_NAME_PREFIX}")
|
||||||
|
|
||||||
set(CPACK_PACKAGE_VECDOR "MESA")
|
set(CPACK_PACKAGE_VECDOR "MESA")
|
||||||
set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
|
set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
|
||||||
set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
|
set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
|
||||||
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}.${VERSION_BUILD}")
|
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}.${VERSION_BUILD}")
|
||||||
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
|
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||||
|
set(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_BUILD}")
|
||||||
set(CPACK_RPM_PACKAGE_DEBUG 1)
|
execute_process(COMMAND bash -c "echo -ne \"`uname -r | awk -F'.' '{print $5\".\"$6\".\"$7}'`\"" OUTPUT_VARIABLE SYSTEM_VERSION)
|
||||||
|
|
||||||
# RPM Build
|
# RPM Build
|
||||||
set(CPACK_GENERATOR "RPM")
|
set(CPACK_GENERATOR "RPM")
|
||||||
set(CPACK_RPM_AUTO_GENERATED_FILE_NAME ON)
|
|
||||||
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
|
|
||||||
set(CPACK_RPM_PACKAGE_VENDOR "MESA")
|
set(CPACK_RPM_PACKAGE_VENDOR "MESA")
|
||||||
set(CPACK_RPM_PACKAGE_AUTOREQPROV "no")
|
set(CPACK_RPM_PACKAGE_AUTOREQPROV "yes")
|
||||||
set(CPACK_RPM_PACKAGE_RELEASE_DIST on)
|
set(CPACK_RPM_PACKAGE_RELEASE_LIBRARY "on")
|
||||||
set(CPACK_RPM_DEBUGINFO_PACKAGE on)
|
set(CPACK_RPM_DEBUGINFO_PACKAGE "on")
|
||||||
|
set(CPACK_RPM_PACKAGE_DEBUG 1)
|
||||||
|
|
||||||
|
set(CPACK_RPM_COMPONENT_INSTALL ON)
|
||||||
|
set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
|
||||||
|
set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP)
|
||||||
|
set(CPACK_COMPONENT_HEADER_DISPLAY_NAME "develop")
|
||||||
|
set(CPACK_COMPONENT_LIBRARIES_REQUIRED TRUE)
|
||||||
|
set(CPACK_COMPONENT_HEADER_REQUIRED TRUE)
|
||||||
|
set(CPACK_RPM_HEADER_PACKAGE_NAME "${MY_RPM_NAME_PREFIX}-devel")
|
||||||
|
set(CPACK_RPM_LIBRARIES_PACKAGE_NAME ${MY_RPM_NAME_PREFIX})
|
||||||
|
|
||||||
|
set(CPACK_RPM_FILE_NAME "${CPACK_RPM_LIBRARIES_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
|
||||||
|
set(CPACK_RPM_LIBRARIES_DEBUGINFO_FILE_NAME "${CPACK_RPM_LIBRARIES_PACKAGE_NAME}-debuginfo-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
|
||||||
|
set(CPACK_COMPONENT_LIBRARIES_GROUP "libraries")
|
||||||
|
|
||||||
|
set(CPACK_RPM_HEADER_FILE_NAME "${CPACK_RPM_HEADER_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
|
||||||
|
set(CPACK_RPM_HEADER_DEBUGINFO_FILE_NAME "${CPACK_RPM_HEADER_PACKAGE_NAME}-debuginfo-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
|
||||||
|
set(CPACK_COMPONENT_HEADER_GROUP "header")
|
||||||
|
|
||||||
|
set(CPACK_RPM_HEADER_PACKAGE_REQUIRES_PRE ${CPACK_RPM_LIBRARIES_PACKAGE_NAME})
|
||||||
|
set(CPACK_RPM_HEADER_PACKAGE_CONFLICTS ${CPACK_RPM_HEADER_PACKAGE_NAME})
|
||||||
|
|
||||||
|
set(CPACK_COMPONENTS_ALL LIBRARIES HEADER)
|
||||||
|
|
||||||
|
|
||||||
set(CPACK_BUILD_SOURCE_DIRS "${CMAKE_SOURCE_DIR}")
|
set(CPACK_BUILD_SOURCE_DIRS "${CMAKE_SOURCE_DIR}")
|
||||||
|
|
||||||
# Must uninstall the debug package before install release package
|
# Must uninstall the debug package before install release package
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
set(CPACK_RPM_PACKAGE_CONFLICTS ${MY_RPM_NAME_PREFIX})
|
||||||
set(CPACK_RPM_PACKAGE_CONFLICTS "${lib_name}-debug")
|
|
||||||
else()
|
|
||||||
set(CPACK_RPM_PACKAGE_CONFLICTS ${lib_name})
|
|
||||||
# set(CPACK_STRIP_FILES TRUE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
# set(CPACK_STRIP_FILES TRUE)
|
||||||
include(CPack)
|
include(CPack)
|
||||||
|
|||||||
@@ -36,13 +36,18 @@ set(VERSION "${VERSION_MAJOR}_${VERSION_MINOR}_${VERSION_PATCH}")
|
|||||||
set(VERSION_BUILD "${VCS_SHORT_HASH}")
|
set(VERSION_BUILD "${VCS_SHORT_HASH}")
|
||||||
|
|
||||||
# print information
|
# print information
|
||||||
message(STATUS "VERSION: ${VERSION}-${VERSION_BUILD}")
|
message(STATUS "Version: ${VERSION}-${VERSION_BUILD}")
|
||||||
|
|
||||||
|
if(NOT DEFINE_GIT_VERSION)
|
||||||
|
option(DEFINE_GIT_VERSION "Set DEFINE_GIT_VERSION to OFF" OFF)
|
||||||
|
|
||||||
set(GIT_VERSION
|
set(GIT_VERSION
|
||||||
"${VERSION}-${CMAKE_BUILD_TYPE}-${VERSION_BUILD}-${VCS_BRANCH}-${VCS_DATE}")
|
"${VERSION}-${CMAKE_BUILD_TYPE}-${VERSION_BUILD}-${VCS_BRANCH}-${VCS_TAG}-${VCS_DATE}")
|
||||||
|
|
||||||
string(REGEX REPLACE "[-:+/\\.]" "_" GIT_VERSION ${GIT_VERSION})
|
string(REGEX REPLACE "[-:+/\\.]" "_" GIT_VERSION ${GIT_VERSION})
|
||||||
|
|
||||||
add_definitions(-DGIT_VERSION=${GIT_VERSION})
|
if(DEFINE_GIT_VERSION)
|
||||||
|
add_definitions(-DGIT_VERSION=${GIT_VERSION})
|
||||||
|
option(DEFINE_GIT_VERSION "Set DEFINE_GIT_VERSION to OFF" ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
message(STATUS "add GIT_VERSION: ${GIT_VERSION}")
|
endif()
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ void call_logger(int log_num, int thread_num)
|
|||||||
{
|
{
|
||||||
MESA_handle_runtime_log(sample_handle, RLOG_LV_INFO, "sample", "sample_handle MESA_handle_runtime_log, i = %d, thread_num = %d", i, thread_num);
|
MESA_handle_runtime_log(sample_handle, RLOG_LV_INFO, "sample", "sample_handle MESA_handle_runtime_log, i = %d, thread_num = %d", i, thread_num);
|
||||||
//sleep(1);
|
//sleep(1);
|
||||||
//MESA_handle_runtime_log(test_handle, RLOG_LV_INFO, "test", "test_handle MESA_handle_runtime_log, i = %d, thread_num = %d", i, thread_num);
|
MESA_handle_runtime_log(test_handle, RLOG_LV_INFO, "test", "test_handle MESA_handle_runtime_log, i = %d, thread_num = %d", i, thread_num);
|
||||||
//MESA_HANDLE_RUNTIME_LOG(sample_handle, RLOG_LV_FATAL, "sample", "sample_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
//MESA_HANDLE_RUNTIME_LOG(sample_handle, RLOG_LV_FATAL, "sample", "sample_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
||||||
////sleep(1);
|
////sleep(1);
|
||||||
//MESA_HANDLE_RUNTIME_LOG(test_handle, RLOG_LV_FATAL, "test", "test_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
//MESA_HANDLE_RUNTIME_LOG(test_handle, RLOG_LV_FATAL, "test", "test_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
||||||
|
|||||||
@@ -8,15 +8,16 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include<sys/stat.h>
|
#include<sys/stat.h>
|
||||||
|
|
||||||
#define LOGMSG_MAX_LEN 4096
|
int LOGMSG_MAX_LEN = 4096;
|
||||||
#define FLUSH_LOG_NUM 4096
|
int FLUSH_LOG_NUM = 0;
|
||||||
typedef struct log_handle_t
|
typedef struct log_handle_t
|
||||||
{
|
{
|
||||||
int runtime_log_level;
|
int runtime_log_level;
|
||||||
int flush_log_count;
|
int flush_log_count;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
pthread_mutex_t mutex;
|
||||||
char runtime_log_file[1200];
|
char runtime_log_file[1200];
|
||||||
char cur_log_file[LOGMSG_MAX_LEN];
|
char cur_log_file[4096];
|
||||||
} log_handle_t;
|
} log_handle_t;
|
||||||
|
|
||||||
|
|
||||||
@@ -97,7 +98,12 @@ void *MESA_create_runtime_log_handle(const char *file_path, int level)
|
|||||||
{
|
{
|
||||||
if(file_path == NULL)
|
if(file_path == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
char *max_len = getenv("HLOG_MSG_SIZE");
|
||||||
|
char *flush_num = getenv("HLOG_FLUSH_NUM");
|
||||||
|
|
||||||
|
if(max_len != NULL)LOGMSG_MAX_LEN = atoi(max_len);
|
||||||
|
if(flush_num != NULL)FLUSH_LOG_NUM = atoi(flush_num);
|
||||||
|
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
log_handle_t *p_handle = NULL;
|
log_handle_t *p_handle = NULL;
|
||||||
|
|
||||||
@@ -121,6 +127,7 @@ void *MESA_create_runtime_log_handle(const char *file_path, int level)
|
|||||||
strncpy(p_handle->runtime_log_file, file_path, 1024);
|
strncpy(p_handle->runtime_log_file, file_path, 1024);
|
||||||
p_handle->runtime_log_file[1024] = '\0';
|
p_handle->runtime_log_file[1024] = '\0';
|
||||||
p_handle->runtime_log_level = level;
|
p_handle->runtime_log_level = level;
|
||||||
|
pthread_mutex_init(&p_handle->mutex,NULL);
|
||||||
//p_handle->fp = fp;
|
//p_handle->fp = fp;
|
||||||
return (void *)p_handle;
|
return (void *)p_handle;
|
||||||
}
|
}
|
||||||
@@ -142,6 +149,32 @@ void MESA_destroy_runtime_log_handle(void *handle)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void MESA_handle_close_file(log_handle_t *p_handle)
|
||||||
|
{
|
||||||
|
pthread_mutex_lock(&p_handle->mutex);
|
||||||
|
if(p_handle->fp != NULL)
|
||||||
|
{
|
||||||
|
fclose(p_handle->fp);
|
||||||
|
p_handle->fp = NULL;
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&p_handle->mutex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int MESA_handle_open_file(char *file_name, log_handle_t *p_handle)
|
||||||
|
{
|
||||||
|
FILE *fp = NULL;
|
||||||
|
MESA_handle_close_file(p_handle);
|
||||||
|
if(NULL == (fp = fopen(file_name, "a")))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
p_handle->fp = fp;
|
||||||
|
p_handle->flush_log_count = 0;
|
||||||
|
memcpy(p_handle->cur_log_file, file_name, strlen(file_name));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void MESA_handle_runtime_log(void *handle, int level, const char *module, const char *fmt, ...)
|
void MESA_handle_runtime_log(void *handle, int level, const char *module, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char buf[LOGMSG_MAX_LEN + 1];
|
char buf[LOGMSG_MAX_LEN + 1];
|
||||||
@@ -205,37 +238,30 @@ void MESA_handle_runtime_log(void *handle, int level, const char *module, const
|
|||||||
local_time.tm_year + 1900, local_time.tm_mon + 1,
|
local_time.tm_year + 1900, local_time.tm_mon + 1,
|
||||||
local_time.tm_mday);
|
local_time.tm_mday);
|
||||||
|
|
||||||
OPEN_LOG_FILE:
|
|
||||||
if(p_handle->fp == NULL)
|
if(p_handle->fp == NULL)
|
||||||
{
|
{
|
||||||
if(NULL == (fp = fopen(tmp_log_file_name, "a"))) return;
|
if(0 != MESA_handle_open_file(tmp_log_file_name,p_handle))return;
|
||||||
p_handle->fp = fp;
|
|
||||||
p_handle->flush_log_count = 0;
|
|
||||||
memcpy(p_handle->cur_log_file, tmp_log_file_name, strlen(tmp_log_file_name));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 != memcmp(tmp_log_file_name, p_handle->cur_log_file, strlen(tmp_log_file_name)))
|
|
||||||
{
|
|
||||||
fclose(p_handle->fp);
|
|
||||||
p_handle->fp = NULL;
|
|
||||||
goto OPEN_LOG_FILE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 > fprintf(p_handle->fp, "%s", buf))
|
|
||||||
{
|
|
||||||
fclose(p_handle->fp);
|
|
||||||
p_handle->fp = NULL;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p_handle->flush_log_count+=1;
|
if (0 != memcmp(tmp_log_file_name, p_handle->cur_log_file, strlen(tmp_log_file_name)))
|
||||||
if (p_handle->flush_log_count >= FLUSH_LOG_NUM)
|
{
|
||||||
{
|
if(0 != MESA_handle_open_file(tmp_log_file_name,p_handle))return;
|
||||||
fflush(p_handle->fp);
|
}
|
||||||
p_handle->flush_log_count = 0;
|
}
|
||||||
}
|
if (0 > fprintf(p_handle->fp, "%s", buf))
|
||||||
|
{
|
||||||
|
MESA_handle_close_file(p_handle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p_handle->flush_log_count+=1;
|
||||||
|
if (p_handle->flush_log_count >= FLUSH_LOG_NUM)
|
||||||
|
{
|
||||||
|
fflush(p_handle->fp);
|
||||||
|
p_handle->flush_log_count = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user