File: lit.local.cfg

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (66 lines) | stat: -rw-r--r-- 4,368 bytes parent folder | download
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
# Make a local copy of the substitutions.
config.substitutions = list(config.substitutions)

def get_target_os():
    import re
    (run_cpu, run_vendor, run_os, run_version) = re.match('([^-]+)-([^-]+)-([^0-9]+)(.*)', config.variant_triple).groups()
    return run_os

clang_compile_opt = '-I' + config.swiftlib_dir + ' '
clang_opt = clang_compile_opt

is_cf_options_interop_updated = True

if config.variant_sdk and config.variant_sdk != "":
    # Check if CF_OPTIONS macro has been updated to be imported into Swift in C++ mode correctly.
    cf_avail_path = os.path.join(config.variant_sdk, 'System', 'Library', 'Frameworks', 'CoreFoundation.framework', 'Versions', 'A', 'Headers', 'CFAvailability.h')
    cf_avail_path_embedded = os.path.join(config.variant_sdk, 'System', 'Library', 'Frameworks', 'CoreFoundation.framework', 'Headers', 'CFAvailability.h')
    if os.path.exists(cf_avail_path) or os.path.exists(cf_avail_path_embedded):
        cf_avail_path_use = cf_avail_path if os.path.exists(cf_avail_path) else cf_avail_path_embedded
        with open(cf_avail_path_use, 'r') as file:
            contents = file.read()
            import re
            regex = r'^#define CF_OPTIONS\(_type, _name\) _type _name; enum __CF_OPTIONS_ATTRIBUTES'
            if re.search(regex, contents, re.MULTILINE):
                is_cf_options_interop_updated = False

if is_cf_options_interop_updated:
    config.available_features.add('cxx-interop-fixed-cf_options')

if get_target_os() in ['windows-msvc']:
    import os
    config.substitutions.insert(0, ('%target-abi', 'WIN'))
    # Clang should build object files with link settings equivalent to -libc MD
    # when building for the MSVC target.
    clang_opt = clang_compile_opt + '-D_MT -D_DLL -Xclang --dependent-lib=msvcrt -Xclang --dependent-lib=oldnames '
    # ucrt.modulemap currently requires -fbuiltin-headers-in-system-modules. -strict-implicit-module-context
    # is necessary for -Xcc arguments to be passed through ModuleInterfaceLoader.
    config.substitutions.insert(0, ('%target-swift-flags', '-vfsoverlay {} -strict-implicit-module-context -Xcc -Xclang -Xcc -fbuiltin-headers-in-system-modules'.format(
                                                            os.path.join(config.swift_obj_root,
                                                                         'stdlib',
                                                                         'windows-vfs-overlay.yaml'))))
else:
    # FIXME(compnerd) do all the targets we currently support use SysV ABI?
    config.substitutions.insert(0, ('%target-abi', 'SYSV'))
    config.substitutions.insert(0, ('%target-swift-flags', ''))

# Enable C++ interop when compiling Swift sources.
config.substitutions.insert(0, ('%target-interop-build-swift',
                                '%target-build-swift -Xfrontend -enable-experimental-cxx-interop '))

# Build C files disallowing implicit functions and with matching link settings, if required by the target.
config.substitutions.insert(0, ('%target-interop-build-clang',  '%target-clang -x c -Werror=implicit-function-declaration ' + clang_opt))

# Build C++ files with matching link settings, if required by the target.
config.substitutions.insert(0, ('%target-interop-build-clangxx', '%target-clangxx --std=gnu++14 ' + clang_opt))

# Test parsing of the generated C++ header in different C++ language modes.
config.substitutions.insert(0, ('%check-interop-cxx-header-in-clang\(([^)]+)\)',
                             SubstituteCaptures(r'%check-cxx-header-in-clang -std=c++14 -Wno-padded -Wno-c11-extensions -D_LIBCPP_CSTDLIB ' + clang_compile_opt + r'\1 && '
                                                r'%check-cxx-header-in-clang -std=c++17 -Wno-padded -Wno-c11-extensions -D_LIBCPP_CSTDLIB ' + clang_compile_opt + r'\1 && '
                                                r'%check-cxx-header-in-clang -std=c++20 -Wno-padded -Wno-c11-extensions -D_LIBCPP_CSTDLIB ' + clang_compile_opt + r'\1')))

# Test parsing of the generated C header in different C language modes.
config.substitutions.insert(0, ('%check-interop-c-header-in-clang\(([^)]+)\)',
                             SubstituteCaptures(r'%check-c-header-in-clang -std=c99 -Wno-padded -Wno-c11-extensions \1 && '
                                                r'%check-c-header-in-clang -std=c11 -Wno-padded \1')))