xref: /minix3/sys/external/bsd/compiler_rt/dist/test/profile/lit.cfg (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc# -*- Python -*-
2*0a6a1f1dSLionel Sambuc
3*0a6a1f1dSLionel Sambucimport os
4*0a6a1f1dSLionel Sambuc
5*0a6a1f1dSLionel Sambuc# Setup config name.
6*0a6a1f1dSLionel Sambucconfig.name = 'Profile'
7*0a6a1f1dSLionel Sambuc
8*0a6a1f1dSLionel Sambuc# Setup source root.
9*0a6a1f1dSLionel Sambucconfig.test_source_root = os.path.dirname(__file__)
10*0a6a1f1dSLionel Sambuc
11*0a6a1f1dSLionel Sambuc# Setup executable root.
12*0a6a1f1dSLionel Sambucif hasattr(config, 'profile_lit_binary_dir') and \
13*0a6a1f1dSLionel Sambuc        config.profile_lit_binary_dir is not None:
14*0a6a1f1dSLionel Sambuc    config.test_exec_root = config.profile_lit_binary_dir
15*0a6a1f1dSLionel Sambuc
16*0a6a1f1dSLionel Sambuc# If the above check didn't work, we're probably in the source tree.  Use some
17*0a6a1f1dSLionel Sambuc# magic to re-execute from the build tree.
18*0a6a1f1dSLionel Sambucif config.test_exec_root is None:
19*0a6a1f1dSLionel Sambuc    # The magic relies on knowing compilerrt_site_basedir.
20*0a6a1f1dSLionel Sambuc    compilerrt_basedir = lit_config.params.get('compilerrt_site_basedir', None)
21*0a6a1f1dSLionel Sambuc    if compilerrt_basedir:
22*0a6a1f1dSLionel Sambuc        site_cfg = os.path.join(compilerrt_basedir, 'profile', 'lit.site.cfg')
23*0a6a1f1dSLionel Sambuc        if os.path.exists(site_cfg):
24*0a6a1f1dSLionel Sambuc            lit_config.load_config(config, site_cfg)
25*0a6a1f1dSLionel Sambuc            raise SystemExit
26*0a6a1f1dSLionel Sambuc
27*0a6a1f1dSLionel Sambuc# Test suffixes.
28*0a6a1f1dSLionel Sambucconfig.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test']
29*0a6a1f1dSLionel Sambuc
30*0a6a1f1dSLionel Sambuc# What to exclude.
31*0a6a1f1dSLionel Sambucconfig.excludes = ['Inputs']
32*0a6a1f1dSLionel Sambuc
33*0a6a1f1dSLionel Sambuc# Clang flags.
34*0a6a1f1dSLionel Sambucclang_cflags = [config.target_cflags]
35*0a6a1f1dSLionel Sambuc
36*0a6a1f1dSLionel Sambucdef build_invocation(compile_flags):
37*0a6a1f1dSLionel Sambuc  return " " + " ".join([config.clang] + compile_flags) + " "
38*0a6a1f1dSLionel Sambuc
39*0a6a1f1dSLionel Sambuc# Add clang substitutions.
40*0a6a1f1dSLionel Sambucconfig.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
41*0a6a1f1dSLionel Sambucconfig.substitutions.append( ("%clang_profgen ", build_invocation(clang_cflags) + " -fprofile-instr-generate ") )
42*0a6a1f1dSLionel Sambucconfig.substitutions.append( ("%clang_profuse=", build_invocation(clang_cflags) + " -fprofile-instr-use=") )
43*0a6a1f1dSLionel Sambuc
44*0a6a1f1dSLionel Sambuc# Profile tests are currently supported on Linux and Darwin only.
45*0a6a1f1dSLionel Sambucif config.host_os not in ['Linux', 'Darwin']:
46*0a6a1f1dSLionel Sambuc  config.unsupported = True
47