]>
git.proxmox.com Git - ceph.git/blob - ceph/src/fmt/support/travis-build.py
2 # Build the project on Travis CI.
4 from __future__
import print_function
5 import errno
, os
, shutil
, subprocess
, sys
, urllib
6 from subprocess
import call
, check_call
, Popen
, PIPE
, STDOUT
8 def rmtree_if_exists(dir):
12 if e
.errno
== errno
.ENOENT
:
15 def makedirs_if_not_exist(dir):
19 if e
.errno
!= errno
.EEXIST
:
22 def install_dependencies():
23 branch
= os
.environ
['TRAVIS_BRANCH']
24 if branch
!= 'master':
25 print('Branch: ' + branch
)
26 exit(0) # Ignore non-master branches
27 check_call('curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key ' +
28 '| sudo apt-key add -', shell
=True)
29 check_call('echo "deb https://deb.nodesource.com/node_0.10 precise main" ' +
30 '| sudo tee /etc/apt/sources.list.d/nodesource.list', shell
=True)
31 check_call(['sudo', 'apt-get', 'update'])
32 check_call(['sudo', 'apt-get', 'install', 'python-virtualenv', 'nodejs'])
33 check_call(['sudo', 'npm', 'install', '-g', 'less@2.6.1', 'less-plugin-clean-css'])
34 deb_file
= 'doxygen_1.8.6-2_amd64.deb'
35 urllib
.urlretrieve('http://mirrors.kernel.org/ubuntu/pool/main/d/doxygen/' +
37 check_call(['sudo', 'dpkg', '-i', deb_file
])
39 fmt_dir
= os
.path
.dirname(os
.path
.dirname(os
.path
.realpath(__file__
)))
41 build
= os
.environ
['BUILD']
43 travis
= 'TRAVIS' in os
.environ
45 install_dependencies()
46 sys
.path
.insert(0, os
.path
.join(fmt_dir
, 'doc'))
48 build
.create_build_env()
49 html_dir
= build
.build_docs()
50 repo
= 'fmtlib.github.io'
51 if travis
and 'KEY' not in os
.environ
:
52 # Don't update the repo if building on Travis from an account that
53 # doesn't have push access.
54 print('Skipping update of ' + repo
)
56 # Clone the fmtlib.github.io repo.
57 rmtree_if_exists(repo
)
58 git_url
= 'https://github.com/' if travis
else 'git@github.com:'
59 check_call(['git', 'clone', git_url
+ 'fmtlib/{}.git'.format(repo
)])
60 # Copy docs to the repo.
61 target_dir
= os
.path
.join(repo
, 'dev')
62 rmtree_if_exists(target_dir
)
63 shutil
.copytree(html_dir
, target_dir
, ignore
=shutil
.ignore_patterns('.*'))
65 check_call(['git', 'config', '--global', 'user.name', 'amplbot'])
66 check_call(['git', 'config', '--global', 'user.email', 'viz@ampl.com'])
67 # Push docs to GitHub pages.
68 check_call(['git', 'add', '--all'], cwd
=repo
)
69 if call(['git', 'diff-index', '--quiet', 'HEAD'], cwd
=repo
):
70 check_call(['git', 'commit', '-m', 'Update documentation'], cwd
=repo
)
73 cmd
+= ' https://$KEY@github.com/fmtlib/fmtlib.github.io.git master'
74 p
= Popen(cmd
, shell
=True, stdout
=PIPE
, stderr
=STDOUT
, cwd
=repo
)
75 # Print the output without the key.
76 print(p
.communicate()[0].replace(os
.environ
['KEY'], '$KEY'))
78 raise subprocess
.CalledProcessError(p
.returncode
, cmd
)
81 standard
= os
.environ
['STANDARD']
82 install_dir
= os
.path
.join(fmt_dir
, "_install")
83 build_dir
= os
.path
.join(fmt_dir
, "_build")
84 test_build_dir
= os
.path
.join(fmt_dir
, "_build_test")
86 # Configure the library.
87 makedirs_if_not_exist(build_dir
)
89 '-DCMAKE_INSTALL_PREFIX=' + install_dir
, '-DCMAKE_BUILD_TYPE=' + build
,
90 '-DCMAKE_CXX_STANDARD=' + standard
93 # Make sure the fuzzers still compile.
94 main_cmake_flags
= list(cmake_flags
)
95 if 'ENABLE_FUZZING' in os
.environ
:
96 main_cmake_flags
+= ['-DFMT_FUZZ=ON', '-DFMT_FUZZ_LINKMAIN=On']
98 check_call(['cmake', '-DFMT_DOC=OFF', '-DFMT_PEDANTIC=ON', '-DFMT_WERROR=ON', fmt_dir
] +
99 main_cmake_flags
, cwd
=build_dir
)
102 check_call(['cmake', '--build','.'], cwd
=build_dir
)
105 env
= os
.environ
.copy()
106 env
['CTEST_OUTPUT_ON_FAILURE'] = '1'
107 if call(['make', 'test'], env
=env
, cwd
=build_dir
):
108 with
open(os
.path
.join(build_dir
, 'Testing', 'Temporary', 'LastTest.log'), 'r') as f
:
112 # Install the library.
113 check_call(['make', 'install'], cwd
=build_dir
)
116 makedirs_if_not_exist(test_build_dir
)
117 check_call(['cmake', os
.path
.join(fmt_dir
, "test", "find-package-test")] +
118 cmake_flags
, cwd
=test_build_dir
)
119 check_call(['make', '-j4'], cwd
=test_build_dir
)