|
| 1 | +# REQUIRES: standalone_build |
| 2 | +# REQUIRES: OS=macosx |
| 3 | + |
| 4 | +# RUN: %empty-directory(%t) |
| 5 | +# RUN: mkdir -p %t |
| 6 | +# RUN: split-file %s %t |
| 7 | + |
| 8 | +# Even though we are running build-script with dry-run, |
| 9 | +# symbol extraction runs real commands against the file system. |
| 10 | +# Thus we generate a series of files |
| 11 | +# to exercise the filtering logic |
| 12 | +# RUN: mkdir -p %t/destdir/bin |
| 13 | +# RUN: mkdir -p %t/destdir/lib |
| 14 | +# RUN: %swiftc_driver %t/hello.swift -o %t/destdir/bin/swift-demangle |
| 15 | +# RUN: %swiftc_driver %t/hello.swift -o %t/destdir/bin/swift-def-to-yaml-converter |
| 16 | +# RUN: ln -s %t/destdir/swift-demangle %t/destdir/bin/swift-api-digester |
| 17 | +# RUN: cp %t/swift-util.py %t/destdir/bin |
| 18 | +# RUN: chmod a+x %t/destdir/bin/swift-util.py |
| 19 | +# RUN: %swiftc_driver %t/dylib.swift -emit-library -o %t/destdir/lib/libswiftDemangle.dylib |
| 20 | +# RUN: %swiftc_driver %t/dylib.swift -emit-library -o %t/destdir/lib/lib_InternalSwiftScan.dylib |
| 21 | +# RUN: %swiftc_driver %t/dylib.swift -emit-library -static -o %t/destdir/lib/libswiftASTSectionImporter.a |
| 22 | +# RUN: mkdir -p %t/symroot/macosx-%target-cpu |
| 23 | + |
| 24 | +# test build-script-impl on its own |
| 25 | +# RUN: SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script-impl --dry-run --build-dir=%t/build --workspace=%swift_src_root/.. --cmake %cmake --only-execute macosx-%target-cpu-extractsymbols --host-cc /usr/bin/true --darwin-install-extract-symbols=1 --host-target=macosx-%target-cpu --install-symroot=%t/symroot --install-destdir=%t/destdir --build-jobs=1 --darwin-symroot-path-filters="/lib/ /swift-demangle" 2>&1 | tee %t/build-script-impl-output.txt |
| 26 | +# RUN: %FileCheck --input-file=%t/build-script-impl-output.txt %s |
| 27 | +# RUN: %FileCheck --input-file=%t/build-script-impl-output.txt --check-prefixes CHECK-SKIPPED %s |
| 28 | + |
| 29 | +# ensure build-script pass the argument to build-script-impl |
| 30 | +# RUN: %empty-directory(%t/symroot) |
| 31 | +# RUN: mkdir -p %t/symroot/macosx-%target-cpu |
| 32 | +# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --cmake %cmake --darwin-install-extract-symbols=1 --install-destdir=%t/destdir --toolchain-prefix="" --install-symroot=%t/symroot --darwin-symroot-path-filters="/lib/ /swift-demangle" --jobs=1 2>&1 | tee %t/build-script-output.txt |
| 33 | +# RUN: %FileCheck --input-file=%t/build-script-output.txt %s |
| 34 | +# RUN: %FileCheck --input-file=%t/build-script-output.txt --check-prefixes CHECK-SKIPPED %s |
| 35 | + |
| 36 | +# ensure we get all the values if we specify the flag multiple times |
| 37 | +# RUN: %empty-directory(%t/symroot) |
| 38 | +# RUN: mkdir -p %t/symroot/macosx-%target-cpu |
| 39 | +# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --cmake %cmake --darwin-install-extract-symbols=1 --install-destdir=%t/destdir --toolchain-prefix="" --install-symroot=%t/symroot --darwin-symroot-path-filters="/lib/" --darwin-symroot-path-filters="/swift-demangle" --jobs=1 2>&1 | tee %t/build-script-output.txt |
| 40 | +# RUN: %FileCheck --input-file=%t/build-script-output.txt %s |
| 41 | +# RUN: %FileCheck --input-file=%t/build-script-output.txt --check-prefixes CHECK-SKIPPED %s |
| 42 | + |
| 43 | + |
| 44 | +# CHECK: --- Extracting symbols --- |
| 45 | + |
| 46 | +# Ensure we copy all the files in lib and the swift-demangle executable |
| 47 | +# CHECK-LABEL: cpio |
| 48 | +# CHECK-DAG: swift-demangle |
| 49 | +# CHECK-DAG: libswiftDemangle.dylib |
| 50 | +# CHECK-DAG: lib_InternalSwiftScan.dylib |
| 51 | + |
| 52 | +# Ensure we generate symbols for the file in the symroot |
| 53 | +# CHECK-LABEL: "command": "dsymutil", "start" |
| 54 | +# CHECK-DAG: dsymutil {{.*}}swift-demangle |
| 55 | +# CHECK-DAG: dsymutil {{.*}}libswiftDemangle.dylib |
| 56 | +# CHECK-DAG: dsymutil {{.*}}lib_InternalSwiftScan.dylib |
| 57 | + |
| 58 | +# Ensure we strip the files in the installation directory |
| 59 | +# (which are not subject to the filters) |
| 60 | +# CHECK-LABEL: xcrun_find_tool strip |
| 61 | +# CHECK-DAG: strip {{.*}}swift-demangle |
| 62 | +# CHECK-DAG: strip {{.*}}swift-def-to-yaml-converter |
| 63 | +# CHECK-DAG: strip {{.*}}libswiftDemangle.dylib |
| 64 | +# CHECK-DAG: strip {{.*}}lib_InternalSwiftScan.dylib |
| 65 | +# CHECK-DAG: strip {{.*}}libswiftASTSectionImporter.a |
| 66 | +# CHECK-DAG: strip {{.*}}swift-util.py |
| 67 | + |
| 68 | +# Ensure we codesign dylibs |
| 69 | +# CHECK-LABEL: xcrun_find_tool codesign |
| 70 | +# CHECK-DAG: codesign {{.*}}libswiftDemangle.dylib |
| 71 | +# CHECK-DAG: codesign {{.*}}lib_InternalSwiftScan.dylib |
| 72 | + |
| 73 | + |
| 74 | +# CHECK-SKIPPED: --- Extracting symbols --- |
| 75 | + |
| 76 | +# Ensure we don't copy files not included by the filters |
| 77 | +# CHECK-SKIPPED-LABEL: cpio |
| 78 | +# CHECK-SKIPPED-NOT: swift-util.py |
| 79 | +# CHECK-SKIPPED-NOT: swift-def-to-yaml-converter |
| 80 | +# CHECK-SKIPPED-NOT: libswiftASTSectionImporter.a |
| 81 | +# CHECK-SKIPPED-NOT: swift-api-digester |
| 82 | + |
| 83 | +# Ensure we don't generate symbols for files we did not copy |
| 84 | +# CHECK-SKIPPED-LABEL: "command": "dsymutil", "start" |
| 85 | +# CHECK-SKIPPED-NOT: dsymutil {{.*}}swift-def-to-yaml-converter |
| 86 | +# CHECK-SKIPPED-NOT: dsymutil {{.*}}libswiftASTSectionImporter.a |
| 87 | +# CHECK-SKIPPED-NOT: dsymutil {{.*}}swift-util.py |
| 88 | +# CHECK-SKIPPED-NOT: dsymutil {{.*}}swift-api-digester |
| 89 | + |
| 90 | +# Ensure we don't strip symlinks |
| 91 | +# CHECK-SKIPPED-LABEL: xcrun_find_tool strip |
| 92 | +# CHECK-SKIPPED-NOT: strip {{.*}}swift-api-digester |
| 93 | + |
| 94 | +# Ensure we don't codesign executables, symlinks, |
| 95 | +# static archives and python scripts |
| 96 | +# CHECK-SKIPPED-LABEL: xcrun_find_tool codesign |
| 97 | +# CHECK-SKIPPED-NOT: codesign {{.*}}swift-demangle |
| 98 | +# CHECK-SKIPPED-NOT: codesign {{.*}}libswiftASTSectionImporter.a |
| 99 | +# CHECK-SKIPPED-NOT: codesign {{.*}}swift-util.py |
| 100 | +# CHECK-SKIPPED-NOT: codesign {{.*}}swift-api-digester |
| 101 | +# CHECK-SKIPPED-NOT: codesign {{.*}}swift-def-to-yaml-converter |
| 102 | + |
| 103 | +#--- hello.swift |
| 104 | +print("hello") |
| 105 | + |
| 106 | +#--- dylib.swift |
| 107 | +func greet(person: String) -> String { |
| 108 | + return "Hello \(person)" |
| 109 | +} |
| 110 | +#--- swift-util.py |
| 111 | +print("hello") |
0 commit comments