1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
#!/usr/bin/python
import sys,os,glob
files_in_order = [
(0, "myth_malloc"),
(0, "myth_free"),
(0, "myth_calloc"),
(0, "myth_posix_memalign"),
(0, "myth_valloc"),
(0, "myth_memalign"),
(1, "myth_aligned_alloc"),
(0, "myth_pvalloc"),
(0, "myth_realloc"),
(0, "myth_create_0"),
(0, "myth_create_1"),
(0, "myth_create_2"),
(0, "myth_create_join_many"),
(0, "myth_yield_0"),
(0, "myth_yield_1"),
(0, "myth_yield_2"),
(0, "myth_sleep_queue"),
(0, "myth_lock"),
(0, "myth_trylock"),
(0, "myth_mixlock"),
(0, "myth_cond_signal"),
(0, "myth_cond_broadcast_0"),
(0, "myth_cond_broadcast_1"),
(0, "myth_barrier"),
(0, "myth_join_counter"),
(0, "myth_felock"),
(0, "myth_uncond_signal"),
(0, "myth_uncond_bounded_buf"),
(0, "myth_dag_1d"),
(0, "myth_dag_2d"),
(0, "myth_dag_random"),
(0, "myth_key_create"),
(0, "myth_key_getspecific"),
(0, "myth_key_destructor"),
(0, "myth_globalattr_set_n_workers"),
(0, "measure_create"),
(0, "measure_latency"),
(0, "measure_wakeup_latency"),
(0, "measure_malloc"),
(0, "measure_thread_specific"),
(0, "pth_barrier"),
(0, "pth_cond_broadcast_0"),
(0, "pth_cond_broadcast_1"),
(0, "pth_cond_signal"),
(0, "pth_create_0"),
(0, "pth_create_1"),
(0, "pth_create_2"),
(0, "pth_lock"),
(0, "pth_mixlock"),
(0, "pth_mutex_initializer"),
(0, "pth_trylock"),
(0, "pth_yield"),
]
def file_order(f):
for i,(c,x) in enumerate(files_in_order):
if x in f:
return i
return len(files_in_order)
def build_condition(f):
for i,(c,x) in enumerate(files_in_order):
if x in f:
if c:
return "BUILD_TEST_%s" % x.upper()
else:
return None
return None
def file_prefix(f):
dot_pos = f.rindex(".")
return f[:dot_pos]
def get_files(lib):
C = sorted([ f for f in glob.glob("*.c") ], key=file_order)
CC = sorted([ f for f in glob.glob("*.cc") ], key=file_order)
C_CC = C + CC
if lib == "myth":
return [ f for f in C_CC if not f.startswith("pth_") ]
else:
return C_CC
# wp = open("hoge.am", "wb")
wp = sys.stdout
wr = wp.write
wr("""
# this Makefile.am is generated automatically by gen_makefile_am.py
# when you like to add a new test, run:
# python gen_makefile_am.py > Makefile.am
# cd ..
# autoreconf
""")
wr("""
common_cflags = -I$(abs_top_srcdir)/include
common_cxxflags = $(common_cflags)
myth_ldadd = $(abs_top_srcdir)/src/libmyth.la
myth_ld_ldadd = $(abs_top_srcdir)/src/libmyth-ld.la
myth_dl_ldadd = $(abs_top_srcdir)/src/libmyth-dl.la -ldl
myth_ldflags =
myth_ld_ldflags = @myth-ld.opts
myth_dl_ldflags =
""")
wr("""
check_PROGRAMS =
""")
def add_check_programs(lib):
assert lib.startswith("myth"), lib
suffix = lib[4:] #
wr("\n")
if suffix != "":
wr("if BUILD_MYTH%s\n" % suffix.upper())
for f in get_files(lib):
cond = build_condition(f)
base = file_prefix(f)
base_suffix = "%s%s" % (base, suffix)
if cond: wr("if %s\n" % cond)
wr("check_PROGRAMS += %s\n" % base_suffix)
if cond: wr("endif\n")
if suffix != "":
wr("endif\n")
def add_flags(lib):
assert lib.startswith("myth"), lib
suffix = lib[4:] #
wr("\n")
if suffix != "":
wr("if BUILD_MYTH%s\n" % suffix.upper())
for f in get_files(lib):
cond = build_condition(f)
base = file_prefix(f)
base_suffix = "%s%s" % (base, suffix)
if f.endswith(".c"):
lang = "c"
elif f.endswith(".cc"):
lang = "cxx"
else:
assert 0, f
if cond: wr("if %s\n" % cond)
wr("""%s_SOURCES = %s
%s_%sFLAGS = $(common_%sflags)
%s_LDADD = $(%s_ldadd)
%s_LDFLAGS = $(%s_ldflags)
"""
% (base_suffix, f,
base_suffix, lang.upper(), lang,
base_suffix, lib,
base_suffix, lib))
if cond: wr("endif\n")
if suffix != "":
wr("endif\n")
for lib in [ "myth", "myth_ld", "myth_dl" ]:
add_check_programs(lib)
for lib in [ "myth", "myth_ld", "myth_dl" ]:
add_flags(lib)
wr("""
TESTS = $(check_PROGRAMS)
build: $(check_PROGRAMS)
""")
if wp != sys.stdout:
wp.close()
|