Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4763 from bazsi/add-severity-aliases
Add severity aliases
- Loading branch information
Showing
17 changed files
with
243 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# SPDX-FileCopyrightText: 2016-2017 Pino Toscano <pino@kde.org> | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
# Adapted from https://invent.kde.org/frameworks/extra-cmake-modules/-/blob/master/find-modules/FindGperf.cmake?ref_type=heads | ||
# | ||
|
||
find_program(Gperf_EXECUTABLE NAMES gperf) | ||
|
||
if (Gperf_EXECUTABLE) | ||
execute_process(COMMAND ${Gperf_EXECUTABLE} -v | ||
OUTPUT_VARIABLE _version_string | ||
ERROR_QUIET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
if(_version_string MATCHES "^GNU gperf ([-0-9\\.]+)") | ||
set(Gperf_VERSION "${CMAKE_MATCH_1}") | ||
endif() | ||
unset(_version_string) | ||
else() | ||
set(Gperf_VERSION) | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(Gperf | ||
FOUND_VAR | ||
Gperf_FOUND | ||
REQUIRED_VARS | ||
Gperf_EXECUTABLE | ||
VERSION_VAR | ||
Gperf_VERSION | ||
) | ||
|
||
if (Gperf_FOUND) | ||
if (NOT TARGET GPerf::Gperf) | ||
add_executable(GPerf::Gperf IMPORTED) | ||
set_target_properties(GPerf::Gperf PROPERTIES | ||
IMPORTED_LOCATION "${Gperf_EXECUTABLE}" | ||
) | ||
endif() | ||
endif() | ||
|
||
function(gperf_generate input_file output_file _target_or_sources_var) | ||
# Parse arguments | ||
set(oneValueArgs GENERATION_FLAGS) | ||
cmake_parse_arguments(ARGS "" "${oneValueArgs}" "" ${ARGN}) | ||
|
||
if(ARGS_UNPARSED_ARGUMENTS) | ||
message(FATAL_ERROR "Unknown keywords given to gperf_generate(): \"${ARGS_UNPARSED_ARGUMENTS}\"") | ||
endif() | ||
if (TARGET ${_target_or_sources_var}) | ||
get_target_property(aliased_target ${_target_or_sources_var} ALIASED_TARGET) | ||
if(aliased_target) | ||
message(FATAL_ERROR "Target argument passed to gperf_generate must not be an alias: ${_target_or_sources_var}") | ||
endif() | ||
endif() | ||
|
||
get_filename_component(_infile ${input_file} ABSOLUTE) | ||
set(_extraopts "${ARGS_GENERATION_FLAGS}") | ||
separate_arguments(_extraopts) | ||
add_custom_command(OUTPUT ${output_file} | ||
COMMAND ${Gperf_EXECUTABLE} ${_extraopts} --output-file=${output_file} ${_infile} | ||
DEPENDS ${_infile} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
VERBATIM | ||
) | ||
set_property(SOURCE ${output_file} PROPERTY SKIP_AUTOMOC ON) | ||
|
||
if (TARGET ${_target_or_sources_var}) | ||
target_sources(${_target_or_sources_var} PRIVATE ${output_file}) | ||
else() | ||
set(${_target_or_sources_var} ${${_target_or_sources_var}} ${output_file} PARENT_SCOPE) | ||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2024 Balazs Scheidler | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* As an additional exemption you are allowed to compile & link against the | ||
* OpenSSL libraries as published by the OpenSSL project. See the file | ||
* COPYING for details. | ||
* | ||
*/ | ||
|
||
%{ | ||
|
||
#pragma GCC diagnostic ignored "-Wswitch-default" | ||
|
||
%} | ||
%define lookup-function-name gperf_lookup_severity_alias | ||
%ignore-case | ||
%struct-type | ||
%readonly-tables | ||
%switch=1 | ||
struct severity_alias { char *name; int severity; }; | ||
%% | ||
emerg, SYSLOG_SEVERITY_CODE(0) | ||
emergency, SYSLOG_SEVERITY_CODE(0) | ||
panic, SYSLOG_SEVERITY_CODE(0) | ||
alert, SYSLOG_SEVERITY_CODE(1) | ||
crit, SYSLOG_SEVERITY_CODE(2) | ||
critical, SYSLOG_SEVERITY_CODE(2) | ||
fatal, SYSLOG_SEVERITY_CODE(2) | ||
err, SYSLOG_SEVERITY_CODE(3) | ||
error, SYSLOG_SEVERITY_CODE(3) | ||
warning, SYSLOG_SEVERITY_CODE(4) | ||
warn, SYSLOG_SEVERITY_CODE(4) | ||
notice, SYSLOG_SEVERITY_CODE(5) | ||
info, SYSLOG_SEVERITY_CODE(6) | ||
log, SYSLOG_SEVERITY_CODE(6) | ||
debug, SYSLOG_SEVERITY_CODE(7) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
`set-severity()` support for aliases: widespread aliases to severity values | ||
produced by various applications are added to set-severity(). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added `gperf` as a build dependency. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.