mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
ThirdParty: Add optional-lite polyfill
Thanks to all who have made contributions to https://github.com/martinmoene/optional-lite
This commit is contained in:
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
cxx_binary(
|
||||
name = 'test',
|
||||
header_namespace = '',
|
||||
headers = glob([
|
||||
'*.h',
|
||||
]),
|
||||
srcs = glob([
|
||||
'*.cpp',
|
||||
]),
|
||||
compiler_flags = [
|
||||
'-std=c++11',
|
||||
],
|
||||
deps = [
|
||||
'//:optional-lite',
|
||||
],
|
||||
)
|
||||
+224
@@ -0,0 +1,224 @@
|
||||
# Copyright 2017-2018 by Martin Moene
|
||||
#
|
||||
# https://github.com/martinmoene/optional-lite
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
if( NOT DEFINED CMAKE_MINIMUM_REQUIRED_VERSION )
|
||||
cmake_minimum_required( VERSION 3.5 FATAL_ERROR )
|
||||
endif()
|
||||
|
||||
project( test LANGUAGES CXX )
|
||||
|
||||
set( unit_name "optional" )
|
||||
set( PACKAGE ${unit_name}-lite )
|
||||
set( PROGRAM ${unit_name}-lite )
|
||||
set( SOURCES ${unit_name}-main.t.cpp ${unit_name}.t.cpp )
|
||||
set( TWEAKD "." )
|
||||
|
||||
message( STATUS "Subproject '${PROJECT_NAME}', programs '${PROGRAM}-*'")
|
||||
|
||||
set( OPTIONS "" )
|
||||
set( DEFCMN "" )
|
||||
|
||||
set( HAS_STD_FLAGS FALSE )
|
||||
set( HAS_CPP98_FLAG FALSE )
|
||||
set( HAS_CPP11_FLAG FALSE )
|
||||
set( HAS_CPP14_FLAG FALSE )
|
||||
set( HAS_CPP17_FLAG FALSE )
|
||||
set( HAS_CPP20_FLAG FALSE )
|
||||
set( HAS_CPPLATEST_FLAG FALSE )
|
||||
|
||||
if( MSVC )
|
||||
message( STATUS "Matched: MSVC")
|
||||
|
||||
set( HAS_STD_FLAGS TRUE )
|
||||
|
||||
set( OPTIONS -W3 -EHsc )
|
||||
set( DEFINITIONS -D_SCL_SECURE_NO_WARNINGS ${DEFCMN} )
|
||||
|
||||
if( NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.00 )
|
||||
set( HAS_CPP14_FLAG TRUE )
|
||||
set( HAS_CPPLATEST_FLAG TRUE )
|
||||
endif()
|
||||
if( NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.11 )
|
||||
set( HAS_CPP17_FLAG TRUE )
|
||||
endif()
|
||||
|
||||
elseif( CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang" )
|
||||
message( STATUS "CompilerId: '${CMAKE_CXX_COMPILER_ID}'")
|
||||
|
||||
set( HAS_STD_FLAGS TRUE )
|
||||
set( HAS_CPP98_FLAG TRUE )
|
||||
|
||||
set( OPTIONS -Wall -Wextra -Wconversion -Wsign-conversion -Wno-missing-braces -fno-elide-constructors )
|
||||
set( DEFINITIONS ${DEFCMN} )
|
||||
|
||||
# GNU: available -std flags depends on version
|
||||
if( CMAKE_CXX_COMPILER_ID MATCHES "GNU" )
|
||||
message( STATUS "Matched: GNU")
|
||||
|
||||
if( NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8.0 )
|
||||
set( HAS_CPP11_FLAG TRUE )
|
||||
endif()
|
||||
if( NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.2 )
|
||||
set( HAS_CPP14_FLAG TRUE )
|
||||
endif()
|
||||
if( NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.1.0 )
|
||||
set( HAS_CPP17_FLAG TRUE )
|
||||
endif()
|
||||
|
||||
# AppleClang: available -std flags depends on version
|
||||
elseif( CMAKE_CXX_COMPILER_ID MATCHES "AppleClang" )
|
||||
message( STATUS "Matched: AppleClang")
|
||||
|
||||
if( NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0.0 )
|
||||
set( HAS_CPP11_FLAG TRUE )
|
||||
endif()
|
||||
if( NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1.0 )
|
||||
set( HAS_CPP14_FLAG TRUE )
|
||||
endif()
|
||||
if( NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.2.0 )
|
||||
set( HAS_CPP17_FLAG TRUE )
|
||||
endif()
|
||||
|
||||
# Clang: available -std flags depends on version
|
||||
elseif( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
||||
message( STATUS "Matched: Clang")
|
||||
|
||||
if( NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3.0 )
|
||||
set( HAS_CPP11_FLAG TRUE )
|
||||
endif()
|
||||
if( NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4.0 )
|
||||
set( HAS_CPP14_FLAG TRUE )
|
||||
endif()
|
||||
if( NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0.0 )
|
||||
set( HAS_CPP17_FLAG TRUE )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
elseif( CMAKE_CXX_COMPILER_ID MATCHES "Intel" )
|
||||
# as is
|
||||
message( STATUS "Matched: Intel")
|
||||
else()
|
||||
# as is
|
||||
message( STATUS "Matched: nothing")
|
||||
endif()
|
||||
|
||||
# enable MS C++ Core Guidelines checker if MSVC:
|
||||
|
||||
function( enable_msvs_guideline_checker target )
|
||||
if( MSVC )
|
||||
set_target_properties( ${target} PROPERTIES
|
||||
VS_GLOBAL_EnableCppCoreCheck true
|
||||
VS_GLOBAL_CodeAnalysisRuleSet CppCoreCheckRules.ruleset
|
||||
VS_GLOBAL_RunCodeAnalysis true )
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# make target, compile for given standard if specified:
|
||||
|
||||
function( make_target target std )
|
||||
message( STATUS "Make target: '${std}'" )
|
||||
|
||||
add_executable ( ${target} ${SOURCES} )
|
||||
target_include_directories( ${target} PRIVATE ${TWEAKD} )
|
||||
target_link_libraries ( ${target} PRIVATE ${PACKAGE} )
|
||||
target_compile_options ( ${target} PRIVATE ${OPTIONS} )
|
||||
target_compile_definitions( ${target} PRIVATE ${DEFINITIONS} )
|
||||
|
||||
if( std )
|
||||
if( MSVC )
|
||||
target_compile_options( ${target} PRIVATE -std:c++${std} )
|
||||
else()
|
||||
# Necessary for clang 3.x:
|
||||
target_compile_options( ${target} PRIVATE -std=c++${std} )
|
||||
# Ok for clang 4 and later:
|
||||
# set( CMAKE_CXX_STANDARD ${std} )
|
||||
# set( CMAKE_CXX_STANDARD_REQUIRED ON )
|
||||
# set( CMAKE_CXX_EXTENSIONS OFF )
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# add generic executable, unless -std flags can be specified:
|
||||
|
||||
if( NOT HAS_STD_FLAGS )
|
||||
make_target( ${PROGRAM}.t "" )
|
||||
else()
|
||||
# unconditionally add C++98 variant as MSVC has no option for it:
|
||||
if( HAS_CPP98_FLAG )
|
||||
make_target( ${PROGRAM}-cpp98.t 98 )
|
||||
else()
|
||||
make_target( ${PROGRAM}-cpp98.t "" )
|
||||
endif()
|
||||
|
||||
if( HAS_CPP11_FLAG )
|
||||
make_target( ${PROGRAM}-cpp11.t 11 )
|
||||
endif()
|
||||
|
||||
if( HAS_CPP14_FLAG )
|
||||
make_target( ${PROGRAM}-cpp14.t 14 )
|
||||
endif()
|
||||
|
||||
if( HAS_CPP17_FLAG )
|
||||
set( std17 17 )
|
||||
if( CMAKE_CXX_COMPILER_ID MATCHES "AppleClang" )
|
||||
set( std17 1z )
|
||||
endif()
|
||||
make_target( ${PROGRAM}-cpp17.t ${std17} )
|
||||
enable_msvs_guideline_checker( ${PROGRAM}-cpp17.t )
|
||||
endif()
|
||||
|
||||
if( HAS_CPPLATEST_FLAG )
|
||||
make_target( ${PROGRAM}-cpplatest.t latest )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# with C++17, honour explicit request for std::optional or nonstd::optional:
|
||||
|
||||
if( HAS_CPP17_FLAG )
|
||||
set( WHICH optional_OPTIONAL_DEFAULT )
|
||||
|
||||
if( OPTIONAL_LITE_OPT_SELECT_STD )
|
||||
set( WHICH optional_OPTIONAL_STD )
|
||||
elseif( OPTIONAL_LITE_OPT_SELECT_NONSTD )
|
||||
set( WHICH optional_OPTIONAL_NONSTD )
|
||||
endif()
|
||||
|
||||
target_compile_definitions( ${PROGRAM}-cpp17.t PRIVATE optional_CONFIG_SELECT_OPTIONAL=${WHICH} )
|
||||
|
||||
if( HAS_CPPLATEST_FLAG )
|
||||
target_compile_definitions( ${PROGRAM}-cpplatest.t PRIVATE optional_CONFIG_SELECT_OPTIONAL=${WHICH} )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# configure unit tests via CTest:
|
||||
|
||||
enable_testing()
|
||||
|
||||
if( HAS_STD_FLAGS )
|
||||
# unconditionally add C++98 variant for MSVC:
|
||||
add_test( NAME test-cpp98 COMMAND ${PROGRAM}-cpp98.t )
|
||||
|
||||
if( HAS_CPP11_FLAG )
|
||||
add_test( NAME test-cpp11 COMMAND ${PROGRAM}-cpp11.t )
|
||||
endif()
|
||||
if( HAS_CPP14_FLAG )
|
||||
add_test( NAME test-cpp14 COMMAND ${PROGRAM}-cpp14.t )
|
||||
endif()
|
||||
if( HAS_CPP17_FLAG )
|
||||
add_test( NAME test-cpp17 COMMAND ${PROGRAM}-cpp17.t )
|
||||
endif()
|
||||
if( HAS_CPPLATEST_FLAG )
|
||||
add_test( NAME test-cpplatest COMMAND ${PROGRAM}-cpplatest.t )
|
||||
endif()
|
||||
else()
|
||||
add_test( NAME test COMMAND ${PROGRAM}.t --pass )
|
||||
add_test( NAME list_version COMMAND ${PROGRAM}.t --version )
|
||||
add_test( NAME list_tags COMMAND ${PROGRAM}.t --list-tags )
|
||||
add_test( NAME list_tests COMMAND ${PROGRAM}.t --list-tests )
|
||||
endif()
|
||||
|
||||
# end of file
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
# Copyright 2014 by Martin Moene
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
# optional lite is inspired on std::optional by Fernando Cacciola and
|
||||
# Andrzej Krzemienski and on expected lite by Martin Moene.
|
||||
|
||||
# Usage: gmake [STD=c++03]
|
||||
|
||||
PROGRAM = optional-main.t
|
||||
SOURCES = $(wildcard *.cpp)
|
||||
OBJECTS = $(SOURCES:.cpp=.o)
|
||||
|
||||
ifdef STD
|
||||
STD_OPTION = -std=$(STD)
|
||||
endif
|
||||
|
||||
CXX = g++
|
||||
CXXFLAGS = $(STD_OPTION) -I../include -Wall # -Wextra
|
||||
|
||||
all: $(PROGRAM)
|
||||
|
||||
$(PROGRAM): $(OBJECTS)
|
||||
$(CXX) -o $@ $^
|
||||
|
||||
test: $(PROGRAM)
|
||||
./$(PROGRAM)
|
||||
|
||||
test-all: $(PROGRAM)
|
||||
./$(PROGRAM) @
|
||||
|
||||
list: test
|
||||
./$(PROGRAM) -l
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJECTS)
|
||||
$(RM) $(PROGRAM)
|
||||
|
||||
+1531
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
#define OPTIONAL_TWEAK_VALUE 42
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
// Copyright (c) 2016 Martin Moene
|
||||
//
|
||||
// https://github.com/martinmoene/optional-lite
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "optional-main.t.hpp"
|
||||
|
||||
#ifndef optional_HAVE
|
||||
# define optional_HAVE(FEATURE) ( optional_HAVE_##FEATURE )
|
||||
#endif
|
||||
|
||||
#define optional_PRESENT( x ) \
|
||||
std::cout << #x << ": " << x << "\n"
|
||||
|
||||
#define optional_ABSENT( x ) \
|
||||
std::cout << #x << ": (undefined)\n"
|
||||
|
||||
lest::tests & specification()
|
||||
{
|
||||
static lest::tests tests;
|
||||
return tests;
|
||||
}
|
||||
|
||||
CASE( "optional-lite version" "[.optional][.version]" )
|
||||
{
|
||||
optional_PRESENT( optional_lite_MAJOR );
|
||||
optional_PRESENT( optional_lite_MINOR );
|
||||
optional_PRESENT( optional_lite_PATCH );
|
||||
optional_PRESENT( optional_lite_VERSION );
|
||||
}
|
||||
|
||||
CASE( "optional-lite configuration" "[.optional][.config]" )
|
||||
{
|
||||
optional_PRESENT( optional_HAVE_STD_OPTIONAL );
|
||||
optional_PRESENT( optional_USES_STD_OPTIONAL );
|
||||
optional_PRESENT( optional_OPTIONAL_DEFAULT );
|
||||
optional_PRESENT( optional_OPTIONAL_NONSTD );
|
||||
optional_PRESENT( optional_OPTIONAL_STD );
|
||||
optional_PRESENT( optional_CONFIG_SELECT_OPTIONAL );
|
||||
optional_PRESENT( optional_CONFIG_NO_EXCEPTIONS );
|
||||
optional_PRESENT( optional_CPLUSPLUS );
|
||||
}
|
||||
|
||||
CASE( "__cplusplus" "[.stdc++]" )
|
||||
{
|
||||
optional_PRESENT( __cplusplus );
|
||||
}
|
||||
|
||||
CASE( "compiler version" "[.compiler]" )
|
||||
{
|
||||
#if optional_USES_STD_OPTIONAL
|
||||
std::cout << "(Compiler version not available: using std::optional)\n";
|
||||
#else
|
||||
optional_PRESENT( optional_COMPILER_CLANG_VERSION );
|
||||
optional_PRESENT( optional_COMPILER_GNUC_VERSION );
|
||||
optional_PRESENT( optional_COMPILER_MSVC_VERSION );
|
||||
#endif
|
||||
}
|
||||
|
||||
CASE( "presence of C++ language features" "[.stdlanguage]" )
|
||||
{
|
||||
#if optional_USES_STD_OPTIONAL
|
||||
std::cout << "(Presence of C++ language features not available: using std::optional)\n";
|
||||
#else
|
||||
optional_PRESENT( optional_HAVE_CONSTEXPR_11 );
|
||||
optional_PRESENT( optional_HAVE_NOEXCEPT );
|
||||
optional_PRESENT( optional_HAVE_NULLPTR );
|
||||
optional_PRESENT( optional_HAVE_REF_QUALIFIER );
|
||||
optional_PRESENT( optional_HAVE_CONSTEXPR_14 );
|
||||
#endif
|
||||
}
|
||||
|
||||
CASE( "presence of C++ library features" "[.stdlibrary]" )
|
||||
{
|
||||
#if optional_USES_STD_OPTIONAL
|
||||
std::cout << "(Presence of C++ library features not available: using std::optional)\n";
|
||||
#else
|
||||
optional_PRESENT( optional_HAVE_CONDITIONAL );
|
||||
optional_PRESENT( optional_HAVE_REMOVE_CV );
|
||||
optional_PRESENT( optional_HAVE_TYPE_TRAITS );
|
||||
optional_PRESENT( optional_HAVE_TR1_TYPE_TRAITS );
|
||||
optional_PRESENT( optional_HAVE_TR1_ADD_POINTER );
|
||||
optional_PRESENT( optional_HAVE_IS_ASSIGNABLE );
|
||||
optional_PRESENT( optional_HAVE_IS_MOVE_CONSTRUCTIBLE );
|
||||
optional_PRESENT( optional_HAVE_IS_NOTHROW_MOVE_ASSIGNABLE );
|
||||
optional_PRESENT( optional_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE );
|
||||
optional_PRESENT( optional_HAVE_IS_TRIVIALLY_COPY_CONSTRUCTIBLE );
|
||||
optional_PRESENT( optional_HAVE_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE );
|
||||
#endif
|
||||
#ifdef _HAS_CPP0X
|
||||
optional_PRESENT( _HAS_CPP0X );
|
||||
#else
|
||||
optional_ABSENT( _HAS_CPP0X );
|
||||
#endif
|
||||
}
|
||||
|
||||
int main( int argc, char * argv[] )
|
||||
{
|
||||
return lest::run( specification(), argc, argv );
|
||||
}
|
||||
|
||||
#if 0
|
||||
g++ -I../include -o optional-lite.t.exe optional-lite.t.cpp && optional-lite.t.exe --pass
|
||||
g++ -std=c++98 -I../include -o optional-lite.t.exe optional-lite.t.cpp && optional-lite.t.exe --pass
|
||||
g++ -std=c++03 -I../include -o optional-lite.t.exe optional-lite.t.cpp && optional-lite.t.exe --pass
|
||||
g++ -std=c++0x -I../include -o optional-lite.t.exe optional-lite.t.cpp && optional-lite.t.exe --pass
|
||||
g++ -std=c++11 -I../include -o optional-lite.t.exe optional-lite.t.cpp && optional-lite.t.exe --pass
|
||||
g++ -std=c++14 -I../include -o optional-lite.t.exe optional-lite.t.cpp && optional-lite.t.exe --pass
|
||||
g++ -std=c++17 -I../include -o optional-lite.t.exe optional-lite.t.cpp && optional-lite.t.exe --pass
|
||||
|
||||
cl -EHsc -I../include optional-lite.t.cpp && optional-lite.t.exe --pass
|
||||
#endif
|
||||
|
||||
// end of file
|
||||
@@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2016 Martin Moene
|
||||
//
|
||||
// https://github.com/martinmoene/optional-lite
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef TEST_OPTIONAL_LITE_H_INCLUDED
|
||||
#define TEST_OPTIONAL_LITE_H_INCLUDED
|
||||
|
||||
#include "nonstd/optional.hpp"
|
||||
|
||||
// Compiler warning suppression for usage of lest:
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang diagnostic ignored "-Wstring-conversion"
|
||||
# pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
# pragma clang diagnostic ignored "-Wunused-template"
|
||||
# pragma clang diagnostic ignored "-Wunused-function"
|
||||
# pragma clang diagnostic ignored "-Wunused-member-function"
|
||||
#elif defined __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
# pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
#include <iosfwd>
|
||||
namespace lest { template<typename T> std::ostream & operator<<( std::ostream & os, nonstd::optional<T> const & v ); }
|
||||
|
||||
#include "lest_cpp03.hpp"
|
||||
|
||||
#define CASE( name ) lest_CASE( specification(), name )
|
||||
|
||||
extern lest::tests & specification();
|
||||
|
||||
namespace lest {
|
||||
|
||||
template< typename T >
|
||||
inline std::ostream & operator<<( std::ostream & os, nonstd::optional<T> const & v )
|
||||
{
|
||||
using lest::to_string;
|
||||
return os << "[optional:" << (v ? to_string(*v) : "[empty]") << "]";
|
||||
}
|
||||
|
||||
} // namespace lest
|
||||
|
||||
#endif // TEST_OPTIONAL_LITE_H_INCLUDED
|
||||
|
||||
// end of file
|
||||
+1433
File diff suppressed because it is too large
Load Diff
Vendored
+56
@@ -0,0 +1,56 @@
|
||||
@echo off & setlocal enableextensions enabledelayedexpansion
|
||||
::
|
||||
:: t.bat - compile & run tests (MSVC).
|
||||
::
|
||||
|
||||
set unit=optional
|
||||
|
||||
:: if no std is given, use compiler default
|
||||
|
||||
set std=%1
|
||||
if not "%std%"=="" set std=-std:%std%
|
||||
|
||||
call :CompilerVersion version
|
||||
echo VC%version%: %args%
|
||||
|
||||
set UCAP=%unit%
|
||||
call :toupper UCAP
|
||||
|
||||
set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_DEFAULT
|
||||
::set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_NONSTD
|
||||
::set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_STD
|
||||
|
||||
set unit_config=
|
||||
|
||||
set msvc_defines=^
|
||||
-D_CRT_SECURE_NO_WARNINGS ^
|
||||
-D_SCL_SECURE_NO_WARNINGS
|
||||
|
||||
set CppCoreCheckInclude=%VCINSTALLDIR%\Auxiliary\VS\include
|
||||
|
||||
cl -W3 -EHsc %std% %unit_select% %unit_config% %msvc_defines% -I../include -I. %unit%-main.t.cpp %unit%.t.cpp && %unit%-main.t.exe
|
||||
endlocal & goto :EOF
|
||||
|
||||
:: subroutines:
|
||||
|
||||
:CompilerVersion version
|
||||
@echo off & setlocal enableextensions
|
||||
set tmpprogram=_getcompilerversion.tmp
|
||||
set tmpsource=%tmpprogram%.c
|
||||
|
||||
echo #include ^<stdio.h^> >%tmpsource%
|
||||
echo int main(){printf("%%d\n",_MSC_VER);} >>%tmpsource%
|
||||
|
||||
cl /nologo %tmpsource% >nul
|
||||
for /f %%x in ('%tmpprogram%') do set version=%%x
|
||||
del %tmpprogram%.* >nul
|
||||
set offset=0
|
||||
if %version% LSS 1900 set /a offset=1
|
||||
set /a version="version / 10 - 10 * ( 5 + offset )"
|
||||
endlocal & set %1=%version%& goto :EOF
|
||||
|
||||
:: toupper; makes use of the fact that string
|
||||
:: replacement (via SET) is not case sensitive
|
||||
:toupper
|
||||
for %%L IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO SET %1=!%1:%%L=%%L!
|
||||
goto :EOF
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
@setlocal
|
||||
@set std=%1
|
||||
@if not "%std%"=="" set std=-std:%std%
|
||||
clang-cl -m32 -W3 -EHsc %std% -Doptional_CONFIG_SELECT_OPTIONAL=optional_OPTIONAL_NONSTD -I../include -I. optional-main.t.cpp optional.t.cpp && optional-main.t.exe
|
||||
@endlocal
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
@echo off & setlocal enableextensions enabledelayedexpansion
|
||||
::
|
||||
:: tc.bat - compile & run tests (clang).
|
||||
::
|
||||
|
||||
set unit=optional
|
||||
|
||||
:: if no std is given, use c++14
|
||||
|
||||
set std=%1
|
||||
if "%std%"=="" set std=c++14
|
||||
|
||||
set clang=clang
|
||||
|
||||
call :CompilerVersion version
|
||||
echo %clang% %version%: %std%
|
||||
|
||||
set UCAP=%unit%
|
||||
call :toupper UCAP
|
||||
|
||||
set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_DEFAULT
|
||||
::set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_NONSTD
|
||||
::set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_STD
|
||||
|
||||
set unit_config=
|
||||
|
||||
rem -flto / -fwhole-program
|
||||
set optflags=-O2
|
||||
set warnflags=-Wall -Wextra -Wpedantic -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-missing-noreturn -Wno-documentation-unknown-command -Wno-documentation-deprecated-sync -Wno-documentation -Wno-weak-vtables -Wno-missing-prototypes -Wno-missing-variable-declarations -Wno-exit-time-destructors -Wno-global-constructors
|
||||
|
||||
"%clang%" -m32 -std=%std% %optflags% %warnflags% %unit_select% %unit_config% -fms-compatibility-version=19.00 -isystem "%VCInstallDir%include" -isystem "%WindowsSdkDir_71A%include" -I../include -I. -o %unit%-main.t.exe %unit%-main.t.cpp %unit%.t.cpp && %unit%-main.t.exe
|
||||
endlocal & goto :EOF
|
||||
|
||||
:: subroutines:
|
||||
|
||||
:CompilerVersion version
|
||||
echo off & setlocal enableextensions
|
||||
set tmpprogram=_getcompilerversion.tmp
|
||||
set tmpsource=%tmpprogram%.c
|
||||
|
||||
echo #include ^<stdio.h^> > %tmpsource%
|
||||
echo int main(){printf("%%d.%%d.%%d\n",__clang_major__,__clang_minor__,__clang_patchlevel__);} >> %tmpsource%
|
||||
|
||||
"%clang%" -m32 -o %tmpprogram% %tmpsource% >nul
|
||||
for /f %%x in ('%tmpprogram%') do set version=%%x
|
||||
del %tmpprogram%.* >nul
|
||||
endlocal & set %1=%version%& goto :EOF
|
||||
|
||||
:: toupper; makes use of the fact that string
|
||||
:: replacement (via SET) is not case sensitive
|
||||
:toupper
|
||||
for %%L IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO SET %1=!%1:%%L=%%L!
|
||||
goto :EOF
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
@for %%s in ( c++98 c++03 c++11 c++14 c++17 ) do (
|
||||
call tg.bat %%s
|
||||
)
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
@echo off & setlocal enableextensions enabledelayedexpansion
|
||||
::
|
||||
:: tg.bat - compile & run tests (GNUC).
|
||||
::
|
||||
|
||||
set unit=optional
|
||||
|
||||
:: if no std is given, use c++11
|
||||
|
||||
set std=%1
|
||||
set args=%2 %3 %4 %5 %6 %7 %8 %9
|
||||
if "%1" == "" set std=c++11
|
||||
|
||||
set gpp=g++
|
||||
|
||||
call :CompilerVersion version
|
||||
echo %gpp% %version%: %std% %args%
|
||||
|
||||
set UCAP=%unit%
|
||||
call :toupper UCAP
|
||||
|
||||
set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_DEFAULT
|
||||
::set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_NONSTD
|
||||
::set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_STD
|
||||
|
||||
set unit_config=
|
||||
|
||||
rem -flto / -fwhole-program
|
||||
set optflags=-O2
|
||||
set warnflags=-Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wno-padded -Wno-missing-noreturn
|
||||
|
||||
%gpp% -std=%std% %optflags% %warnflags% %unit_select% %unit_config% -o %unit%-main.t.exe -I../include -I. %unit%-main.t.cpp %unit%.t.cpp && %unit%-main.t.exe
|
||||
|
||||
endlocal & goto :EOF
|
||||
|
||||
:: subroutines:
|
||||
|
||||
:CompilerVersion version
|
||||
echo off & setlocal enableextensions
|
||||
set tmpprogram=_getcompilerversion.tmp
|
||||
set tmpsource=%tmpprogram%.c
|
||||
|
||||
echo #include ^<stdio.h^> > %tmpsource%
|
||||
echo int main(){printf("%%d.%%d.%%d\n",__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__);} >> %tmpsource%
|
||||
|
||||
%gpp% -o %tmpprogram% %tmpsource% >nul
|
||||
for /f %%x in ('%tmpprogram%') do set version=%%x
|
||||
del %tmpprogram%.* >nul
|
||||
endlocal & set %1=%version%& goto :EOF
|
||||
|
||||
:: toupper; makes use of the fact that string
|
||||
:: replacement (via SET) is not case sensitive
|
||||
:toupper
|
||||
for %%L IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO SET %1=!%1:%%L=%%L!
|
||||
goto :EOF
|
||||
Reference in New Issue
Block a user