[C] Enabled wchar_t and utf-8 by default

This commit is contained in:
seleznevae 2019-08-29 09:12:58 +03:00
parent 5bfabee696
commit 64dbd4c2c4
9 changed files with 79 additions and 24 deletions

View File

@ -14,14 +14,14 @@ main_task:
# Basic c build # Basic c build
- cd lib - cd lib
- cc -Wall -Wextra -Werror --std=gnu89 -DFT_CONGIG_HAVE_WCHAR fort.c -c -o fort.o - cc -Wall -Wextra -Werror --std=gnu89 fort.c -c -o fort.o
- rm fort.o - rm fort.o
- cd .. - cd ..
# Basic c++ build # Basic c++ build
- cd lib - cd lib
- cp fort.c fort.cpp - cp fort.c fort.cpp
- c++ -Wall -Wextra -Werror -DFT_CONGIG_HAVE_WCHAR fort.cpp -c -o fort.o - c++ -Wall -Wextra -Werror fort.cpp -c -o fort.o
- rm fort.o - rm fort.o
- rm fort.cpp - rm fort.cpp
- cd .. - cd ..
@ -47,10 +47,10 @@ main_task:
- cd .. - cd ..
- rm -r build/* - rm -r build/*
# Test without WCHAR support # Test without WCHAR and UTF-8 support
- mkdir -p build - mkdir -p build
- cd build - cd build
- cmake .. -DFORT_ENABLE_WCHAR=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_STANDARD=99 -DCMAKE_CXX_STANDARD=11 -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS}" -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" - cmake .. -DFORT_ENABLE_WCHAR=OFF -DFORT_ENABLE_UTF8=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_STANDARD=99 -DCMAKE_CXX_STANDARD=11 -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS}" -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}"
- cmake --build . --target all - cmake --build . --target all
- ls - ls
- ctest -VV - ctest -VV

View File

@ -144,7 +144,7 @@ script:
# basic build with old c standard (use gnu89 instead of c89 because some functions are not defines in c89) # basic build with old c standard (use gnu89 instead of c89 because some functions are not defines in c89)
- cd lib - cd lib
- ${CC} -Wall -Wextra -Werror --std=gnu89 -DFT_CONGIG_HAVE_WCHAR fort.c -c -o fort.o - ${CC} -Wall -Wextra -Werror --std=gnu89 fort.c -c -o fort.o
- rm fort.o - rm fort.o
- cd .. - cd ..
@ -199,12 +199,12 @@ script:
- ls - ls
- ctest -VV - ctest -VV
# Test without WCHAR support # Test without WCHAR and UTF-8 support
- cd .. - cd ..
- rm -r build/* - rm -r build/*
- mkdir -p build - mkdir -p build
- cd build - cd build
- cmake .. -DFORT_ENABLE_WCHAR=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_STANDARD=99 -DCMAKE_CXX_STANDARD=11 -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS}" -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" - cmake .. -DFORT_ENABLE_WCHAR=OFF -DFORT_ENABLE_UTF8=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_STANDARD=99 -DCMAKE_CXX_STANDARD=11 -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS}" -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}"
- cmake --build . --target all - cmake --build . --target all
- ls - ls
- ctest -VV - ctest -VV

View File

@ -14,6 +14,7 @@ include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
option(FORT_ENABLE_ASTYLE "Enable astyle" OFF) option(FORT_ENABLE_ASTYLE "Enable astyle" OFF)
option(FORT_ENABLE_WCHAR "Enable wchar support" ON) option(FORT_ENABLE_WCHAR "Enable wchar support" ON)
option(FORT_ENABLE_UTF8 "Enable utf8 support" ON)
set(FORT_BUILD_TYPE "common" CACHE STRING "Build type") set(FORT_BUILD_TYPE "common" CACHE STRING "Build type")
set_property(CACHE FORT_BUILD_TYPE PROPERTY STRINGS set_property(CACHE FORT_BUILD_TYPE PROPERTY STRINGS
@ -137,11 +138,16 @@ endforeach()
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Add WChar support for the build # Add WChar support for the build
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
if(FORT_ENABLE_WCHAR) if(NOT FORT_ENABLE_WCHAR)
add_definitions(-DFT_CONGIG_HAVE_WCHAR) add_definitions(-DFT_CONGIG_DISABLE_WCHAR)
endif()
if(NOT FORT_ENABLE_UTF8)
add_definitions(-DFT_CONGIG_DISABLE_UTF8)
endif() endif()
set(FORT_HAVE_WCHAR "${FORT_ENABLE_WCHAR}" CACHE STRING "fort option") set(FORT_HAVE_WCHAR "${FORT_ENABLE_WCHAR}" CACHE STRING "fort option")
set(FORT_HAVE_UTF8 "${FORT_ENABLE_UTF8}" CACHE STRING "fort option")
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------

View File

@ -1,4 +1,5 @@
option(FORT_HAVE_WCHAR "Enable wchar support" ON) option(FORT_HAVE_WCHAR "Enable wchar support" ON)
option(FORT_HAVE_UTF8 "Enable UTF8 support" ON)
add_library(fort add_library(fort
fort.c) fort.c)
@ -12,10 +13,17 @@ set_target_properties(fort
PROPERTIES VERSION ${libfort_VERSION} PROPERTIES VERSION ${libfort_VERSION}
SOVERSION ${libfort_SOVERSION}) SOVERSION ${libfort_SOVERSION})
if(FORT_HAVE_WCHAR) if(NOT FORT_HAVE_WCHAR)
target_compile_definitions(fort target_compile_definitions(fort
PRIVATE PRIVATE
-DFT_CONGIG_HAVE_WCHAR -DFT_CONGIG_DISABLE_WCHAR
)
endif()
if(NOT FORT_HAVE_UTF8)
target_compile_definitions(fort
PRIVATE
-DFT_CONGIG_DISABLE_UTF8
) )
endif() endif()

View File

@ -53,21 +53,37 @@ SOFTWARE.
/***************************************************************************** /*****************************************************************************
* Configuration * Configuration
*****************************************************************************/ *****************************************************************************/
///**
// * libfort configuration macros
// * (to enable/disable some options this macros should be defined/undefined)
// */
///** #define FT_CONGIG_HAVE_WCHAR */
//#if defined(FT_CONGIG_HAVE_WCHAR)
//#define FT_HAVE_WCHAR
//#endif
//#define FT_CONGIG_HAVE_UTF8
//#if defined(FT_CONGIG_HAVE_UTF8)
//#define FT_HAVE_UTF8
//#endif
/** /**
* libfort configuration macros * libfort configuration macros
* (to enable/disable some options this macros should be defined/undefined) * (to disable wchar_t/utf-8 support this macros should be defined)
*/ */
/** #define FT_CONGIG_HAVE_WCHAR */ /** #define FT_CONGIG_DISABLE_WCHAR */
/** #define FT_CONGIG_DISABLE_UTF8 */
#if defined(FT_CONGIG_HAVE_WCHAR) #if !defined(FT_CONGIG_DISABLE_WCHAR)
#define FT_HAVE_WCHAR #define FT_HAVE_WCHAR
#endif #endif
#define FT_CONGIG_HAVE_UTF8 #if !defined(FT_CONGIG_DISABLE_UTF8)
#if defined(FT_CONGIG_HAVE_UTF8)
#define FT_HAVE_UTF8 #define FT_HAVE_UTF8
#endif #endif
/***************************************************************************** /*****************************************************************************
* RETURN CODES * RETURN CODES
*****************************************************************************/ *****************************************************************************/

View File

@ -1,4 +1,5 @@
option(FORT_HAVE_WCHAR "Enable wchar support" ON) option(FORT_HAVE_WCHAR "Enable wchar support" ON)
option(FORT_HAVE_UTF8 "Enable UTF8 support" ON)
option(FORT_TEST_BUILD "Export some internal symbols for tests" ON) option(FORT_TEST_BUILD "Export some internal symbols for tests" ON)
add_library(fort_dev add_library(fort_dev
@ -17,10 +18,17 @@ target_include_directories(fort_dev
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
) )
if(FORT_HAVE_WCHAR) if(NOT FORT_HAVE_WCHAR)
target_compile_definitions(fort_dev target_compile_definitions(fort_dev
PRIVATE PRIVATE
-DFT_CONGIG_HAVE_WCHAR -DFT_CONGIG_DISABLE_WCHAR
)
endif()
if(NOT FORT_HAVE_UTF8)
target_compile_definitions(fort_dev
PRIVATE
-DFT_CONGIG_DISABLE_UTF8
) )
endif() endif()

View File

@ -53,21 +53,37 @@ SOFTWARE.
/***************************************************************************** /*****************************************************************************
* Configuration * Configuration
*****************************************************************************/ *****************************************************************************/
///**
// * libfort configuration macros
// * (to enable/disable some options this macros should be defined/undefined)
// */
///** #define FT_CONGIG_HAVE_WCHAR */
//#if defined(FT_CONGIG_HAVE_WCHAR)
//#define FT_HAVE_WCHAR
//#endif
//#define FT_CONGIG_HAVE_UTF8
//#if defined(FT_CONGIG_HAVE_UTF8)
//#define FT_HAVE_UTF8
//#endif
/** /**
* libfort configuration macros * libfort configuration macros
* (to enable/disable some options this macros should be defined/undefined) * (to disable wchar_t/utf-8 support this macros should be defined)
*/ */
/** #define FT_CONGIG_HAVE_WCHAR */ /** #define FT_CONGIG_DISABLE_WCHAR */
/** #define FT_CONGIG_DISABLE_UTF8 */
#if defined(FT_CONGIG_HAVE_WCHAR) #if !defined(FT_CONGIG_DISABLE_WCHAR)
#define FT_HAVE_WCHAR #define FT_HAVE_WCHAR
#endif #endif
#define FT_CONGIG_HAVE_UTF8 #if !defined(FT_CONGIG_DISABLE_UTF8)
#if defined(FT_CONGIG_HAVE_UTF8)
#define FT_HAVE_UTF8 #define FT_HAVE_UTF8
#endif #endif
/***************************************************************************** /*****************************************************************************
* RETURN CODES * RETURN CODES
*****************************************************************************/ *****************************************************************************/

View File

@ -1,4 +1,5 @@
option(FORT_HAVE_WCHAR "Enable wchar support" ON) option(FORT_HAVE_WCHAR "Enable wchar support" ON)
option(FORT_HAVE_UTF8 "Enable UTF8 support" ON)
option(FORT_TEST_BUILD "Export some internal symbols for tests" ON) option(FORT_TEST_BUILD "Export some internal symbols for tests" ON)

View File

@ -14,7 +14,7 @@
#define THEN(...) #define THEN(...)
#define SCENARIO(...) #define SCENARIO(...)
#if defined(FT_CONGIG_HAVE_WCHAR) #if !defined(FT_CONGIG_DISABLE_WCHAR)
#define FT_HAVE_WCHAR #define FT_HAVE_WCHAR
#endif #endif