diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..2809445e0 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,63 @@ +cmake_minimum_required(VERSION 3.13) +include(src/cmake/projectVersionDetails.cmake) +project(log4cxx VERSION ${log4cxx_VER} LANGUAGES CXX) +include(CTest) + +# FindAPR and FindAPR-util are not provided by APR and APR-Util so source them locally +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/src/cmake") + +# Find Apache Runtime +find_package(APR REQUIRED) + +# Find Apache Runtime Utilities +find_package(APR-Util REQUIRED) + +# Building +add_subdirectory(src) + +## Installing +include(GNUInstallDirs) +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src/main/include/log4cxx + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING PATTERN "*.h" +) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/main/include/log4cxx + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING PATTERN "*.h" +) + +install(TARGETS log4cxx EXPORT log4cxxTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) + +IF(WIN32 AND LOG4CXX_INSTALL_PDB) + INSTALL(FILES $ + DESTINATION ${CMAKE_INSTALL_BINDIR} + CONFIGURATIONS RelWithDebInfo Debug + ) +ENDIF(WIN32 AND LOG4CXX_INSTALL_PDB) + +if(UNIX) + set(prefix "${CMAKE_INSTALL_PREFIX}") + set(exec_prefix "${CMAKE_INSTALL_PREFIX}") + set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}") + set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") + set(VERSION "${log4cxx_VERSION_MAJOR}.${log4cxx_VERSION_MINOR}.${log4cxx_VERSION_PATCH}") + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/liblog4cxx.pc.in" + "${CMAKE_CURRENT_BINARY_DIR}/liblog4cxx.pc" + ) + + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/liblog4cxx.pc" + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) +endif(UNIX) + + +# create export file which can be imported by other cmake projects +install(EXPORT log4cxxTargets + FILE log4cxx-targets.cmake + NAMESPACE log4cxx:: + DESTINATION share/cmake/log4cxx +) diff --git a/build.xml b/build.xml index f0ffe82f2..6e1a811c9 100644 --- a/build.xml +++ b/build.xml @@ -17,50 +17,6 @@ --> - - - - - - - - - - - - -'> - - - ]> - + &common; - &find-apr; - &find-apr-util; - &find-libesmtp; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Ant build file for log4cxx - - Common invocations: - - > ant - - will attempt to locate APR and APR-util in /usr, /usr/local/apr and .. - - Builds and tests log4cxx. - - > ant -Dwith-apr=APRPATH -Dwith-apr-util=APUPATH - - Builds and tests log4cxx using APR and APR-Util at specified location - - > ant -p - - Displays available targets - - > ant build-projects-vc6 - - Builds Microsoft Visual Studio 6 projects. - -vc7, -vc8, -vc9 and -xcode for Visual Studio .NET, 2005, 2008 and Apple Xcode 2 and later. - respectively. - - Command line options: - - -Ddebug=[true|false] - -Doptimize=[speed|size|none] - -Dversion=n.n.n - -Dlib.type=[shared|static] (Library type to create, default=shared) - -Denable-char=[0, 1] (expose char* API, default=1) - -Denable-wchar_t=[0, 1] (expose wchar_t* API, default=1) - -Denable-unichar=[0, 1] (expose UniChar API, default=0) - -Denable-cfstring[0, 1] (expose CFString API, default=0) - -Dwith-charset=[auto|utf-8|iso-8859-1|usascii|ebcdic] (default=auto) - -Dwith-logchar=[utf-8|wchar_t|unichar] (default=utf-8 on Unix, wchar_t on Windows) - -Dwith-apr=APRPATH - -Dwith-apr-util=PATH - -Dwith-SMTP=[libesmtp, no] (default no) - -Dwith-ODBC=[auto, unixODBC, iODBC, Microsoft, no] (default=auto resulting in no on Unix, Microsoft on Windows) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - force-ant: ${force-ant} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Could not locate apr library or source. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Could not locate apr-util library or source. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Could not locate libesmtp library or source. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "${header}" - #include "${header}" - - - - - Requires GCC compiler - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - apr is ${apr.lib.type} and apr-util is ${apr-util.lib.type}, must be same type. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &libsets; - - - &license; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &libsets; - - - &license; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &libsets; - - - &license; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &libsets; - - - - - - - - - - &license; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - output/dom³ was ${dom3-status} created in DOMTestCase::test3 - output/dom㆕ was ${dom4-status} created in DOMTestCase::test4 - - - - - - - - - - - - - - - - - - - - - - - - - - output/dom³ was ${dom3-status} created in DOMTestCase::test3 - output/dom㆕ was ${dom4-status} created in DOMTestCase::test4 - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + - - - - - - - + + + + - - - + + + Ant file for releasing log4cxx - - - - - - - - - + Common invocations: - - - - - - - - - + > ant -p - - - - - - - - - + Displays available targets + - - - - - - - - - + - - - - - - - + - + + force-ant: ${force-ant} - - - - - - - - + + + #include "${header}" + #include "${header}" + + + Requires GCC compiler - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - + - + - - - - - - - - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/configure-aprutil.bat b/configure-aprutil.bat deleted file mode 100755 index 6477b2c7b..000000000 --- a/configure-aprutil.bat +++ /dev/null @@ -1,19 +0,0 @@ -ECHO OFF -REM Licensed to the Apache Software Foundation (ASF) under one or more -REM contributor license agreements. See the NOTICE file distributed with -REM this work for additional information regarding copyright ownership. -REM The ASF licenses this file to You under the Apache License, Version 2.0 -REM (the "License"); you may not use this file except in compliance with -REM the License. You may obtain a copy of the License at -REM -REM http://www.apache.org/licenses/LICENSE-2.0 -REM -REM Unless required by applicable law or agreed to in writing, software -REM distributed under the License is distributed on an "AS IS" BASIS, -REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -REM See the License for the specific language governing permissions and -REM limitations under the License. -REM - -sed -i -e "s/#define APU_HAVE_APR_ICONV\b.*/#define APU_HAVE_APR_ICONV 0/" ..\apr-util\include\apu.hw -sed -i -e "s/#define APR_HAS_LDAP\b.*/#define APR_HAS_LDAP 0/" ..\apr-util\include\apr_ldap.hw diff --git a/pom.xml b/pom.xml index abdf7f766..5722ae980 100644 --- a/pom.xml +++ b/pom.xml @@ -74,6 +74,7 @@ ${project.version} Matt Sicker B62BABE8 + x64 @@ -179,49 +180,60 @@ + + com.googlecode.cmake-maven-project + cmake-maven-plugin + 3.16.3-b1 + + + cmake-generate + + generate + + + ${project.basedir} + ${project.build.directory}/${platform} + ${cmake.classifier} + ${cmake.options} + + ${cmake.classifier} + + ${download.cmake} + + + + cmake-compile + process-resources + + compile + + + ${project.build.directory}/${platform} + ${cmake.classifier} + ${cmake.config} + true + + + + test + cmake-run-tests + + test + + + ${project.build.directory}/${platform} + true + ${maven.test.skip} + ${cmake.config} + 1 + + + + maven-antrun-plugin 1.7 - - compile - compile - - - - - - - run - - - - - test-compile - test-compile - - - - - - - run - - - - - test - test - - - - - - - run - - - package autogen @@ -287,12 +299,6 @@ ant-contrib 1.0b2 - - - ant-contrib - cpptasks - 1.0b5 - @@ -394,4 +400,84 @@ file:///${user.dir}/target/site-deploy/${project.version} + + + + linux-x86_64-debug + + linux-x86_64 + debug + + + + linux-x86_64-release + + + linux + amd64 + + + + linux-x86_64 + release + linux-x86_64 + + + + Win32 + + Win32 + + + + windows-debug + + windows-${windowsArchitecture} + debug + windows-x86_64 + -A${windowsArchitecture} + ${build.type} + + + + windows-release + + + windows + amd64 + + + + windows-${windowsArchitecture} + release + windows-x86_64 + -A${windowsArchitecture} + ${build.type} + + + + mac-x86_64-debug + + mac-x86_64 + debug + mac-x86_64 + ${build.type} + + + + mac-x86_64-release + + + mac + x86_64 + + + + mac-x86_64 + release + mac-x86_64 + ${build.type} + + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 000000000..39420dd70 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,13 @@ +add_subdirectory(main) +target_include_directories(log4cxx INTERFACE $ PRIVATE ${APR_INCLUDE_DIR} ${APR_UTIL_INCLUDE_DIR}) +target_link_libraries(log4cxx PRIVATE ${APR_LIBRARIES} ${APR_UTIL_LIBRARIES}) +if(WIN32) +# The ODBC appender is always enabled in the Windows configuration +target_link_libraries(log4cxx PRIVATE odbc32.lib) +option(LOG4CXX_INSTALL_PDB "Install .pdb files (if generated)" ON) +endif() + +if(BUILD_TESTING) + add_subdirectory(test) + add_subdirectory(examples/cpp) +endif() diff --git a/src/ant/apr-build.xml b/src/ant/apr-build.xml deleted file mode 100644 index 9812ae0f3..000000000 --- a/src/ant/apr-build.xml +++ /dev/null @@ -1,851 +0,0 @@ - - - - -]> - - - -&common; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &license; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &license; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &license; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &license; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/ant/apr-util-build.xml b/src/ant/apr-util-build.xml deleted file mode 100644 index 70ba3b244..000000000 --- a/src/ant/apr-util-build.xml +++ /dev/null @@ -1,722 +0,0 @@ - - - - - -]> - - - - -&common; -&find-apr; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #define APU_CONFIG_H - -#include <stdint.h> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &license; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &license; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &license; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/ant/common.xml b/src/ant/common.xml index 3343b3d2e..1f9f192ca 100644 --- a/src/ant/common.xml +++ b/src/ant/common.xml @@ -34,8 +34,6 @@ value="dynamic" /> - - @@ -124,26 +122,6 @@ - - cpptasks required - -Use cpptasks 1.0b5 or later from -http://ant-contrib.sourceforge.net. - - - - - - - - @@ -211,27 +189,6 @@ Required features not present in cpptasks releases prior to Feb 2005 - - - - - - - - - - - -]> - - - - - -&common; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/ant/find-apr-util.xml b/src/ant/find-apr-util.xml deleted file mode 100644 index 10908ede7..000000000 --- a/src/ant/find-apr-util.xml +++ /dev/null @@ -1,369 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Unable to locate apr-util base directory. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - apr-util-find: -apr-util.dir=${apr-util.dir} -apr-util.include.dir=${apr-util.include.dir} -apr-util.src.dir=${apr-util.src.dir} -apr-util.lib.file=${apr-util.lib.file} -apr-util.lib.file.dir=${apr-util.lib.file.dir} -apr-util.lib.dir=${apr-util.lib.dir} -apr-util.lib.prefix=${apr-util.lib.prefix} -apr-util.lib.suffix=${apr-util.lib.suffix} -apr-util.lib.type=${apr-util.lib.type} - - diff --git a/src/ant/find-apr.xml b/src/ant/find-apr.xml deleted file mode 100644 index d29d7aa93..000000000 --- a/src/ant/find-apr.xml +++ /dev/null @@ -1,370 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Unable to locate apr base directory. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - apr-find: -apr.dir=${apr.dir} -apr.include.dir=${apr.include.dir} -apr.src.dir=${apr.src.dir} -apr.lib.file=${apr.lib.file} -apr.lib.file.dir=${apr.lib.file.dir} -apr.lib.dir=${apr.lib.dir} -apr.lib.prefix=${apr.lib.prefix} -apr.lib.suffix=${apr.lib.suffix} -apr.lib.type=${apr.lib.type} - - diff --git a/src/ant/find-libesmtp.xml b/src/ant/find-libesmtp.xml deleted file mode 100644 index 27676584c..000000000 --- a/src/ant/find-libesmtp.xml +++ /dev/null @@ -1,363 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Unable to locate esmtp base directory. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - esmtp-find: -esmtp.dir=${esmtp.dir} -esmtp.include.dir=${esmtp.include.dir} -esmtp.src.dir=${esmtp.src.dir} -esmtp.lib.file=${esmtp.lib.file} -esmtp.lib.file.dir=${esmtp.lib.file.dir} -esmtp.lib.dir=${esmtp.lib.dir} -esmtp.lib.prefix=${esmtp.lib.prefix} -esmtp.lib.suffix=${esmtp.lib.suffix} -esmtp.lib.type=${esmtp.lib.type} - - \ No newline at end of file diff --git a/src/assembly/source.xml b/src/assembly/source.xml index 063d3369d..860fb2ecf 100644 --- a/src/assembly/source.xml +++ b/src/assembly/source.xml @@ -45,6 +45,7 @@ aclocal.m4 build.xml + CMakeLists.txt configure.ac config.guess config.sub @@ -104,48 +105,6 @@ 0644 0755 - - - - target/projects - keep - projects/vc6 - - - *.dsp - *.dsw - - - - apr*.ds* - xml.ds* - - - 0644 - - - - target/projects - keep - projects/xcode - - - *.xcodeproj/project.pbxproj - - - 0644 - 0755 - diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 2113a8138..52605a3ce 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -24,13 +24,14 @@ CachedDateFormat reuses timestamps without updating milliseconds after formatting timestamp with ms == 654 Checksums/Signatures don't match for log4cxx binaries appenderattachable.h function doc formatted "incorrectly" Logging in Timing-Critical Applications Wrong usage of milli- vs. micro- and non- vs. milliseconds in some docs. + Provide a windows build environment for the project by replacing the ant build with a CMake build Space after log level hides messages Spelling error s/excute/execute Build failure with GCC-6 diff --git a/src/cmake/FindAPR-Util.cmake b/src/cmake/FindAPR-Util.cmake new file mode 100644 index 000000000..9b1ec6884 --- /dev/null +++ b/src/cmake/FindAPR-Util.cmake @@ -0,0 +1,45 @@ +# Locate APR-Util include paths and libraries +include(FindPackageHandleStandardArgs) + +# This module defines +# APR_UTIL_INCLUDE_DIR, where to find apr.h, etc. +# APR_UTIL_LIBRARIES, the libraries to link against to use APR. +# APR_UTIL_DLL_DIR, where to find libaprutil-1.dll +# APR_UTIL_FOUND, set to yes if found + +macro(_apu_invoke _varname) + execute_process( + COMMAND ${APR_UTIL_CONFIG_EXECUTABLE} ${ARGN} + OUTPUT_VARIABLE _apr_output + RESULT_VARIABLE _apr_failed + ) + + if(_apr_failed) + message(FATAL_ERROR "apu-1-config ${ARGN} failed with result ${_apr_failed}") + else(_apr_failed) + string(REGEX REPLACE "[\r\n]" "" _apr_output "${_apr_output}") + string(REGEX REPLACE " +$" "" _apr_output "${_apr_output}") + string(REGEX REPLACE "^ +" "" _apr_output "${_apr_output}") + + separate_arguments(_apr_output) + + set(${_varname} "${_apr_output}") + endif(_apr_failed) +endmacro(_apu_invoke) + +find_program(APR_UTIL_CONFIG_EXECUTABLE + apu-1-config + PATHS /usr/local/bin /usr/bin C:/Progra~1/apr-util/bin + ) +mark_as_advanced(APR_UTIL_CONFIG_EXECUTABLE) +if(EXISTS ${APR_UTIL_CONFIG_EXECUTABLE}) + _apu_invoke(APR_UTIL_INCLUDE_DIR --includedir) + _apu_invoke(APR_UTIL_LIBRARIES --link-ld) +else() + find_path(APR_UTIL_INCLUDE_DIR apu.h PATH_SUFFIXES apr-1) + find_library(APR_UTIL_LIBRARIES NAMES libaprutil-1 aprutil-1) + find_path(APR_UTIL_DLL_DIR libaprutil-1.dll) +endif() + +find_package_handle_standard_args(apr-util DEFAULT_MSG + APR_UTIL_INCLUDE_DIR APR_UTIL_LIBRARIES) diff --git a/src/cmake/FindAPR.cmake b/src/cmake/FindAPR.cmake new file mode 100644 index 000000000..7678519d7 --- /dev/null +++ b/src/cmake/FindAPR.cmake @@ -0,0 +1,44 @@ +# Locate APR include paths and libraries +include(FindPackageHandleStandardArgs) + +# This module defines +# APR_INCLUDE_DIR, where to find apr.h, etc. +# APR_LIBRARIES, the libraries to link against to use APR. +# APR_DLL_DIR, where to find libapr-1.dll +# APR_FOUND, set to 'yes' if found +macro(_apr_invoke _varname) + execute_process( + COMMAND ${APR_CONFIG_EXECUTABLE} ${ARGN} + OUTPUT_VARIABLE _apr_output + RESULT_VARIABLE _apr_failed + ) + + if(_apr_failed) + message(FATAL_ERROR "apr-1-config ${ARGN} failed with result ${_apr_failed}") + else(_apr_failed) + string(REGEX REPLACE "[\r\n]" "" _apr_output "${_apr_output}") + string(REGEX REPLACE " +$" "" _apr_output "${_apr_output}") + string(REGEX REPLACE "^ +" "" _apr_output "${_apr_output}") + + separate_arguments(_apr_output) + set(${_varname} "${_apr_output}") + endif(_apr_failed) +endmacro(_apr_invoke) + + +find_program(APR_CONFIG_EXECUTABLE + apr-1-config + PATHS /usr/local/bin /usr/bin C:/Progra~1/apr/bin + ) +mark_as_advanced(APR_CONFIG_EXECUTABLE) +if(EXISTS ${APR_CONFIG_EXECUTABLE}) + _apr_invoke(APR_INCLUDE_DIR --includedir) + _apr_invoke(APR_LIBRARIES --link-ld) +else() + find_path(APR_INCLUDE_DIR apr.h PATH_SUFFIXES apr-1) + find_library(APR_LIBRARIES NAMES libapr-1 apr-1) + find_path(APR_DLL_DIR libapr-1.dll) +endif() + +find_package_handle_standard_args(apr + APR_INCLUDE_DIR APR_LIBRARIES) diff --git a/src/cmake/projectVersionDetails.cmake b/src/cmake/projectVersionDetails.cmake new file mode 100644 index 000000000..68bda9b8c --- /dev/null +++ b/src/cmake/projectVersionDetails.cmake @@ -0,0 +1,5 @@ +# This file should contain nothing but the following line +# setting the project version. The variable name must not +# clash with the log4cxx_VERSION* variables automatically +# defined by the project() command. +set(log4cxx_VER 0.11.0.0) diff --git a/src/examples/cpp/CMakeLists.txt b/src/examples/cpp/CMakeLists.txt new file mode 100644 index 000000000..ed0412a31 --- /dev/null +++ b/src/examples/cpp/CMakeLists.txt @@ -0,0 +1,7 @@ +set(ALL_LOG4CXX_EXAMPLES console delayedloop stream trivial) + +foreach(exampleName IN LISTS ALL_LOG4CXX_EXAMPLES) + add_executable(${exampleName} ${exampleName}.cpp) + target_include_directories(${exampleName} PRIVATE ${CMAKE_CURRENT_LIST_DIR} $) + target_link_libraries(${exampleName} PRIVATE log4cxx ${APR_LIBRARIES}) +endforeach() diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt new file mode 100644 index 000000000..80dd6d82d --- /dev/null +++ b/src/main/CMakeLists.txt @@ -0,0 +1,10 @@ +add_subdirectory(include) +add_subdirectory(cpp) +add_subdirectory(resources) + +# setup include directories +include(GNUInstallDirs) +target_include_directories(log4cxx PUBLIC + $ + $ +) diff --git a/src/main/cpp/CMakeLists.txt b/src/main/cpp/CMakeLists.txt new file mode 100644 index 000000000..779554abb --- /dev/null +++ b/src/main/cpp/CMakeLists.txt @@ -0,0 +1,170 @@ + +# Options +option(LOG4CXX_BLOCKING_ASYNC_APPENDER "Async appender behaviour" ON) +option(BUILD_SHARED_LIBS "Build shared libraries" ON) + +# Build the log4cxx library +add_library(log4cxx action.cpp) +if(BUILD_SHARED_LIBS) + target_compile_definitions(log4cxx PRIVATE LOG4CXX) +else() + target_compile_definitions(log4cxx PUBLIC LOG4CXX_STATIC) +endif() +add_dependencies(log4cxx configure_log4cxx) +target_sources(log4cxx + PRIVATE + andfilter.cpp + appenderattachableimpl.cpp + appenderskeleton.cpp + aprinitializer.cpp + $,asyncappender.cpp,asyncappender_nonblocking.cpp> + basicconfigurator.cpp + bufferedwriter.cpp + bytearrayinputstream.cpp + bytearrayoutputstream.cpp + bytebuffer.cpp + cacheddateformat.cpp + charsetdecoder.cpp + charsetencoder.cpp + class.cpp + classnamepatternconverter.cpp + classregistration.cpp + condition.cpp + configurator.cpp + consoleappender.cpp + cyclicbuffer.cpp + dailyrollingfileappender.cpp + datagrampacket.cpp + datagramsocket.cpp + date.cpp + dateformat.cpp + datelayout.cpp + datepatternconverter.cpp + defaultconfigurator.cpp + defaultloggerfactory.cpp + defaultrepositoryselector.cpp + domconfigurator.cpp + exception.cpp + fallbackerrorhandler.cpp + file.cpp + fileappender.cpp + filedatepatternconverter.cpp + fileinputstream.cpp + filelocationpatternconverter.cpp + fileoutputstream.cpp + filerenameaction.cpp + filewatchdog.cpp + filter.cpp + filterbasedtriggeringpolicy.cpp + fixedwindowrollingpolicy.cpp + formattinginfo.cpp + fulllocationpatternconverter.cpp + gzcompressaction.cpp + hierarchy.cpp + htmllayout.cpp + inetaddress.cpp + inputstream.cpp + inputstreamreader.cpp + integer.cpp + integerpatternconverter.cpp + jsonlayout.cpp + layout.cpp + level.cpp + levelmatchfilter.cpp + levelpatternconverter.cpp + levelrangefilter.cpp + linelocationpatternconverter.cpp + lineseparatorpatternconverter.cpp + literalpatternconverter.cpp + loader.cpp + locale.cpp + locationinfo.cpp + logger.cpp + loggermatchfilter.cpp + loggerpatternconverter.cpp + loggingevent.cpp + loggingeventpatternconverter.cpp + loglog.cpp + logmanager.cpp + logstream.cpp + manualtriggeringpolicy.cpp + mdc.cpp + messagebuffer.cpp + messagepatternconverter.cpp + methodlocationpatternconverter.cpp + mutex.cpp + nameabbreviator.cpp + namepatternconverter.cpp + ndc.cpp + ndcpatternconverter.cpp + nteventlogappender.cpp + objectimpl.cpp + objectoutputstream.cpp + objectptr.cpp + obsoleterollingfileappender.cpp + odbcappender.cpp + onlyonceerrorhandler.cpp + optionconverter.cpp + outputdebugstringappender.cpp + outputstream.cpp + outputstreamwriter.cpp + patternconverter.cpp + patternlayout.cpp + patternparser.cpp + pool.cpp + properties.cpp + propertiespatternconverter.cpp + propertyconfigurator.cpp + propertyresourcebundle.cpp + propertysetter.cpp + reader.cpp + relativetimedateformat.cpp + relativetimepatternconverter.cpp + resourcebundle.cpp + rollingfileappender.cpp + rollingpolicy.cpp + rollingpolicybase.cpp + rolloverdescription.cpp + rootlogger.cpp + serversocket.cpp + simpledateformat.cpp + simplelayout.cpp + sizebasedtriggeringpolicy.cpp + smtpappender.cpp + socket.cpp + socketappender.cpp + socketappenderskeleton.cpp + sockethubappender.cpp + socketoutputstream.cpp + strftimedateformat.cpp + stringhelper.cpp + stringmatchfilter.cpp + stringtokenizer.cpp + synchronized.cpp + syslogappender.cpp + syslogwriter.cpp + system.cpp + systemerrwriter.cpp + systemoutwriter.cpp + telnetappender.cpp + threadcxx.cpp + threadlocal.cpp + threadpatternconverter.cpp + threadspecificdata.cpp + throwableinformationpatternconverter.cpp + timebasedrollingpolicy.cpp + timezone.cpp + transcoder.cpp + transform.cpp + triggeringpolicy.cpp + ttcclayout.cpp + writer.cpp + writerappender.cpp + xmllayout.cpp + xmlsocketappender.cpp + zipcompressaction.cpp +) +set_target_properties(log4cxx PROPERTIES + VERSION ${log4cxx_VERSION_MAJOR}.${log4cxx_VERSION_MINOR}.${log4cxx_VERSION_PATCH} + SOVERSION ${log4cxx_VERSION_MAJOR} +) diff --git a/src/main/include/CMakeLists.txt b/src/main/include/CMakeLists.txt new file mode 100644 index 000000000..d1a0bb21c --- /dev/null +++ b/src/main/include/CMakeLists.txt @@ -0,0 +1,117 @@ +# Configure +if(WIN32) +add_custom_target(configure_log4cxx + COMMAND "${CMAKE_COMMAND}" -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/log4cxx.hw + ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/log4cxx.h + COMMAND "${CMAKE_COMMAND}" -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/private/log4cxx_private.hw + ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/private/log4cxx_private.h + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/log4cxx.hw + ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/private/log4cxx_private.hw + BYPRODUCTS + ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/log4cxx.h + ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/private/log4cxx_private.h +) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/version_info.h.in + ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/version_info.h + @ONLY +) +else() +# Configure log4cxx.h +set(LOG4CXX_CHAR "utf-8" CACHE STRING "Interal character representation, choice of utf-8 (default), wchar_t, unichar") +set_property(CACHE LOG4CXX_CHAR PROPERTY STRINGS "utf-8" "wchar_t" "unichar") +set(LOGCHAR_IS_UNICHAR 0) +set(LOGCHAR_IS_WCHAR 0) +set(LOGCHAR_IS_UTF8 0) +if(${LOG4CXX_CHAR} STREQUAL "unichar") + set(LOGCHAR_IS_UNICHAR 1) +elseif(${LOG4CXX_CHAR} STREQUAL "wchar_t") + set(LOGCHAR_IS_WCHAR 1) +else() + set(LOGCHAR_IS_UTF8 1) +endif() +option(LOG4CXX_WCHAR_T "Enable wchar_t API methods" ON) +option(LOG4CXX_UNICHAR "Enable UniChar API methods" OFF) +if(APPLE) +option(LOG4CXX_CFSTRING "Enable CFString API methods, requires Mac OS/X CoreFoundation" OFF) +endif() +set(CHAR_API 1) +foreach(varName WCHAR_T UNICHAR CFSTRING ) + if(${LOG4CXX_${varName}}) + set("${varName}_API" 1) + else() + set("${varName}_API" 0) + endif() +endforeach() +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/log4cxx.h.in + ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/log4cxx.h + @ONLY +) + +# Configure log4cxx_private.h +set(LOG4CXX_CHARSET "locale" CACHE STRING "LogString characters, choice of locale (default), utf-8, ISO-8859-1, US-ASCII, EBCDIC") +set_property(CACHE LOG4CXX_CHARSET PROPERTY STRINGS "locale" "utf-8" "ISO-8859-1" "US-ASCII" "EBCDIC") +set(CHARSET_EBCDIC 0) +set(CHARSET_USASCII 0) +set(CHARSET_ISO88591 0) +set(CHARSET_UTF8 0) +if(${LOG4CXX_CHARSET} STREQUAL "EBCDIC") + set(CHARSET_EBCDIC 1) +elseif(${LOG4CXX_CHARSET} STREQUAL "US-ASCII") + set(CHARSET_USASCII 1) +elseif(${LOG4CXX_CHARSET} STREQUAL "ISO-8859-1") + set(CHARSET_ISO88591 1) +elseif(${LOG4CXX_CHARSET} STREQUAL "utf-8") + set(CHARSET_UTF8 1) +endif() + +# +# Test for various functions +# +include(CheckFunctionExists) +include(CheckCXXSymbolExists) +include(CheckIncludeFiles) +include(CheckIncludeFileCXX) +include(CheckLibraryExists) + +CHECK_INCLUDE_FILE_CXX(locale HAS_STD_LOCALE) +CHECK_INCLUDE_FILES(sqlext.h HAS_ODBC) +CHECK_FUNCTION_EXISTS(mbsrtowcs HAS_MBSRTOWCS) +CHECK_FUNCTION_EXISTS(wcstombs HAS_WCSTOMBS) +CHECK_FUNCTION_EXISTS(fwide HAS_FWIDE) +CHECK_LIBRARY_EXISTS(esmtp smtp_create_session "" HAS_LIBESMTP) +CHECK_FUNCTION_EXISTS(syslog HAS_SYSLOG) + +foreach(varName HAS_STD_LOCALE HAS_ODBC HAS_MBSRTOWCS HAS_WCSTOMBS HAS_FWIDE HAS_LIBESMTP HAS_SYSLOG) + if(${varName} EQUAL 0) + continue() + elseif(${varName} EQUAL 1) + continue() + elseif("${varName}" STREQUAL "ON") + set(${varName} 1 ) + elseif("${varName}" STREQUAL "OFF") + set(${varName} 0 ) + else() + set(${varName} 0 ) + endif() +endforeach() + + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/private/log4cxx_private.h.in + ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/private/log4cxx_private.h + @ONLY +) + +# Provide the dependencies +add_custom_target(configure_log4cxx + COMMAND "${CMAKE_COMMAND}" -E echo "Checking configuration" + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/log4cxx.h.in + ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx/private/log4cxx_private.h.in + BYPRODUCTS + ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/log4cxx.h + ${CMAKE_CURRENT_BINARY_DIR}/log4cxx/private/log4cxx_private.h +) +endif() diff --git a/src/main/include/log4cxx/version_info.h.in b/src/main/include/log4cxx/version_info.h.in new file mode 100644 index 000000000..b4331fcc4 --- /dev/null +++ b/src/main/include/log4cxx/version_info.h.in @@ -0,0 +1,5 @@ +// Information used by resource files +#define INFO_PRODUCT_VERSION_LIST @log4cxx_VERSION_MAJOR@,@log4cxx_VERSION_MINOR@,@log4cxx_VERSION_PATCH@ +#define INFO_PRODUCT_VERSION_STRING "@log4cxx_VERSION@" +#define INFO_FILE_VERSION_LIST INFO_PRODUCT_VERSION_LIST,@log4cxx_VERSION_TWEAK@ +#define INFO_FILE_VERSION_STRING INFO_PRODUCT_VERSION_STRING "." @log4cxx_VERSION_TWEAK@ diff --git a/src/main/resources/CMakeLists.txt b/src/main/resources/CMakeLists.txt new file mode 100644 index 000000000..382735736 --- /dev/null +++ b/src/main/resources/CMakeLists.txt @@ -0,0 +1,7 @@ +# Configure +if(WIN32) +target_sources(log4cxx + PRIVATE + log4cxx.rc +) +endif() \ No newline at end of file diff --git a/src/main/resources/log4cxx.rc b/src/main/resources/log4cxx.rc index d61b19c87..3faf8b0c9 100644 --- a/src/main/resources/log4cxx.rc +++ b/src/main/resources/log4cxx.rc @@ -74,10 +74,11 @@ END // // Version // +#include VS_VERSION_INFO VERSIONINFO - FILEVERSION 0, 0, 0, 0 - PRODUCTVERSION 0, 0, 0, 0 + FILEVERSION INFO_FILE_VERSION_LIST + PRODUCTVERSION INFO_PRODUCT_VERSION_LIST FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -94,12 +95,12 @@ BEGIN BEGIN VALUE "CompanyName", "Apache Software Foundation" VALUE "FileDescription", "Apache log4cxx" - VALUE "FileVersion", "0, 0, 0, 0" + VALUE "FileVersion", INFO_FILE_VERSION_STRING VALUE "InternalName", "log4cxx" VALUE "LegalCopyright", "Licensed to the Apache Software Foundation (ASF) under one or more\ncontributor license agreements. See the NOTICE file distributed with\nthis work for additional information regarding copyright ownership.\nThe ASF licenses this file to You under the Apache License, Version 2.0\n(the ""License""); you may not use this file except in compliance with\nthe License. You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an ""AS IS"" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License." VALUE "OriginalFilename", "log4cxx.dll" VALUE "ProductName", "Apache log4cxx" - VALUE "ProductVersion", "0, 0, 0, 0" + VALUE "ProductVersion", INFO_PRODUCT_VERSION_STRING END END BLOCK "VarFileInfo" diff --git a/src/site/apt/building/ant.apt b/src/site/apt/building/ant.apt deleted file mode 100644 index ceb2838aa..000000000 --- a/src/site/apt/building/ant.apt +++ /dev/null @@ -1,229 +0,0 @@ -~~ Licensed to the Apache Software Foundation (ASF) under one or more -~~ contributor license agreements. See the NOTICE file distributed with -~~ this work for additional information regarding copyright ownership. -~~ The ASF licenses this file to You under the Apache License, Version 2.0 -~~ (the "License"); you may not use this file except in compliance with -~~ the License. You may obtain a copy of the License at -~~ -~~ http://www.apache.org/licenses/LICENSE-2.0 -~~ -~~ Unless required by applicable law or agreed to in writing, software -~~ distributed under the License is distributed on an "AS IS" BASIS, -~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -~~ See the License for the specific language governing permissions and -~~ limitations under the License. - ------ - Building Apache log4cxx with Apache Ant - ------ - ------ - ------ - -Building Apache log4cxx with Apache Ant - - {{{https://ant.apache.org}Apache Ant}} with cpptasks from the - {{{http://ant-contrib.sourceforge.net}Ant-Contrib}} project can be used to build log4cxx - with supported compilers and is also used to generate the IDE project files included - in the releases. The Apache Maven build which is used to generate the site documentation - and release packaging delegates to this build. The Ant build can build APR and APR-Util - if source is available. - -* Quick start: - - * Install {{{https://ant.apache.org}Apache Ant}} 1.6.5 or later. - - * Install cpptasks 1.0b5 or later from the {{{http://ant-contrib.sourceforge.net}Ant-Contrib Project}}. - ant-contribs 1.0b3 or later is needed for some less frequent build targets. - - * Install APR and APR-Util or place source in apr and apr-util directories as a - sibling to the log4cxx directory. - - * Install gzip and zip (used for compression by RollingFileAppender) and - sed (used to normalize output files for comparison in unit tests). - - * Install log4j 1.2. Used in testing of SocketAppender. - - Building and testing log4cxx on a Unix platform with packaged APR and APR-Util. - -+----+ -$ export CLASSPATH=~/cpptasks/cpptasks-1.0b5.jar -$ cd apache-log4cxx-x.x.x -$ ant -+----+ - - Building and testing log4cxx on a Unix platform with APR and APR-Util built from source. - -+----+ -$ export CLASSPATH=~/cpptasks/cpptasks-1.0b5.jar -$ tar -xvzf apr-1.2.12.tar.gz -$ mv apr-1.2.12 apr -$ tar -xvzf apr-util-1.2.12.tar.gz -$ mv apr-util-1.2.12 apr-util -$ cd apache-log4cxx-x.x.x -$ ant -+----+ - - Building and testing log4cxx on a Microsoft Windows with APR and APR-Util built from source. - -+----+ -$ "%VS120COMNTOOLS%\vsvars32.bat" -$ set PATH=\apache-ant-1.7.0\bin;%PATH% -$ set CLASSPATH=\cpptasks\cpptasks-1.0b5.jar -$ tar -xvzf apr-1.2.12.tar.gz -$ rename apr-1.2.12 apr -$ tar -xvzf apr-util-1.2.12.tar.gz -$ rename apr-util-1.2.12 apr-util -$ cd apache-log4cxx-x.x.x -$ ant -Dcompiler=xyz -+----+ - -* Common ant targets - -*-----------------------+---------------------------------------------------------------------------------------------+ -| build | build log4cxx library. | -*-----------------------+---------------------------------------------------------------------------------------------+ -| check | build logcxx library and build and run unit tests and examples. | -*-----------------------+---------------------------------------------------------------------------------------------+ -| clean | Delete all generated files. | -*-----------------------+---------------------------------------------------------------------------------------------+ -| build-unittest | build log4cxx library and unit test. | -*-----------------------+---------------------------------------------------------------------------------------------+ -| run-socketserver | Tests SocketAppender with Java-based receiver. | -*-----------------------+---------------------------------------------------------------------------------------------+ -| build-projects-vc6 | Build Microsoft Visual Studio 6 project files. | -*-----------------------+---------------------------------------------------------------------------------------------+ -| build-projects-vc7 | Build Microsoft Visual Studio .NET project files. | -*-----------------------+---------------------------------------------------------------------------------------------+ -| build-projects-vc8 | Build Microsoft Visual Studio 2005 project files. | -*-----------------------+---------------------------------------------------------------------------------------------+ -| build-projects-vc9 | Build Microsoft Visual Studio 2008 project files. | -*-----------------------+---------------------------------------------------------------------------------------------+ -| build-projects-xcode | Build Apple Xcode project files. | -*-----------------------+---------------------------------------------------------------------------------------------+ - - All build products will be placed in the target subdirectory. - - Project files should be generated after successfully building the library, however it is possible - to generate Microsoft Visual Studio project files on other platforms. The project - files will typically be missing references to the Platform SDK libraries. - The Maven project modifies the generated project files for release preparation. Generation - of Xcode projects from Microsoft Windows is not supported. - -* ant options - -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Dcompiler | Compiler, see {{{http://ant-contrib.sourceforge.net/cpptasks/antdocs/CCTask.html}cpptasks documentation}} for full list. | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Ddebug | Build for debugging, yes (default), no. | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Dfind | Attempt to locate compiled APR and APR-Util, yes (default), no. | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Dwith-apr | path to non-default location for APR. | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Dwith-apr-util | path to non-default location for APR-Util. | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Denable-char | Enable char API methods, choice of yes (default), no. | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Denable-wchar_t | Enable wchar_t API methods, choice of yes (default), no. | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Denable-unichar | Enable UniChar API methods, choice of yes, no (default). | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Denable-cfstring | Enable CFString API methods, requires Mac OS/X CoreFoundation, choice of yes, no (default). | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Dwith-logchar | Internal character representation, choice of utf-8 (default non-Windows), wchar_t (default Windows), unichar. | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Dwith-charset | External character encoding, choice of utf-8, iso-8859-1, usascii, ebcdic, auto (default). | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Dwith-SMTP | SMTP implementation for SMTPAppender, choice of libesmtp, no (default). | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Dwith-ODBC | OBDC implementation for ODBCAppender, choice of auto (default), unixODBC, iODBC, Microsoft, no | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Dlog4j.jar | Path to log4j.jar for run-socketserver. | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Dprojects.dir | Location for generated IDE projects. | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Dlib.type | Library type to create, choice of shared (default), static. | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Druntime | Type of C runtime library to use, choice of dynamic (default), static. | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -Doptimize | Optimization: none (default), speed, size. | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ -| -p | Display available targets and quit. | -*-------------------+--------------------------------------------------------------------------------------------------------------------------+ - - SMTP and ODBC options can depend on libraries that that have different licenses. You should - review the corresponding licenses and understand the implications before redistribution. - - Combining -Dlib.type=shared and -Druntime=static is unsafe. - - Properties may also be placed in a build.properties file in the log4cxx directory. The file has - to be in the default format for {{{https://en.wikipedia.org/wiki/.properties}Java properties files}}, - especially one must not provide options using the syntax -Dxy=z like on the shell, but only as - xy=z per line. - -* Platform specific notes: - - ** Microsoft Windows - - {{{http://gnuwin32.sourceforge.net}GnuWin32}} - provides binary versions of sed, gzip and zip. Alternative, - the bin directory of {{{https://www.cygwin.com}Cygwin}} may be placed on the path. - - If -Dwith-SMTP=libesmtp is specified, the build will attempt to build - libesmtp from source, unfortunately libesmtp depends on poll.h and will not build. - - APR 1.2.12 has a known issue that will prevent - compilation with Visual Studio 6 unless a later Platform SDK is installed. - See APR bug {{{https://issues.apache.org/bugzilla/show_bug.cgi?44327}44327}}. - APR 1.2.11 and the corresponding APR-Util 1.2.10 will compile with Visual Studio 6. - - If your are using Visual Studio, vsvars32.bat from the directory ...\Common7\Tools needs to be - executed manually before a build. This script sets include paths etc., else you will get a lot - of errors about missing windows.h and such. - - *** Cygwin: - - gcc 3.x does not provide wchar_t support which needs to be explicitly disabled. - The Win32 path to the APR libraries need to be provided (CYGWIN_HOME/lib) if compiling against an installed APR and APR-Util. - -+-----+ -$ cd apache-log4cxx-x.x.x -$ ant -Dos.family=cygwin -Dwith-apr=/cygwin/lib -Dwith-apr-util=/cygwin/lib -Denable-wchar_t=0 -+-----+ - - *** MinGW: - -+----+ -$ cd apache-log4cxx-x.x.x -$ path c:\mingw\bin;%PATH% -$ ant -Dcompiler=gcc -Dfind=false build-all -$ cd src\test\resources -$ set TOTO=wonderful -$ set key1=value1 -$ set key2=value2 -$ ..\..\..\target\debug\shared\testsuite -v -$ ..\..\..\target\debug\shared\trivial -$ ..\..\..\target\debug\shared\stream -+----+ - - Running "ant check" was observed to fail with unexpected exceptions - in streamtestcase and datetimedateformattestcase. - See {{{https://issues.apache.org/jira/browse/LOGCXX-244}LOGCXX-244}}. - - ** Debian: - - Apache APR, APR-Util, Ant and log4j and zip may be installed using: - -+----+ -$ sudo apt-get install libapr1-dev libaprutil1-dev ant ant-optional liblog4j1.2-java zip -+----+ - - ** Mac OS/X: - - APR and APR-Util are provided by the platform in Mac OS/X 10.5 and iODBC in 10.4. - - Site generation requires "doxygen" command on path which can be provided - by installing Doxygen.app and then setting the path like: - -+---+ -$ setenv PATH /Applications/Doxygen.app/Contents/Resources:$PATH -+---+ diff --git a/src/site/apt/building/cmake.apt b/src/site/apt/building/cmake.apt new file mode 100644 index 000000000..3585ea89b --- /dev/null +++ b/src/site/apt/building/cmake.apt @@ -0,0 +1,107 @@ +~~ Licensed to the Apache Software Foundation (ASF) under one or more +~~ contributor license agreements. See the NOTICE file distributed with +~~ this work for additional information regarding copyright ownership. +~~ The ASF licenses this file to You under the Apache License, Version 2.0 +~~ (the "License"); you may not use this file except in compliance with +~~ the License. You may obtain a copy of the License at +~~ +~~ http://www.apache.org/licenses/LICENSE-2.0 +~~ +~~ Unless required by applicable law or agreed to in writing, software +~~ distributed under the License is distributed on an "AS IS" BASIS, +~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +~~ See the License for the specific language governing permissions and +~~ limitations under the License. + ------ + Building Apache log4cxx with CMake + ------ + ------ + ------ + +Building Apache log4cxx with CMake + +* Quick start: + + Building and testing log4cxx on a Unix platform with packaged APR and APR-Util. + + Make sure cmake 3.13+, g++ and make are available, install or + build apr 1.x, apr-util 1.x, gzip and zip. + ++------------+ +$ apt-get install build-essential libapr1-dev libaprutil1-dev gzip zip +$ cd apache-log4cxx-x.x.x +$ mkdir build +$ cd build +$ ccmake .. +$ make +$ sudo make install ++------------+ + +* ccmake options + +*------------------------+---------------------------------------------------------------------------------------------+ +| -DLOG4CXX_WCHAR_T=no | Enable wchar_t API methods, choice of yes (default), no. | +*------------------------+---------------------------------------------------------------------------------------------+ +| -DLOG4CXX_UNICHAR=yes | Enable UniChar API methods, choice of yes, no (default). | +*------------------------+---------------------------------------------------------------------------------------------+ +| -DLOG4CXX_CFSTRING=yes | Enable CFString API methods, requires Mac OS/X CoreFoundation, choice of yes, no (default). | +*------------------------+---------------------------------------------------------------------------------------------+ + + Building and testing log4cxx on a Microsoft Windows with APR, Expat and APR-Util built from source + extracted into apr-1.7.0, libexpat(from github) and apr-util-1.6.1 in %HOMEPATH%\Libraries. + ++------------+ + cd %HOMEPATH%\Libraries + cmake -S libexpat\expat -B buildtrees\expat -DCMAKE_INSTALL_PREFIX=%HOMEPATH%\Libraries\installed + cmake --build buildtrees\expat --target install --config Release + cmake -S apr-1.7.0 -B buildtrees\apr -DCMAKE_INSTALL_PREFIX=%HOMEPATH%\Libraries\installed + cmake --build buildtrees\apr --target install --config Release + set CMAKE_PREFIX_PATH=%HOMEPATH%\Libraries\installed + cmake -S apr-util-1.6.1 -B buildtrees\apr-util -DCMAKE_INSTALL_PREFIX=%HOMEPATH%\Libraries\installed + cmake --build buildtrees\apr-util --target install --config Release + cmake -S apache-log4cxx-x.x.x -B buildtrees\log4cxx -DCMAKE_INSTALL_PREFIX=%HOMEPATH%\Libraries\installed + cmake --build buildtrees\log4cxx --target install --config Release ++------------+ + +* Platform specific notes: + +** Mac OS/X: + + APR and APR-Util are provided by the platform in Mac OS/X 10.5 and iODBC in 10.4. + + cmake can be installed by typing "brew install cmake" + +** Debian: + + APR, APR-Util, openssl, gzip and zip may be installed by: + ++----+ +$ sudo apt-get install libssl-dev libapr1-dev libaprutil1-dev gzip zip ++----+ + + CMake can be built from source by typing: + ++----+ +$ wget https://github.com/Kitware/CMake/releases/download/v3.16.4/cmake-3.16.4.tar.gz +$ tar xf cmake-3.16.4.tar.gz +$ cd cmake-3.16.4 +$ ./bootstrap +$ make +$ sudo make install ++----+ + +** FreeBSD: + + APR, APR-Util, gzip and zip may be installed from the ports collection by: + ++----+ +# cd /usr/ports/archivers/zip +# make +# make install +# cd /usr/ports/archivers/gzip +# make +# make install +# cd /usr/ports/devel/apr +# make +# make install ++----+ diff --git a/src/site/apt/building/maven.apt b/src/site/apt/building/maven.apt index a09049799..2fa52a3ea 100644 --- a/src/site/apt/building/maven.apt +++ b/src/site/apt/building/maven.apt @@ -21,38 +21,41 @@ Building Apache log4cxx with Apache Maven 2 {{{https://maven.apache.org}Apache Maven 2}} is used to generate the release assemblies and generate - product documentation. It delegates to the {{{./ant.html}Apache Ant build}} to build - and test log4cxx and can be used as an alternate front end to the Ant - build process since it can automatically download and use ant-contrib, - cpptasks and log4j. - The Maven build, like the Ant build, can build APR and APR-Util from source. + product documentation. It delegates to {{{./cmake.html}CMake}} to build + and test log4cxx and can be used as an alternate front end to the CMake + build process since it can automatically download and use cmake, + and log4j. * Quick start: *Install {{{https://maven.apache.org}Apache Maven}} 2.0.8 or later. - *Install APR and APR-Util or place source in apr and apr-util directories in same parent directory - as log4cxx directory. + *Install APR and APR-Util. Building and testing log4cxx on a Unix platform with packaged APR and APR-Util. +----+ -$ sudo apt-get install libapr1-dev libaprutil1-dev doxygen -$ cd apache-log4cxx-x.x.x -$ export PATH=/home/myself/maven-2.0.8/bin:$PATH -$ mvn package + sudo apt-get install libapr1-dev libaprutil1-dev doxygen + cd apache-log4cxx-x.x.x + export PATH=/home/myself/maven-3.6.3/bin:$PATH + mvn package +----+ - Building and testing log4cxx on a Microsoft Windows with APR and APR-Util built from source. + Building and testing log4cxx on a Microsoft Windows with APR, Expat and APR-Util built from source + extracted into apr-1.7.0, libexpat(from github) and apr-util-1.6.1 in %HOMEPATH%\Libraries. +----+ -$ set PATH=\maven-2.0.8\bin;%PATH% -$ tar -xvzf apr-1.2.12.tar.gz -$ rename apr-1.2.12 apr -$ tar -xvzf apr-util-1.2.12.tar.gz -$ rename apr-util-1.2.12 apr-util -$ cd apache-log4cxx-x.x.x -$ mvn package + cd %HOMEPATH%\Libraries + cmake -S libexpat\expat -B buildtrees\expat -DCMAKE_INSTALL_PREFIX=%HOMEPATH%\Libraries\installed + cmake --build buildtrees\expat --target install --config Release + cmake -S apr-1.7.0 -B buildtrees\apr -DCMAKE_INSTALL_PREFIX=%HOMEPATH%\Libraries\installed + cmake --build buildtrees\apr --target install --config Release + set CMAKE_PREFIX_PATH=%HOMEPATH%\Libraries\installed + cmake -S apr-util-1.6.1 -B buildtrees\apr-util -DCMAKE_INSTALL_PREFIX=%HOMEPATH%\Libraries\installed + cmake --build buildtrees\apr-util --target install --config Release + cd apache-log4cxx-x.x.x + set PATH=%MAVEN_HOME%\bin;%PATH% + mvn package +----+ * Common Maven targets @@ -73,14 +76,5 @@ $ mvn package All build products will be placed in the target subdirectory. - It is not possible to directly pass options to the Ant build, however the ant build will read - any build.properties file in the log4cxx directory. The file has to be in the default format - for {{{https://en.wikipedia.org/wiki/.properties}Java properties files}}, especially one must not - provide options using the syntax -Dxy=z like on the shell, but only as xy=z per line. - SMTP and ODBC options can depend on libraries that that have different licenses. You should review the corresponding licenses and understand the implications before redistribution. - -* Platform specific notes: - - See the {{{./ant.html}Apache Ant build}} for platform specific notes. diff --git a/src/site/apt/building/vcpkg.apt b/src/site/apt/building/vcpkg.apt new file mode 100644 index 000000000..4c3bdecab --- /dev/null +++ b/src/site/apt/building/vcpkg.apt @@ -0,0 +1,43 @@ +~~ Licensed to the Apache Software Foundation (ASF) under one or more +~~ contributor license agreements. See the NOTICE file distributed with +~~ this work for additional information regarding copyright ownership. +~~ The ASF licenses this file to You under the Apache License, Version 2.0 +~~ (the "License"); you may not use this file except in compliance with +~~ the License. You may obtain a copy of the License at +~~ +~~ http://www.apache.org/licenses/LICENSE-2.0 +~~ +~~ Unless required by applicable law or agreed to in writing, software +~~ distributed under the License is distributed on an "AS IS" BASIS, +~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +~~ See the License for the specific language governing permissions and +~~ limitations under the License. + ------ + Building Apache log4cxx with vcpkg + ------ + ------ + ------ + +Building Apache log4cxx with vcpkg + +*Preparation + ++----+ + > git clone https://github.com/Microsoft/vcpkg.git + > cd vcpkg + + PS> .\bootstrap-vcpkg.bat + Linux:~/$ ./bootstrap-vcpkg.sh + + Then, to hook up user-wide integration, run (note: requires admin on first use) + + PS> .\vcpkg integrate install + Linux:~/$ ./vcpkg integrate install ++----+ + +*Building log4cxx.dll + ++----+ + PS> .\vcpkg install log4cxx + Linux:~/$ ./vcpkg install log4cxx ++----+ diff --git a/src/site/apt/building/xcode.apt b/src/site/apt/building/xcode.apt deleted file mode 100644 index 33a163ac1..000000000 --- a/src/site/apt/building/xcode.apt +++ /dev/null @@ -1,65 +0,0 @@ -~~ Licensed to the Apache Software Foundation (ASF) under one or more -~~ contributor license agreements. See the NOTICE file distributed with -~~ this work for additional information regarding copyright ownership. -~~ The ASF licenses this file to You under the Apache License, Version 2.0 -~~ (the "License"); you may not use this file except in compliance with -~~ the License. You may obtain a copy of the License at -~~ -~~ http://www.apache.org/licenses/LICENSE-2.0 -~~ -~~ Unless required by applicable law or agreed to in writing, software -~~ distributed under the License is distributed on an "AS IS" BASIS, -~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -~~ See the License for the specific language governing permissions and -~~ limitations under the License. - ------ - Building Apache log4cxx with Apple Xcode - ------ - ------ - ------ - -Building Apache log4cxx with Apple Xcode - -*Building log4cxx.dylib - - Run configure to generate log4cxx.h and log4cxx_private.h - then launch Xcode. - -+----+ -cd apache-log4cxx-x.x.x -./configure -open projects/log4cxx.xcodeproj -+----+ - - -*Running unit tests - - Run configure then open projects/testsuite.xcodeproj - or projects/testsuite-standalone.xcodeproj - (test suite and implementation in one project) in Xcode. - - The unit tests require the working directory and several environment variables - to be set. To set these, select the executable in Groups & Files, press Info and: - - * In the General pane, set Working Directory to Custom with path "../src/test/resources". - - * In the Arguments pane, add following key value pairs to "Variables to be set in the environment": - TOTO=wonderful, key1=value1 and key2=value2. - - * In the Arguments pane, add "-v" for verbose output, or individual test names in "Arguments to be passed on launch". - -*Issues - - The project file generation does does not - properly create an entry in the "Link Binary with Libraries" - build phase for projects (such as the examples and unit tests) that depend - on log4cxx. To work around the problem, open the project in Xcode and - in the Groups & Files pane, drag log4cxx.dylib - and drop on the "Link Binary with Libraries" folder - under Targets. - - See issue {{{https://issues.apache.org/jira/browse/LOGCXX-245}LOGCXX-245}} for further information. - - The projects provided in the release target Mac OS/X 10.5 which provides - preinstalled APR and APR-Util libraries. To generate XCode projects to target Mac OS/X 10.4, - set up the ant build and then "ant build-projects-xcode -Dfind=false". diff --git a/src/site/site.xml b/src/site/site.xml index c33ae73f7..69412627c 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -111,17 +111,14 @@ - - - diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt new file mode 100644 index 000000000..42ff35733 --- /dev/null +++ b/src/test/CMakeLists.txt @@ -0,0 +1,5 @@ +find_package(Java COMPONENTS Development) +if(Java_Development_FOUND) + add_subdirectory(java) +endif(Java_Development_FOUND) +add_subdirectory(cpp) diff --git a/src/test/cpp/CMakeLists.txt b/src/test/cpp/CMakeLists.txt new file mode 100644 index 000000000..6f863515d --- /dev/null +++ b/src/test/cpp/CMakeLists.txt @@ -0,0 +1,87 @@ +# Determine whether to include tests that call sed +find_program(sedProgram sed) + +# Components required by all tests +add_library(testingFramework STATIC abts.cpp appenderskeletontestcase.cpp logunit.cpp vectorappender.cpp writerappendertestcase.cpp ) +target_include_directories(testingFramework PRIVATE ${CMAKE_CURRENT_LIST_DIR} $) +add_subdirectory(util) +target_sources(testingUtilities PRIVATE xml/xlevel.cpp) + +# Tests defined in this directory +set(ALL_LOG4CXX_TESTS + asyncappendertestcase + consoleappendertestcase + decodingtest + encodingtest + fileappendertest + filetestcase + hierarchytest + hierarchythresholdtestcase + jsonlayouttest + l7dtestcase + leveltestcase + loggertestcase + mdctestcase + ndctestcase + + propertyconfiguratortest + rollingfileappendertestcase + streamtestcase +) +if(sedProgram) + list(APPEND ALL_LOG4CXX_TESTS minimumtestcase patternlayouttest) +endif() +foreach(fileName IN LISTS ALL_LOG4CXX_TESTS) + add_executable(${fileName} "${fileName}.cpp") +endforeach() +target_sources(rollingfileappendertestcase PRIVATE fileappendertestcase.cpp) + +# Tests defined in subdirectories +add_subdirectory(helpers) +add_subdirectory(customlogger) +if(LOG4CXX_HAS_ODBC OR WIN32) + add_subdirectory(db) +endif() +add_subdirectory(defaultinit) +add_subdirectory(filter) +add_subdirectory(net) +if(WIN32) + add_subdirectory(nt) +endif() +add_subdirectory(pattern) +add_subdirectory(rolling) +add_subdirectory(spi) +add_subdirectory(varia) +add_subdirectory(xml) + +foreach(testName IN LISTS ALL_LOG4CXX_TESTS) + target_include_directories(${testName} PRIVATE ${CMAKE_CURRENT_LIST_DIR} $) + target_link_libraries(${testName} PRIVATE testingFramework testingUtilities log4cxx ${APR_LIBRARIES}) + add_test(NAME ${testName} + COMMAND ${testName} -v + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../resources + ) + + if(WIN32) + set(LOG4CXX_DLL_DIR "$>") + if(${testName} STREQUAL socketservertestcase) + set_tests_properties(socketservertestcase PROPERTIES + ENVIRONMENT "SOCKET_SERVER_PARAMETER_FILE=${START_SOCKET_SERVER_PARAMETER_FILE};PATH=${LOG4CXX_DLL_DIR}\;${APR_DLL_DIR}\;${APR_UTIL_DLL_DIR}" + ) + else() + set_tests_properties(${testName} PROPERTIES + ENVIRONMENT "TOTO=wonderful;key1=value1;key2=value2;PATH==${LOG4CXX_DLL_DIR}\;${APR_DLL_DIR}\;${APR_UTIL_DLL_DIR}" + ) + endif() + else() + if(${testName} STREQUAL socketservertestcase) + set_tests_properties(socketservertestcase PROPERTIES + ENVIRONMENT "SOCKET_SERVER_PARAMETER_FILE=${START_SOCKET_SERVER_PARAMETER_FILE}" + ) + else() + set_tests_properties(${testName} PROPERTIES + ENVIRONMENT "TOTO=wonderful;key1=value1;key2=value2" + ) + endif() + endif() +endforeach() diff --git a/src/test/cpp/customlogger/CMakeLists.txt b/src/test/cpp/customlogger/CMakeLists.txt new file mode 100644 index 000000000..76f02d690 --- /dev/null +++ b/src/test/cpp/customlogger/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(xloggertestcase xloggertestcase.cpp xlogger.cpp) +set(ALL_LOG4CXX_TESTS ${ALL_LOG4CXX_TESTS} xloggertestcase PARENT_SCOPE) diff --git a/src/test/cpp/db/CMakeLists.txt b/src/test/cpp/db/CMakeLists.txt new file mode 100644 index 000000000..3f34418d7 --- /dev/null +++ b/src/test/cpp/db/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(odbcappendertestcase odbcappendertestcase.cpp) +target_include_directories(odbcappendertestcase PRIVATE ${CMAKE_CURRENT_LIST_DIR} $) +target_link_libraries(odbcappendertestcase log4cxx testingFramework testingUtilities ${APR_LIBRARIES}) diff --git a/src/test/cpp/defaultinit/CMakeLists.txt b/src/test/cpp/defaultinit/CMakeLists.txt new file mode 100644 index 000000000..a9d2ee8cc --- /dev/null +++ b/src/test/cpp/defaultinit/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(defaultinittestcase testcase1.cpp testcase2.cpp testcase3.cpp testcase4.cpp) +set(ALL_LOG4CXX_TESTS ${ALL_LOG4CXX_TESTS} defaultinittestcase PARENT_SCOPE) diff --git a/src/test/cpp/defaultinit/testcase1.cpp b/src/test/cpp/defaultinit/testcase1.cpp index 9d60bb56d..b0059a407 100644 --- a/src/test/cpp/defaultinit/testcase1.cpp +++ b/src/test/cpp/defaultinit/testcase1.cpp @@ -48,5 +48,5 @@ LOGUNIT_CLASS(TestCase1) }; -LOGUNIT_TEST_SUITE_REGISTRATION_DISABLED(TestCase1) +LOGUNIT_TEST_SUITE_REGISTRATION(TestCase1) diff --git a/src/test/cpp/defaultinit/testcase2.cpp b/src/test/cpp/defaultinit/testcase2.cpp index 13c755d4f..1c362c2d8 100644 --- a/src/test/cpp/defaultinit/testcase2.cpp +++ b/src/test/cpp/defaultinit/testcase2.cpp @@ -21,6 +21,8 @@ #include #include +#include +#include #include "../insertwide.h" #include "../logunit.h" @@ -35,17 +37,21 @@ LOGUNIT_CLASS(TestCase2) public: void setUp() { + helpers::Pool p; + apr_file_copy("input/xml/defaultInit.xml", "log4cxx.xml", APR_FPROT_UREAD|APR_FPROT_UWRITE, p.getAPRPool()); } void tearDown() { + helpers::Pool p; + apr_file_remove("log4cxx.xml", p.getAPRPool()); LogManager::shutdown(); } void xmlTest() { LoggerPtr root = Logger::getRootLogger(); - LOG4CXX_DEBUG(root, "Hello, world"); + LOG4CXX_DEBUG(root, "Hello, world"); bool rootIsConfigured = !root->getAllAppenders().empty(); LOGUNIT_ASSERT(rootIsConfigured); @@ -56,6 +62,6 @@ LOGUNIT_CLASS(TestCase2) }; -LOGUNIT_TEST_SUITE_REGISTRATION_DISABLED(TestCase2) +LOGUNIT_TEST_SUITE_REGISTRATION(TestCase2) diff --git a/src/test/cpp/defaultinit/testcase3.cpp b/src/test/cpp/defaultinit/testcase3.cpp index 37e0761ca..2b36f2828 100644 --- a/src/test/cpp/defaultinit/testcase3.cpp +++ b/src/test/cpp/defaultinit/testcase3.cpp @@ -17,6 +17,8 @@ #include #include +#include +#include #include "../insertwide.h" #include "../logunit.h" @@ -31,10 +33,14 @@ LOGUNIT_CLASS(TestCase3) public: void setUp() { + helpers::Pool p; + apr_file_copy("input/defaultInit3.properties", "log4cxx.properties", APR_FPROT_UREAD|APR_FPROT_UWRITE, p.getAPRPool()); } void tearDown() { + helpers::Pool p; + apr_file_remove("log4cxx.properties", p.getAPRPool()); LogManager::shutdown(); } @@ -52,4 +58,4 @@ LOGUNIT_CLASS(TestCase3) }; -LOGUNIT_TEST_SUITE_REGISTRATION_DISABLED(TestCase3) +LOGUNIT_TEST_SUITE_REGISTRATION(TestCase3) diff --git a/src/test/cpp/defaultinit/testcase4.cpp b/src/test/cpp/defaultinit/testcase4.cpp index 64bc06ef7..d22806ae6 100644 --- a/src/test/cpp/defaultinit/testcase4.cpp +++ b/src/test/cpp/defaultinit/testcase4.cpp @@ -21,6 +21,8 @@ #include #include +#include +#include #include "../insertwide.h" #include "../logunit.h" @@ -35,10 +37,14 @@ LOGUNIT_CLASS(TestCase4) public: void setUp() { + helpers::Pool p; + apr_file_copy("input/xml/defaultInit.xml", "log4cxx.xml", APR_FPROT_UREAD|APR_FPROT_UWRITE, p.getAPRPool()); } void tearDown() { + helpers::Pool p; + apr_file_remove("log4cxx.xml", p.getAPRPool()); LogManager::shutdown(); } @@ -57,5 +63,5 @@ LOGUNIT_CLASS(TestCase4) }; -LOGUNIT_TEST_SUITE_REGISTRATION_DISABLED(TestCase4) +LOGUNIT_TEST_SUITE_REGISTRATION(TestCase4) diff --git a/src/test/cpp/filter/CMakeLists.txt b/src/test/cpp/filter/CMakeLists.txt new file mode 100644 index 000000000..83dc49851 --- /dev/null +++ b/src/test/cpp/filter/CMakeLists.txt @@ -0,0 +1,9 @@ +add_executable(filtertests + andfiltertest.cpp + denyallfiltertest.cpp + levelmatchfiltertest.cpp + levelrangefiltertest.cpp + loggermatchfiltertest.cpp + stringmatchfiltertest.cpp +) +set(ALL_LOG4CXX_TESTS ${ALL_LOG4CXX_TESTS} filtertests PARENT_SCOPE) diff --git a/src/test/cpp/helpers/CMakeLists.txt b/src/test/cpp/helpers/CMakeLists.txt new file mode 100644 index 000000000..bb27546fb --- /dev/null +++ b/src/test/cpp/helpers/CMakeLists.txt @@ -0,0 +1,28 @@ +set(HELPER_TESTS + absolutetimedateformattestcase + cacheddateformattestcase + charsetdecodertestcase + charsetencodertestcase + cyclicbuffertestcase + datetimedateformattestcase + filewatchdogtest + inetaddresstestcase + iso8601dateformattestcase + messagebuffertest + optionconvertertestcase + propertiestestcase + relativetimedateformattestcase + stringhelpertestcase + stringtokenizertestcase + syslogwritertest + threadtestcase + timezonetestcase + transcodertestcase +) +foreach(fileName IN LISTS HELPER_TESTS) + add_executable(${fileName} "${fileName}.cpp") + target_include_directories(${fileName} PRIVATE ${CMAKE_CURRENT_LIST_DIR} $ ${APR_INCLUDE_DIR}) +endforeach() +target_sources(cacheddateformattestcase PRIVATE localechanger.cpp) +target_sources(datetimedateformattestcase PRIVATE localechanger.cpp) +set(ALL_LOG4CXX_TESTS ${ALL_LOG4CXX_TESTS} ${HELPER_TESTS} PARENT_SCOPE) diff --git a/src/test/cpp/net/CMakeLists.txt b/src/test/cpp/net/CMakeLists.txt new file mode 100644 index 000000000..bee6f346c --- /dev/null +++ b/src/test/cpp/net/CMakeLists.txt @@ -0,0 +1,21 @@ + +# Tests defined in this directory +set(NET_TESTS + socketappendertestcase + sockethubappendertestcase + syslogappendertestcase + telnetappendertestcase + xmlsocketappendertestcase +) +if(HAS_LIBESMPT) + list(APPEND NET_TESTS smtpappendertestcase) +endif(HAS_LIBESMPT) +foreach(fileName IN LISTS NET_TESTS) + add_executable(${fileName} "${fileName}.cpp") +endforeach() +if(Java_Development_FOUND AND sedProgram) + add_executable(socketservertestcase socketserverstarter.cpp socketservertestcase.cpp) + add_dependencies(socketservertestcase test-classes) + list(APPEND NET_TESTS socketservertestcase) +endif() +set(ALL_LOG4CXX_TESTS ${ALL_LOG4CXX_TESTS} ${NET_TESTS} PARENT_SCOPE) diff --git a/src/test/cpp/net/socketserverstarter.cpp b/src/test/cpp/net/socketserverstarter.cpp new file mode 100644 index 000000000..a8c2ae0e6 --- /dev/null +++ b/src/test/cpp/net/socketserverstarter.cpp @@ -0,0 +1,166 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "../logunit.h" + +#include +#include +#include +#include +#include +#include +#include + +using namespace log4cxx; + +LOGUNIT_CLASS(SocketServerStarter) +{ + LOGUNIT_TEST_SUITE(SocketServerStarter); + LOGUNIT_TEST(startServer); + LOGUNIT_TEST_SUITE_END(); + +public: + void setUp() + { + } + + void tearDown() + { + } + + void startServer() + { + helpers::Pool p; + apr_pool_t* pool = p.getAPRPool(); + char* cmd = NULL; + apr_status_t stat = apr_env_get(&cmd, "SOCKET_SERVER_COMMAND", pool); + char* param_file = NULL; + stat = apr_env_get(¶m_file, "SOCKET_SERVER_PARAMETER_FILE", pool); + + // prepare to launch the server + // + apr_proc_t server_pid; + apr_procattr_t* attr = NULL; + stat = apr_procattr_create(&attr, pool); + if (stat != APR_SUCCESS) + LOGUNIT_FAIL("apr_procattr_create failed"); + stat = apr_procattr_io_set(attr, APR_NO_PIPE, APR_NO_PIPE, APR_NO_PIPE); + if (stat != APR_SUCCESS) + LOGUNIT_FAIL("apr_procattr_io_set failed"); + + //fprintf(stdout, "SOCKET_SERVER_COMMAND=%s\n", cmd); + stat = apr_procattr_cmdtype_set(attr, APR_PROGRAM); + if (stat != APR_SUCCESS) + LOGUNIT_FAIL("apr_procattr_cmdtype_set failed"); + + if (cmd && *cmd) + { + // convert the space separated cmd string to the argument list + // + static const int MaxArgumentCount = 14; + char** argv = (char**)apr_palloc(pool, (MaxArgumentCount + 1) * sizeof(*argv)); + char* pcmd = apr_pstrdup(pool, cmd); + int i = 0; + for (; i < MaxArgumentCount && pcmd && *pcmd; ++i) + { + char separ = ' '; + while(separ == *pcmd) + { + *pcmd = 0; + ++pcmd; + } + if ('"' == *pcmd || '\'' == *pcmd) + { + separ = *pcmd; + ++pcmd; + } + argv[i] = pcmd; + if (NULL != (pcmd = strchr(pcmd, separ))) + { + *pcmd = 0; + ++pcmd; + while(' ' == *pcmd) + { + *pcmd = 0; + ++pcmd; + } + } + } + argv[i] = 0; + stat = apr_proc_create(&server_pid, argv[0], argv, NULL, attr, pool); + + + if (stat == APR_SUCCESS) // Allow server time to load + apr_sleep(1000000); // 1 seconds + else + fprintf(stderr, "apr_proc_create failed to start %s\n", argv[0]); + } + else if (param_file && *param_file) + { + // Build the argument list from param_file + // + //fprintf(stderr, "Processing: %s\n", param_file); + std::ifstream in(param_file); + std::vector params; + while (in) + { + params.push_back(std::string()); + std::string& line = params.back(); + std::getline(in, line); + while (!line.empty() && (' ' == line[0] || '\t' == line[0])) + line.erase(0, 1); + while (!line.empty() && (' ' == line[line.size() - 1] || '\t' == line[line.size() - 1])) + line.erase(line.size() - 1, 1); + if (line.empty()) + params.pop_back(); + } + const char** argv = (const char**)apr_palloc(pool, (params.size() + 1) * sizeof(*argv)); + int i = 0; + for (; i < params.size(); ++i) + { + argv[i] = params[i].c_str(); + //fprintf(stderr, "argv[%i]: %s\n", i, argv[i]); + } + argv[i] = 0; + stat = apr_proc_create(&server_pid, argv[0], argv, NULL, attr, pool); + + + if (stat == APR_SUCCESS) // Allow server time to load + apr_sleep(1000000); // 1 seconds + else + fprintf(stderr, "apr_proc_create failed to start %s\n", argv[0]); + } + else + { + fputs("Either:\n", stderr); + fputs(" The environment variable SOCKET_SERVER_COMMAND" + " must contain the server process path" + " followed by space separated command arguments\n", stderr); + fputs("Or:\n", stderr); + fputs(" The file named in the environment variable SOCKET_SERVER_PARAMETER_FILE" + " must contain a line per argument starting with the server process path" + " followed by lines containing command arguments\n", stderr); + stat = -1; + } + + LOGUNIT_ASSERT(stat == APR_SUCCESS); + } +}; + + +LOGUNIT_TEST_SUITE_REGISTRATION(SocketServerStarter) + diff --git a/src/test/cpp/net/socketservertestcase.cpp b/src/test/cpp/net/socketservertestcase.cpp index ce4444f16..d46b3784b 100644 --- a/src/test/cpp/net/socketservertestcase.cpp +++ b/src/test/cpp/net/socketservertestcase.cpp @@ -38,7 +38,6 @@ #include "../logunit.h" #include - //Define INT64_C for compilers that don't have it #if (!defined(INT64_C)) #define INT64_C(value) value ## LL @@ -478,4 +477,4 @@ LOGUNIT_CLASS(SocketServerTestCase) const File SocketServerTestCase::TEMP("output/temp"); const File SocketServerTestCase::FILTERED("output/filtered"); -LOGUNIT_TEST_SUITE_REGISTRATION_DISABLED(SocketServerTestCase) +LOGUNIT_TEST_SUITE_REGISTRATION(SocketServerTestCase) diff --git a/src/test/cpp/nt/CMakeLists.txt b/src/test/cpp/nt/CMakeLists.txt new file mode 100644 index 000000000..0b8a825ff --- /dev/null +++ b/src/test/cpp/nt/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(eventlogtests nteventlogappendertestcase.cpp) +set(ALL_LOG4CXX_TESTS ${ALL_LOG4CXX_TESTS} eventlogtests PARENT_SCOPE) diff --git a/src/test/cpp/pattern/CMakeLists.txt b/src/test/cpp/pattern/CMakeLists.txt new file mode 100644 index 000000000..cd00697ad --- /dev/null +++ b/src/test/cpp/pattern/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(patternparsertestcase patternparsertestcase.cpp num343patternconverter.cpp) +set(ALL_LOG4CXX_TESTS ${ALL_LOG4CXX_TESTS} patternparsertestcase PARENT_SCOPE) diff --git a/src/test/cpp/rolling/CMakeLists.txt b/src/test/cpp/rolling/CMakeLists.txt new file mode 100644 index 000000000..2b2c6503c --- /dev/null +++ b/src/test/cpp/rolling/CMakeLists.txt @@ -0,0 +1,14 @@ +# Tests defined in this directory +set(ROLLING_TESTS + filenamepatterntestcase + filterbasedrollingtest + manualrollingtest + obsoletedailyrollingfileappendertest + obsoleterollingfileappendertest + sizebasedrollingtest + timebasedrollingtest +) +foreach(fileName IN LISTS ROLLING_TESTS) + add_executable(${fileName} "${fileName}.cpp") +endforeach() +set(ALL_LOG4CXX_TESTS ${ALL_LOG4CXX_TESTS} ${ROLLING_TESTS} PARENT_SCOPE) diff --git a/src/test/cpp/spi/CMakeLists.txt b/src/test/cpp/spi/CMakeLists.txt new file mode 100644 index 000000000..380269f66 --- /dev/null +++ b/src/test/cpp/spi/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(spitestcase loggingeventtest.cpp) +set(ALL_LOG4CXX_TESTS ${ALL_LOG4CXX_TESTS} spitestcase PARENT_SCOPE) diff --git a/src/test/cpp/util/CMakeLists.txt b/src/test/cpp/util/CMakeLists.txt new file mode 100644 index 000000000..dd25dd726 --- /dev/null +++ b/src/test/cpp/util/CMakeLists.txt @@ -0,0 +1,21 @@ +# Components required by all tests +add_library(testingUtilities STATIC + serializationtesthelper.cpp + absolutedateandtimefilter.cpp + absolutetimefilter.cpp + binarycompare.cpp + compare.cpp + controlfilter.cpp + filenamefilter.cpp + iso8601filter.cpp + linenumberfilter.cpp + relativetimefilter.cpp + threadfilter.cpp + transformer.cpp + utilfilter.cpp + xmlfilenamefilter.cpp + xmllineattributefilter.cpp + xmlthreadfilter.cpp + xmltimestampfilter.cpp +) +target_include_directories(testingUtilities PRIVATE ${CMAKE_CURRENT_LIST_DIR} $) diff --git a/src/test/cpp/varia/CMakeLists.txt b/src/test/cpp/varia/CMakeLists.txt new file mode 100644 index 000000000..2bef8aa5e --- /dev/null +++ b/src/test/cpp/varia/CMakeLists.txt @@ -0,0 +1,13 @@ +# Tests defined in this directory +set(VARIA_TESTS + levelmatchfiltertestcase + levelrangefiltertestcase +) +if(sedProgram) + list(APPEND VARIA_TESTS errorhandlertestcase) +endif() + +foreach(fileName IN LISTS VARIA_TESTS) + add_executable(${fileName} "${fileName}.cpp") +endforeach() +set(ALL_LOG4CXX_TESTS ${ALL_LOG4CXX_TESTS} ${VARIA_TESTS} PARENT_SCOPE) diff --git a/src/test/cpp/xml/CMakeLists.txt b/src/test/cpp/xml/CMakeLists.txt new file mode 100644 index 000000000..e9e421b22 --- /dev/null +++ b/src/test/cpp/xml/CMakeLists.txt @@ -0,0 +1,9 @@ +add_executable(xmltests + xmllayouttest +) +if(sedProgram) + list(APPEND xmltests domtestcase xmllayouttestcase) +endif() + +target_link_libraries(xmltests PRIVATE ${APR_UTIL_LIBRARIES}) +set(ALL_LOG4CXX_TESTS ${ALL_LOG4CXX_TESTS} xmltests PARENT_SCOPE) diff --git a/src/test/java/CMakeLists.txt b/src/test/java/CMakeLists.txt new file mode 100644 index 000000000..061824178 --- /dev/null +++ b/src/test/java/CMakeLists.txt @@ -0,0 +1,33 @@ +include(FetchContent) +FetchContent_Declare(log4j + URL https://www-us.apache.org/dist/logging/log4j/1.2.17/log4j-1.2.17.tar.gz + URL_HASH MD5=8218714e41ee0c6509dcfeafa2e1f53f +) +FetchContent_GetProperties(log4j) +if(NOT log4j_POPULATED) + FetchContent_Populate(log4j) +endif() +set(log4j_CLASSPATH "${log4j_SOURCE_DIR}/log4j-1.2.17.jar" ) +set(SOCKET_SERVER_SOURCES org/apache/log4j/net/ShortSocketServer.java) +add_custom_target(test-classes + COMMAND ${Java_JAVAC_EXECUTABLE} -d ${CMAKE_CURRENT_BINARY_DIR} + -classpath "${log4j_CLASSPATH}" ${SOCKET_SERVER_SOURCES} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) +if(WIN32) + set(SOCKET_SERVER_CLASSPATH "${CMAKE_CURRENT_BINARY_DIR};${log4j_CLASSPATH}") +else() + set(SOCKET_SERVER_CLASSPATH "${CMAKE_CURRENT_BINARY_DIR}:${log4j_CLASSPATH}") +endif() + +# Use a parameter file to avoid issues with processing ';' +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/StartSocketServerParams.txt +"${Java_JAVA_EXECUTABLE} +-classpath +${SOCKET_SERVER_CLASSPATH} +org.apache.log4j.net.ShortSocketServer +8 +input/socketServer +" +) +set(START_SOCKET_SERVER_PARAMETER_FILE ${CMAKE_CURRENT_BINARY_DIR}/StartSocketServerParams.txt PARENT_SCOPE)