From ed839c4a9b583e80b66e10ca4bd10202be86eb90 Mon Sep 17 00:00:00 2001 From: Elias Kosunen Date: Tue, 15 May 2018 10:21:08 +0300 Subject: [PATCH] Reintroduce appveyor-build.py --- .travis.yml | 24 +++++++++++----- include/fmt/ostream.h | 8 ++++++ include/fmt/printf.h | 9 ++++++ support/appveyor-build.py | 47 ++++++++++++++++++++++++++++++++ support/appveyor-test-upload.ps1 | 11 ++++++++ support/appveyor.yml | 41 ++++++---------------------- 6 files changed, 101 insertions(+), 39 deletions(-) create mode 100644 support/appveyor-build.py create mode 100644 support/appveyor-test-upload.ps1 diff --git a/.travis.yml b/.travis.yml index 3d01de23..85dd3d7e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,13 +7,6 @@ os: linux git: depth: 1 -addons: - apt: - update: true - sources: &apt_sources - - ubuntu-toolchain-r-test - packages: - - g++-6 env: global: @@ -30,8 +23,22 @@ matrix: # g++ 6 on Linux with C++14 - env: CXX_COMPILER=g++-6 BUILD=Debug STANDARD=14 compiler: gcc + addons: + apt: + update: true + sources: + - ubuntu-toolchain-r-test + packages: + - g++-6 - env: CXX_COMPILER=g++-6 BUILD=Release STANDARD=14 compiler: gcc + addons: + apt: + update: true + sources: + - ubuntu-toolchain-r-test + packages: + - g++-6 # Apple clang on OS X with C++14 - env: BUILD=Debug STANDARD=14 compiler: clang @@ -79,6 +86,9 @@ matrix: # Android - language: android android: + addons: + apt: + update: true components: - tools - platform-tools diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index fdbe1698..a836d16c 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -140,13 +140,21 @@ inline void vprint(std::basic_ostream &os, template inline void print(std::ostream &os, string_view format_str, const Args & ... args) { +#if FMT_GCC_VERSION && FMT_GCC_VERSION <= 440 + vprint(os, format_str, make_format_args(args...)); +#else vprint(os, format_str, make_format_args(args...)); +#endif } template inline void print(std::wostream &os, wstring_view format_str, const Args & ... args) { +#if FMT_GCC_VERSION && FMT_GCC_VERSION <= 440 + vprint(os, format_str, make_format_args(args...)); +#else vprint(os, format_str, make_format_args(args...)); +#endif } FMT_END_NAMESPACE diff --git a/include/fmt/printf.h b/include/fmt/printf.h index bf4a293b..29aef503 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -625,14 +625,23 @@ template inline int fprintf(std::FILE *f, string_view format_str, const Args & ... args) { auto vargs = make_format_args< typename printf_context::type>(args...); +#if FMT_GCC_VERSION && FMT_GCC_VERSION <= 440 + return vfprintf(f, format_str, vargs); +#else return vfprintf(f, format_str, vargs); +#endif } template inline int fprintf(std::FILE *f, wstring_view format_str, const Args & ... args) { +#if FMT_GCC_VERSION && FMT_GCC_VERSION <= 440 + return vfprintf(f, format_str, + make_format_args::type>(args...)); +#else return vfprintf(f, format_str, make_format_args::type>(args...)); +#endif } inline int vprintf(string_view format, printf_args args) { diff --git a/support/appveyor-build.py b/support/appveyor-build.py new file mode 100644 index 00000000..d7b61562 --- /dev/null +++ b/support/appveyor-build.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# Build the project on AppVeyor. + +import os +from subprocess import check_call + +build = os.environ['BUILD'] +config = os.environ['CONFIGURATION'] +platform = os.environ['PLATFORM'] +path = os.environ['PATH'] +image = os.environ['APPVEYOR_BUILD_WORKER_IMAGE'] +jobid = os.environ['APPVEYOR_JOB_ID'] +cmake_command = ['cmake', '-DFMT_PEDANTIC=ON', '-DCMAKE_BUILD_TYPE=' + config, '..'] +if build == 'mingw': + cmake_command.append('-GMinGW Makefiles') + build_command = ['mingw32-make', '-j4'] + test_command = ['mingw32-make', 'test'] + # Remove the path to Git bin directory from $PATH because it breaks + # MinGW config. + path = path.replace(r'C:\Program Files (x86)\Git\bin', '') + os.environ['PATH'] = r'C:\MinGW\bin;' + path +else: + # Add MSBuild 14.0 to PATH as described in + # http://help.appveyor.com/discussions/problems/2229-v140-not-found-on-vs2105rc. + os.environ['PATH'] = r'C:\Program Files (x86)\MSBuild\15.0\Bin;' + path + if image == 'Visual Studio 2013': + generator = 'Visual Studio 12 2013' + elif image == 'Visual Studio 2015': + generator = 'Visual Studio 14 2015' + elif image == 'Visual Studio 2017': + generator = 'Visual Studio 15 2017' + if platform == 'x64': + generator += ' Win64' + cmake_command.append('-G' + generator) + # build_command = ['msbuild', r'C:\projects\fmt\build\fmt.sln', '/m:4', + # r'/logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"'] + build_command = ['cmake', '--build', '.', '--config', config, '--', '/m:4'] + test_command = ['ctest', '-C', config, '-T', 'Test'] + with open('DartConfiguration.tcl', 'w+') as file: + pass + +check_call(cmake_command) +check_call(build_command) +check_call(test_command) + +# Upload test results +# check_call([r'../support/appveyor-test-upload.ps1', '-configuration', config, '-jobid', jobid]) diff --git a/support/appveyor-test-upload.ps1 b/support/appveyor-test-upload.ps1 new file mode 100644 index 00000000..0a2eb7af --- /dev/null +++ b/support/appveyor-test-upload.ps1 @@ -0,0 +1,11 @@ +param ( + [Parameter(Mandatory=$true)][string]$configuration, + [Parameter(Mandatory=$true)][string]$jobid +) + +$XSLInputElement = New-Object System.Xml.Xsl.XslCompiledTransform +$XslInputElement.Load("https://raw.githubusercontent.com/rpavlik/jenkins-ctest-plugin/master/ctest-to-junit.xsl") +$file = $(ls Testing\*\Test.xml) | Select -first 1 +$XSLInputElement.Transform((Resolve-Path $file), (Join-Path (Resolve-Path .) "ctest-to-junit-results.xml")) +$wc = New-Object 'System.Net.WebClient' +$wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$jobid", (Resolve-Path .\ctest-to-junit-results.xml)) diff --git a/support/appveyor.yml b/support/appveyor.yml index ede92196..a2830588 100644 --- a/support/appveyor.yml +++ b/support/appveyor.yml @@ -8,49 +8,26 @@ platform: - Win32 - x64 +image: + - Visual Studio 2013 + - Visual Studio 2015 + - Visual Studio 2017 + environment: CTEST_OUTPUT_ON_FAILURE: 1 MSVC_DEFAULT_OPTIONS: ON - matrix: - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - CMAKE_GENERATOR: Visual Studio 12 2013 - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - CMAKE_GENERATOR: Visual Studio 14 2015 - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - CMAKE_GENERATOR: Visual Studio 15 2017 + BUILD: msvc matrix: allow_failures: - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - CMAKE_GENERATOR: Visual Studio 12 2013 - -init: - - ps: | - If ($env:Platform -Match "x64") { - $env:CMAKE_GENERATOR_SUFFIX=" Win64" - } + - image: Visual Studio 2013 before_build: - mkdir build - cd build - - - ps: cmake -G "$($env:CMAKE_GENERATOR)$($env:CMAKE_GENERATOR_SUFFIX)" -DFMT_WERROR=OFF -DFMT_PEDANTIC=ON -DCMAKE_BUILD_TYPE="$($env:configuration)" .. -build: - project: C:\projects\fmt\build\fmt.sln - parallel: true - verbosity: normal - -test_script: - - ps: | - New-Item .\DartConfiguration.tcl -ItemType file - ctest -C "$($env:configuration)" -T Test - $XSLInputElement = New-Object System.Xml.Xsl.XslCompiledTransform - $XslInputElement.Load("https://raw.githubusercontent.com/rpavlik/jenkins-ctest-plugin/master/ctest-to-junit.xsl") - $file = $(ls Testing\*\Test.xml) | Select -first 1 - $XSLInputElement.Transform((Resolve-Path $file), (Join-Path (Resolve-Path .) "ctest-to-junit-results.xml")) - $wc = New-Object 'System.Net.WebClient' - $wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\ctest-to-junit-results.xml)) +build_script: + - python ../support/appveyor-build.py on_failure: - appveyor PushArtifact Testing/Temporary/LastTest.log