mirror of
https://github.com/fmtlib/fmt.git
synced 2025-02-28 06:39:50 +00:00
Move the code from appveyor config to a Python script
No more PowerShell rubbish, yay!
This commit is contained in:
parent
86fee707fb
commit
c110f7b8d3
31
appveyor.yml
31
appveyor.yml
@ -10,37 +10,8 @@ environment:
|
|||||||
- BUILD: mingw
|
- BUILD: mingw
|
||||||
CONFIG: Release
|
CONFIG: Release
|
||||||
|
|
||||||
install:
|
|
||||||
- ps: |
|
|
||||||
if ($env:BUILD -eq "mingw") {
|
|
||||||
# Install MinGW.
|
|
||||||
$url = "http://sourceforge.net/projects/mingw-w64/files/"
|
|
||||||
$url += "Toolchains%20targetting%20Win64/Personal%20BUILDs/"
|
|
||||||
$url += "mingw-builds/4.9.2/threads-win32/seh/"
|
|
||||||
$url += "x86_64-4.9.2-release-win32-seh-rt_v3-rev1.7z/download"
|
|
||||||
Invoke-WebRequest -UserAgent wget -Uri $url -OutFile mingw.7z
|
|
||||||
&7z x -oC:\ mingw.7z > $null
|
|
||||||
}
|
|
||||||
- set PATH=C:\Program Files (x86)\MSBUILD\12.0\bin\;%PATH%;C:\mingw64\bin
|
|
||||||
|
|
||||||
before_build:
|
|
||||||
- python support/build.py
|
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- ps: |
|
- python support/build.py
|
||||||
if ($env:BUILD -eq "mingw") {
|
|
||||||
mingw32-make -j4
|
|
||||||
} else {
|
|
||||||
msbuild /m:4 /p:Config=$env:CONFIG FORMAT.sln
|
|
||||||
}
|
|
||||||
|
|
||||||
test_script:
|
|
||||||
- ps: |
|
|
||||||
if ($env:BUILD -eq "mingw") {
|
|
||||||
mingw32-make test
|
|
||||||
} else {
|
|
||||||
msbuild RUN_TESTS.vcxproj
|
|
||||||
}
|
|
||||||
|
|
||||||
on_failure:
|
on_failure:
|
||||||
- appveyor PushArtifact Testing/Temporary/LastTest.log
|
- appveyor PushArtifact Testing/Temporary/LastTest.log
|
||||||
|
@ -1,14 +1,30 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# Build the project on AppVeyor.
|
# Build the project on AppVeyor.
|
||||||
|
|
||||||
from subprocess import check_call
|
|
||||||
import os
|
import os
|
||||||
|
from download import Downloader
|
||||||
|
from subprocess import check_call
|
||||||
|
|
||||||
env = os.environ
|
build = os.environ['BUILD']
|
||||||
build = env['BUILD']
|
cmake_command = ['cmake', '-DFMT_EXTRA_TESTS=ON', '-DCMAKE_BUILD_TYPE=' + os.environ['CONFIG']]
|
||||||
cmake_command = ['cmake', '-DFMT_EXTRA_TESTS=ON', '-DCMAKE_BUILD_TYPE=' + env['CONFIG']]
|
build_command = ['msbuild', '/m:4', '/p:Config=' + os.environ['CONFIG'], 'FORMAT.sln']
|
||||||
|
test_command = ['msbuild', 'RUN_TESTS.vcxproj']
|
||||||
if build == 'mingw':
|
if build == 'mingw':
|
||||||
|
# Install MinGW.
|
||||||
|
mingw_url = 'http://sourceforge.net/projects/mingw-w64/files/' + \
|
||||||
|
'Toolchains%20targetting%20Win64/Personal%20Builds/' + \
|
||||||
|
'mingw-builds/4.9.2/threads-win32/seh/' + \
|
||||||
|
'x86_64-4.9.2-release-win32-seh-rt_v3-rev1.7z/download'
|
||||||
|
with Downloader().download(mingw_url) as f:
|
||||||
|
check_call(['7z', 'x', '-oC:\\', f])
|
||||||
|
|
||||||
# Remove path to Git bin directory from $PATH because it breaks MinGW config.
|
# Remove path to Git bin directory from $PATH because it breaks MinGW config.
|
||||||
env['PATH'] = env['PATH'].replace(r'C:\Program Files (x86)\Git\bin', '')
|
path = os.environ['PATH'].replace(r'C:\Program Files (x86)\Git\bin', '')
|
||||||
|
|
||||||
|
os.environ['PATH'] = r'C:\Program Files (x86)\MSBUILD\12.0\bin\;' + path + r';C:\mingw64\bin'
|
||||||
cmake_command.append('-GMinGW Makefiles')
|
cmake_command.append('-GMinGW Makefiles')
|
||||||
check_call(cmake_command, env=env)
|
build_command = ['mingw32-make', '-j4']
|
||||||
|
test_command = ['mingw32-make', 'test']
|
||||||
|
|
||||||
|
check_call(cmake_command)
|
||||||
|
check_call(build_command)
|
||||||
|
46
support/download.py
Normal file
46
support/download.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# A file downloader.
|
||||||
|
|
||||||
|
import contextlib, os, tempfile, timer, urllib2, urlparse
|
||||||
|
|
||||||
|
class Downloader:
|
||||||
|
def __init__(self, dir=None):
|
||||||
|
self.dir = dir
|
||||||
|
|
||||||
|
# Downloads a file and removes it when exiting a block.
|
||||||
|
# Usage:
|
||||||
|
# d = Downloader()
|
||||||
|
# with d.download(url) as f:
|
||||||
|
# use_file(f)
|
||||||
|
def download(self, url, cookie=None):
|
||||||
|
suffix = os.path.splitext(urlparse.urlsplit(url)[2])[1]
|
||||||
|
fd, filename = tempfile.mkstemp(suffix=suffix, dir=self.dir)
|
||||||
|
os.close(fd)
|
||||||
|
with timer.print_time('Downloading', url, 'to', filename):
|
||||||
|
opener = urllib2.build_opener()
|
||||||
|
if cookie:
|
||||||
|
opener.addheaders.append(('Cookie', cookie))
|
||||||
|
num_tries = 2
|
||||||
|
for i in range(num_tries):
|
||||||
|
try:
|
||||||
|
f = opener.open(url)
|
||||||
|
except urllib2.URLError, e:
|
||||||
|
print('Failed to open url', url)
|
||||||
|
continue
|
||||||
|
length = f.headers.get('content-length')
|
||||||
|
if not length:
|
||||||
|
print('Failed to get content-length')
|
||||||
|
continue
|
||||||
|
length = int(length)
|
||||||
|
with open(filename, 'wb') as out:
|
||||||
|
count = 0
|
||||||
|
while count < length:
|
||||||
|
data = f.read(1024 * 1024)
|
||||||
|
count += len(data)
|
||||||
|
out.write(data)
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def remove(filename):
|
||||||
|
try:
|
||||||
|
yield filename
|
||||||
|
finally:
|
||||||
|
pass #os.remove(filename)
|
||||||
|
return remove(filename)
|
35
support/timer.py
Normal file
35
support/timer.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# A with statement based timer.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
from contextlib import contextmanager
|
||||||
|
import timeit
|
||||||
|
|
||||||
|
class Timer:
|
||||||
|
"""
|
||||||
|
A with statement based timer.
|
||||||
|
Usage:
|
||||||
|
t = Timer()
|
||||||
|
with t:
|
||||||
|
do_something()
|
||||||
|
time = t.time
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
self.start = timeit.default_timer()
|
||||||
|
|
||||||
|
def __exit__(self, type, value, traceback):
|
||||||
|
finish = timeit.default_timer()
|
||||||
|
self.time = finish - self.start
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def print_time(*args):
|
||||||
|
"""
|
||||||
|
Measures and prints the time taken to execute nested code.
|
||||||
|
args: Additional arguments to print.
|
||||||
|
"""
|
||||||
|
t = Timer()
|
||||||
|
print(*args)
|
||||||
|
with t:
|
||||||
|
yield
|
||||||
|
print(*args, end=' ')
|
||||||
|
print('finished in {0:.2f} second(s)'.format(t.time))
|
Loading…
x
Reference in New Issue
Block a user