File: verify_all_overlays.py

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 (67 lines) | stat: -rwxr-xr-x 2,519 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
67
#!/usr/bin/env python3
# RUN: ${python} %s %target-swiftmodule-name %platform-sdk-overlay-dir \
# RUN:     %swift_src_root \
# RUN:     %target-sil-opt -sdk %sdk -enable-sil-verify-all \
# RUN:       -F %sdk/System/Library/PrivateFrameworks \
# RUN:       -F "%xcode-extra-frameworks-dir"

# REQUIRES: long_test
# REQUIRES: nonexecutable_test


import os
import subprocess
import sys

target_swiftmodule_name = sys.argv[1]
sdk_overlay_dir = sys.argv[2]
source_dir = sys.argv[3]
sil_opt_invocation = sys.argv[4:]

for module_file in os.listdir(sdk_overlay_dir):
    extra_args = []
    module_name, ext = os.path.splitext(module_file)
    if ext != ".swiftmodule":
        continue
    # Skip the standard library because it's tested elsewhere.
    if module_name == "Swift":
        continue
    # Skip the C++ standard library overlay because it's not yet shipped
    # in any released SDK.
    if module_name in ("Cxx", "CxxStdlib"):
        continue
    # TODO(TF-1229): Fix the "_Differentiation" module.
    if module_name == "_Differentiation":
        continue
    # TODO: fix the DifferentiationUnittest module.
    if module_name == "DifferentiationUnittest":
        continue
    # Backtracing needs its own additional modules in the module path
    if module_name == "_Backtracing":
        extra_args = ["-I", os.path.join(source_dir, "stdlib",
                                         "public", "Backtracing", "modules"),
                      "-I", os.path.join(source_dir, "include")]
    # _Concurrency needs its own additional modules in the module path
    if module_name == "_Concurrency":
        extra_args = ["-I", os.path.join(source_dir, "stdlib",
                                         "public", "Concurrency", "InternalShims")]

    print("# " + module_name)

    module_path = os.path.join(sdk_overlay_dir, module_file)
    if os.path.isdir(module_path):
        module_path = os.path.join(module_path, target_swiftmodule_name)

    # llvm-bcanalyzer | not grep Unknown
    bcanalyzer_output = subprocess.check_output(["llvm-bcanalyzer",
                                                 module_path]).decode("utf-8")
    if "Unknown" in bcanalyzer_output:
        print(bcanalyzer_output)
        sys.exit(1)

    # sil-opt
    # We are deliberately discarding the output here; we're just making sure
    # it can be generated.
    subprocess.check_output(sil_opt_invocation +
                            [module_path, "-module-name", module_name] +
                            extra_args)