xref: /netbsd-src/external/bsd/jemalloc.old/dist/scripts/gen_travis.py (revision 8e33eff89e26cf71871ead62f0d5063e1313c33a)
1*8e33eff8Schristos#!/usr/bin/env python
2*8e33eff8Schristos
3*8e33eff8Schristosfrom itertools import combinations
4*8e33eff8Schristos
5*8e33eff8Schristostravis_template = """\
6*8e33eff8Schristoslanguage: generic
7*8e33eff8Schristos
8*8e33eff8Schristosmatrix:
9*8e33eff8Schristos  include:
10*8e33eff8Schristos%s
11*8e33eff8Schristos
12*8e33eff8Schristosbefore_script:
13*8e33eff8Schristos  - autoconf
14*8e33eff8Schristos  - ./configure ${COMPILER_FLAGS:+ \
15*8e33eff8Schristos      CC="$CC $COMPILER_FLAGS" \
16*8e33eff8Schristos      CXX="$CXX $COMPILER_FLAGS" } \
17*8e33eff8Schristos      $CONFIGURE_FLAGS
18*8e33eff8Schristos  - make -j3
19*8e33eff8Schristos  - make -j3 tests
20*8e33eff8Schristos
21*8e33eff8Schristosscript:
22*8e33eff8Schristos  - make check
23*8e33eff8Schristos"""
24*8e33eff8Schristos
25*8e33eff8Schristos# The 'default' configuration is gcc, on linux, with no compiler or configure
26*8e33eff8Schristos# flags.  We also test with clang, -m32, --enable-debug, --enable-prof,
27*8e33eff8Schristos# --disable-stats, and --with-malloc-conf=tcache:false.  To avoid abusing
28*8e33eff8Schristos# travis though, we don't test all 2**7 = 128 possible combinations of these;
29*8e33eff8Schristos# instead, we only test combinations of up to 2 'unusual' settings, under the
30*8e33eff8Schristos# hope that bugs involving interactions of such settings are rare.
31*8e33eff8Schristos# Things at once, for C(7, 0) + C(7, 1) + C(7, 2) = 29
32*8e33eff8SchristosMAX_UNUSUAL_OPTIONS = 2
33*8e33eff8Schristos
34*8e33eff8Schristosos_default = 'linux'
35*8e33eff8Schristosos_unusual = 'osx'
36*8e33eff8Schristos
37*8e33eff8Schristoscompilers_default = 'CC=gcc CXX=g++'
38*8e33eff8Schristoscompilers_unusual = 'CC=clang CXX=clang++'
39*8e33eff8Schristos
40*8e33eff8Schristoscompiler_flag_unusuals = ['-m32']
41*8e33eff8Schristos
42*8e33eff8Schristosconfigure_flag_unusuals = [
43*8e33eff8Schristos    '--enable-debug',
44*8e33eff8Schristos    '--enable-prof',
45*8e33eff8Schristos    '--disable-stats',
46*8e33eff8Schristos]
47*8e33eff8Schristos
48*8e33eff8Schristosmalloc_conf_unusuals = [
49*8e33eff8Schristos    'tcache:false',
50*8e33eff8Schristos    'dss:primary',
51*8e33eff8Schristos    'percpu_arena:percpu',
52*8e33eff8Schristos    'background_thread:true',
53*8e33eff8Schristos]
54*8e33eff8Schristos
55*8e33eff8Schristosall_unusuals = (
56*8e33eff8Schristos    [os_unusual] + [compilers_unusual] + compiler_flag_unusuals
57*8e33eff8Schristos    + configure_flag_unusuals + malloc_conf_unusuals
58*8e33eff8Schristos)
59*8e33eff8Schristos
60*8e33eff8Schristosunusual_combinations_to_test = []
61*8e33eff8Schristosfor i in xrange(MAX_UNUSUAL_OPTIONS + 1):
62*8e33eff8Schristos    unusual_combinations_to_test += combinations(all_unusuals, i)
63*8e33eff8Schristos
64*8e33eff8Schristosinclude_rows = ""
65*8e33eff8Schristosfor unusual_combination in unusual_combinations_to_test:
66*8e33eff8Schristos    os = os_default
67*8e33eff8Schristos    if os_unusual in unusual_combination:
68*8e33eff8Schristos        os = os_unusual
69*8e33eff8Schristos
70*8e33eff8Schristos    compilers = compilers_default
71*8e33eff8Schristos    if compilers_unusual in unusual_combination:
72*8e33eff8Schristos        compilers = compilers_unusual
73*8e33eff8Schristos
74*8e33eff8Schristos    compiler_flags = [
75*8e33eff8Schristos        x for x in unusual_combination if x in compiler_flag_unusuals]
76*8e33eff8Schristos
77*8e33eff8Schristos    configure_flags = [
78*8e33eff8Schristos        x for x in unusual_combination if x in configure_flag_unusuals]
79*8e33eff8Schristos
80*8e33eff8Schristos    malloc_conf = [
81*8e33eff8Schristos        x for x in unusual_combination if x in malloc_conf_unusuals]
82*8e33eff8Schristos    # Filter out unsupported configurations on OS X.
83*8e33eff8Schristos    if os == 'osx' and ('dss:primary' in malloc_conf or \
84*8e33eff8Schristos      'percpu_arena:percpu' in malloc_conf or 'background_thread:true' \
85*8e33eff8Schristos      in malloc_conf):
86*8e33eff8Schristos        continue
87*8e33eff8Schristos    if len(malloc_conf) > 0:
88*8e33eff8Schristos        configure_flags.append('--with-malloc-conf=' + ",".join(malloc_conf))
89*8e33eff8Schristos
90*8e33eff8Schristos    # Filter out an unsupported configuration - heap profiling on OS X.
91*8e33eff8Schristos    if os == 'osx' and '--enable-prof' in configure_flags:
92*8e33eff8Schristos        continue
93*8e33eff8Schristos
94*8e33eff8Schristos    # We get some spurious errors when -Warray-bounds is enabled.
95*8e33eff8Schristos    env_string = ('{} COMPILER_FLAGS="{}" CONFIGURE_FLAGS="{}" '
96*8e33eff8Schristos	'EXTRA_CFLAGS="-Werror -Wno-array-bounds"').format(
97*8e33eff8Schristos        compilers, " ".join(compiler_flags), " ".join(configure_flags))
98*8e33eff8Schristos
99*8e33eff8Schristos    include_rows += '    - os: %s\n' % os
100*8e33eff8Schristos    include_rows += '      env: %s\n' % env_string
101*8e33eff8Schristos    if '-m32' in unusual_combination and os == 'linux':
102*8e33eff8Schristos        include_rows += '      addons:\n'
103*8e33eff8Schristos	include_rows += '        apt:\n'
104*8e33eff8Schristos	include_rows += '          packages:\n'
105*8e33eff8Schristos	include_rows += '            - gcc-multilib\n'
106*8e33eff8Schristos
107*8e33eff8Schristosprint travis_template % include_rows
108