Compare commits
8 Commits
v2.0.8
...
v1.0.10-re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
524bca2714 | ||
|
|
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
|
|
||||||
@@ -7,24 +7,26 @@ project (${lib_name})
|
|||||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
||||||
include(Version)
|
include(Version)
|
||||||
|
|
||||||
|
#SET(CMAKE_C_COMPILER "/usr/bin/g++")
|
||||||
set(CMAKE_MACOSX_RPATH 0)
|
set(CMAKE_MACOSX_RPATH 0)
|
||||||
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -Wall)
|
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
|
||||||
|
|
||||||
@@ -49,10 +51,8 @@ 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 LIBRARY)
|
||||||
${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)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
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_LIBRARY_REQUIRED TRUE)
|
||||||
|
set(CPACK_COMPONENT_HEADER_REQUIRED TRUE)
|
||||||
|
set(CPACK_RPM_HEADER_PACKAGE_NAME "${MY_RPM_NAME_PREFIX}-devel")
|
||||||
|
set(CPACK_RPM_LIBRARY_PACKAGE_NAME ${MY_RPM_NAME_PREFIX})
|
||||||
|
|
||||||
|
set(CPACK_RPM_FILE_NAME "${CPACK_RPM_LIBRARY_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
|
||||||
|
set(CPACK_RPM_LIBRARY_DEBUGINFO_FILE_NAME "${CPACK_RPM_LIBRARY_PACKAGE_NAME}-debuginfo-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
|
||||||
|
set(CPACK_COMPONENT_LIBRARY_GROUP "library")
|
||||||
|
|
||||||
|
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_LIBRARY_PACKAGE_NAME})
|
||||||
|
set(CPACK_RPM_HEADER_PACKAGE_CONFLICTS ${CPACK_RPM_HEADER_PACKAGE_NAME})
|
||||||
|
|
||||||
|
set(CPACK_COMPONENTS_ALL LIBRARY 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,22 +8,17 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include<sys/stat.h>
|
#include<sys/stat.h>
|
||||||
|
|
||||||
#define LOGMSG_MAX_LEN 4096
|
|
||||||
#define FLUSH_LOG_NUM 4096
|
|
||||||
typedef struct log_handle_t
|
typedef struct log_handle_t
|
||||||
{
|
{
|
||||||
int runtime_log_level;
|
int runtime_log_level;
|
||||||
int flush_log_count;
|
|
||||||
FILE *fp;
|
|
||||||
char runtime_log_file[1200];
|
char runtime_log_file[1200];
|
||||||
char cur_log_file[LOGMSG_MAX_LEN];
|
|
||||||
} log_handle_t;
|
} log_handle_t;
|
||||||
|
|
||||||
|
#define THREAD_CTIME(t, buf, len) thread_safe_ctime(t, buf, len)
|
||||||
|
#define LOGMSG_MAX_LEN 4096
|
||||||
|
|
||||||
|
//const int HANDLE_LOGGER_VERSION_20170816 = 1;
|
||||||
//const int HANDLE_LOGGER_VERSION_20190218 = 1;
|
#define GIT_VERSION_CATTER(v) __attribute__((__used__)) const char *GIT_VERSION_##v = NULL
|
||||||
|
|
||||||
#define GIT_VERSION_CATTER(v) __attribute__((__used__)) const char * GIT_VERSION_##v = NULL
|
|
||||||
#define GIT_VERSION_EXPEND(v) GIT_VERSION_CATTER(v)
|
#define GIT_VERSION_EXPEND(v) GIT_VERSION_CATTER(v)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -33,9 +28,9 @@ extern "C"
|
|||||||
|
|
||||||
/* VERSION TAG */
|
/* VERSION TAG */
|
||||||
#ifdef GIT_VERSION
|
#ifdef GIT_VERSION
|
||||||
GIT_VERSION_EXPEND(GIT_VERSION);
|
GIT_VERSION_EXPEND(GIT_VERSION);
|
||||||
#else
|
#else
|
||||||
static __attribute__((__used__)) const char * GIT_VERSION_UNKNOWN = NULL;
|
static __attribute__((__used__)) const char *GIT_VERSION_UNKNOWN = NULL;
|
||||||
#endif
|
#endif
|
||||||
#undef GIT_VERSION_CATTER
|
#undef GIT_VERSION_CATTER
|
||||||
#undef GIT_VERSION_EXPEND
|
#undef GIT_VERSION_EXPEND
|
||||||
@@ -44,6 +39,8 @@ static __attribute__((__used__)) const char * GIT_VERSION_UNKNOWN = NULL;
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static unsigned int month_days[12] =
|
||||||
|
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||||
|
|
||||||
static unsigned char weekday_str[7][4] =
|
static unsigned char weekday_str[7][4] =
|
||||||
{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
||||||
@@ -51,6 +48,44 @@ static unsigned char weekday_str[7][4] =
|
|||||||
static unsigned char month_str[12][4] = {"Jan", "Feb", "Mar", "Apr",
|
static unsigned char month_str[12][4] = {"Jan", "Feb", "Mar", "Apr",
|
||||||
"May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
"May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||||
|
|
||||||
|
char *thread_safe_ctime(const time_t *tp, char *buf, int len)
|
||||||
|
{
|
||||||
|
unsigned int year, month, day, weekday, hour, min, sec;
|
||||||
|
unsigned int year_days = 365;
|
||||||
|
sec = * tp;
|
||||||
|
min = sec / 60; sec = sec % 60;
|
||||||
|
hour = min / 60; min = min % 60; hour += 8;
|
||||||
|
day = hour / 24; hour = hour % 24;
|
||||||
|
weekday = day % 7; weekday = (weekday + 4) % 7;
|
||||||
|
|
||||||
|
for(year = 1970; day >= year_days;)
|
||||||
|
{
|
||||||
|
day -= year_days;
|
||||||
|
year ++;
|
||||||
|
|
||||||
|
if(0 == year % 4 && (0 != year % 100 || 0 == year % 400))
|
||||||
|
year_days = 366;
|
||||||
|
else year_days = 365;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(366 == year_days) month_days[1] = 29;
|
||||||
|
|
||||||
|
//bug fix by yw 20120808
|
||||||
|
for(month = 0; day >= month_days[month];)
|
||||||
|
{
|
||||||
|
day -= month_days[month];
|
||||||
|
month ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
snprintf(buf, len, "%02d:%02d:%02d, %04d/%02d/%02d, %s",
|
||||||
|
hour, min, sec, year, month, day, weekday_str[week_day]);
|
||||||
|
*/
|
||||||
|
snprintf(buf, len, "%s %s %d %02d:%02d:%02d %d", weekday_str[weekday],
|
||||||
|
month_str[month], day + 1, hour, min, sec, year);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
static int create_dir(const char *dir_path, int path_len)
|
static int create_dir(const char *dir_path, int path_len)
|
||||||
{
|
{
|
||||||
if(dir_path == NULL)
|
if(dir_path == NULL)
|
||||||
@@ -111,7 +146,7 @@ void *MESA_create_runtime_log_handle(const char *file_path, int level)
|
|||||||
if(NULL == (fp = fopen(file_path, "w")))
|
if(NULL == (fp = fopen(file_path, "w")))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
//fclose(fp);
|
fclose(fp);
|
||||||
//remove(file_path);
|
//remove(file_path);
|
||||||
p_handle = (log_handle_t *)calloc(sizeof(log_handle_t), 1);
|
p_handle = (log_handle_t *)calloc(sizeof(log_handle_t), 1);
|
||||||
|
|
||||||
@@ -121,7 +156,6 @@ 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;
|
||||||
//p_handle->fp = fp;
|
|
||||||
return (void *)p_handle;
|
return (void *)p_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,13 +163,7 @@ void MESA_destroy_runtime_log_handle(void *handle)
|
|||||||
{
|
{
|
||||||
if(handle != NULL)
|
if(handle != NULL)
|
||||||
{
|
{
|
||||||
log_handle_t *p_handle = (log_handle_t *)handle;
|
free(handle);
|
||||||
if (p_handle->fp != NULL)
|
|
||||||
{
|
|
||||||
fclose(p_handle->fp);
|
|
||||||
p_handle->fp = NULL;
|
|
||||||
}
|
|
||||||
free(handle);
|
|
||||||
handle = NULL;
|
handle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +178,7 @@ void MESA_handle_runtime_log(void *handle, int level, const char *module, const
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
struct tm local_time;
|
struct tm local_time;
|
||||||
char tmp_log_file_name[1400];
|
char tmp_log_file_name[1201];
|
||||||
log_handle_t *p_handle = (log_handle_t *)handle;
|
log_handle_t *p_handle = (log_handle_t *)handle;
|
||||||
|
|
||||||
if(p_handle == NULL || p_handle->runtime_log_file == NULL)return;
|
if(p_handle == NULL || p_handle->runtime_log_file == NULL)return;
|
||||||
@@ -159,6 +187,7 @@ void MESA_handle_runtime_log(void *handle, int level, const char *module, const
|
|||||||
|
|
||||||
time(&t);
|
time(&t);
|
||||||
if(NULL == (localtime_r(&t, &local_time))) return;
|
if(NULL == (localtime_r(&t, &local_time))) return;
|
||||||
|
//THREAD_CTIME(&t, buf, LOGMSG_MAX_LEN);
|
||||||
len = snprintf(buf, sizeof(buf), "%s %s %d %02d:%02d:%02d %d", weekday_str[local_time.tm_wday],
|
len = snprintf(buf, sizeof(buf), "%s %s %d %02d:%02d:%02d %d", weekday_str[local_time.tm_wday],
|
||||||
month_str[local_time.tm_mon], local_time.tm_mday, local_time.tm_hour, local_time.tm_min, local_time.tm_sec, local_time.tm_year+1900);
|
month_str[local_time.tm_mon], local_time.tm_mday, local_time.tm_hour, local_time.tm_min, local_time.tm_sec, local_time.tm_year+1900);
|
||||||
//len = strlen(buf);
|
//len = strlen(buf);
|
||||||
@@ -205,37 +234,9 @@ 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(NULL == (fp = fopen(tmp_log_file_name, "a"))) return;
|
||||||
if(p_handle->fp == NULL)
|
|
||||||
{
|
|
||||||
if(NULL == (fp = fopen(tmp_log_file_name, "a"))) 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)))
|
fprintf(fp, "%s", buf);
|
||||||
{
|
fclose(fp);
|
||||||
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
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user