xref: /llvm-project/clang/test/InstallAPI/extra-exclude-headers.test (revision 1c683eb324aea08b2f9de26cac27532da8a0f7e3)
1; RUN: rm -rf %t
2; RUN: split-file %s %t
3; RUN: mkdir -p %t/System/Library/Frameworks
4; RUN: cp -r %S/Inputs/Simple/Simple.framework %t/System/Library/Frameworks/
5; RUN: cp -r %S/Inputs/Foundation/Foundation.framework %t/System/Library/Frameworks/
6; RUN: sed -e "s|DSTROOT|%/t|g" %t/inputs.json.in > %t/inputs.json
7; RUN: yaml2obj %S/Inputs/Simple/Simple.yaml -o %t/Simple
8
9// Add exclude options.
10; RUN: clang-installapi -target x86_64-apple-macosx10.12 \
11; RUN: -install_name /System/Library/Frameworks/Simple.framework/Versions/A/Simple \
12; RUN: -current_version 1.2.3 -compatibility_version 1 \
13; RUN: -F%t/System/Library/Frameworks \
14; RUN: %t/inputs.json -o %t/Simple.tbd \
15; RUN: --verify-against=%t/Simple --verify-mode=ErrorsAndWarnings \
16; RUN: --exclude-public-header=**/SimpleAPI.h \
17; RUN: --exclude-private-header=**/SimplePrivateSPI.h 2>&1 | FileCheck -check-prefix=WARNINGS %s
18; RUN: llvm-readtapi -compare %t/Simple.tbd %t/expected-excluded.tbd
19
20// Add extra options.
21; RUN: clang-installapi -target x86_64-apple-macosx10.12 \
22; RUN: -install_name /System/Library/Frameworks/Simple.framework/Versions/A/Simple \
23; RUN: -current_version 1.2.3 -compatibility_version 1 \
24; RUN: -F%t/System/Library/Frameworks \
25; RUN: %t/inputs.json -o %t/Simple.tbd \
26; RUN: --verify-against=%t/Simple --verify-mode=Pedantic \
27; RUN: --extra-project-header=%S/Inputs/Simple/SimpleInternalAPI2.h \
28; RUN: --extra-project-header=%S/Inputs/Simple/SimpleInternalAPI.h \
29; RUN: --extra-public-header=%S/Inputs/Simple/Extra \
30; RUN: --extra-private-header=%S/Inputs/Simple/SimpleInternalSPI.h \
31; RUN: --exclude-public-header=**/SimpleAPI.h \
32; RUN: --exclude-private-header=**/SimplePrivateSPI.h 2>&1 | FileCheck -check-prefix=PEDANTIC -allow-empty %s
33; RUN: llvm-readtapi -compare %t/Simple.tbd %t/expected-extra.tbd
34
35// Check fatal missing file input.
36; RUN: not clang-installapi -target x86_64-apple-macosx10.12 \
37; RUN: -install_name /System/Library/Frameworks/Simple.framework/Versions/A/Simple \
38; RUN: -current_version 1.2.3 -compatibility_version 1 \
39; RUN: -F%t/System/Library/Frameworks \
40; RUN: %t/inputs.json -o %t/Simple.tbd \
41; RUN: --extra-public-header=%S/Inputs/Simple/NoSuchFile.h 2>&1 | FileCheck -allow-empty -check-prefix=NOPUBLIC %s
42
43; WARNINGS: warning: no declaration was found for exported symbol '_extraGlobalAPI1' in dynamic library
44; WARNINGS: warning: no declaration was found for exported symbol '_extraGlobalAPI2' in dynamic library
45; WARNINGS: warning: no declaration was found for exported symbol '(ObjC Class) SimpleInternalSPI' in dynamic library
46; WARNINGS: warning: no declaration was found for exported symbol '(ObjC Class) SimpleInternalAPI' in dynamic library
47
48; PEDANTIC-NOT: error
49; PEDANTIC: warning: cannot find protocol definition for 'ForwardProcotol'
50
51; NOPUBLIC: error: no such public header file:
52
53;--- expected-excluded.tbd
54{
55  "main_library": {
56    "current_versions": [
57      {
58        "version": "1.2.3"
59      }
60    ],
61    "exported_symbols": [
62      {
63        "data": {
64          "global": [
65            "_publicGlobalVariable",
66            "_privateGlobalVariable"
67          ],
68          "objc_class": [
69            "ExternalManagedObject", "Basic6",
70            "Basic1", "Base", "Basic3",
71            "FooClass", "Simple",
72            "Basic4_2", "Basic5",
73            "Basic9","Basic8",
74            "Basic2", "Basic4", "A", "SubClass"
75          ],
76          "objc_eh_type": [
77            "SubClass", "Base"
78          ],
79          "objc_ivar": [
80            "Basic4.ivar2", "Basic4_2.ivar1", "Basic6.ivar1",
81            "Basic4.ivar1", "Basic4_2.ivar2"
82          ],
83          "weak": [
84            "_weakPrivateGlobalVariable", "_weakPublicGlobalVariable"
85          ]
86        }
87      }
88    ],
89    "flags": [
90      {
91        "attributes": ["not_app_extension_safe"]
92      }
93    ],
94    "install_names": [
95      {
96        "name": "/System/Library/Frameworks/Simple.framework/Versions/A/Simple"
97      }
98    ],
99    "target_info": [
100      {"min_deployment": "10.12", "target": "x86_64-macos"}
101    ]
102  },
103  "tapi_tbd_version": 5
104}
105
106;--- expected-extra.tbd
107{
108  "main_library": {
109    "current_versions": [
110      { "version": "1.2.3" }
111    ],
112    "exported_symbols": [
113      {
114        "data": {
115          "global": [
116            "_publicGlobalVariable", "_extraGlobalAPI2",
117            "_extraGlobalAPI1", "_privateGlobalVariable"
118          ],
119          "objc_class": [
120            "SubClass", "SimpleInternalSPI",
121            "Basic6", "Basic1", "Base",
122            "Basic3", "Simple", "Basic4_2",
123            "Basic5", "FooClass", "Basic9",
124            "Basic8", "Basic2", "Basic4",
125            "A", "SimpleInternalAPI",
126            "ExternalManagedObject"
127          ],
128          "objc_eh_type": [
129            "SubClass", "SimpleInternalAPI",
130            "Base", "SimpleInternalSPI"
131          ],
132          "objc_ivar": [
133            "Basic4.ivar2", "Basic4_2.ivar1",
134            "Basic6.ivar1", "Basic4.ivar1",
135            "Basic4_2.ivar2"
136          ],
137          "weak": [
138            "_weakPrivateGlobalVariable", "_weakPublicGlobalVariable"
139          ]
140        }
141      }
142    ],
143    "flags": [
144      {
145        "attributes": [ "not_app_extension_safe"]
146      }
147    ],
148    "install_names": [
149      { "name": "/System/Library/Frameworks/Simple.framework/Versions/A/Simple" }
150    ],
151    "target_info": [
152      { "min_deployment": "10.12", "target": "x86_64-macos" }
153    ]
154  },
155  "tapi_tbd_version": 5
156}
157
158;--- inputs.json.in
159{
160  "headers": [
161  {
162    "path" : "DSTROOT/System/Library/Frameworks/Simple.framework/Headers/Basic.h",
163    "type" : "public"
164  },
165  {
166    "path" : "DSTROOT/System/Library/Frameworks/Simple.framework/Headers/External.h",
167    "type" : "public"
168  },
169  {
170    "path" : "DSTROOT/System/Library/Frameworks/Simple.framework/Headers/Simple.h",
171    "type" : "public"
172  },
173  {
174    "path" : "DSTROOT/System/Library/Frameworks/Simple.framework/Headers/SimpleAPI.h",
175    "type" : "public"
176  },
177  {
178    "path" : "DSTROOT/System/Library/Frameworks/Simple.framework/PrivateHeaders/SimplePrivate.h",
179    "type" : "private"
180  },
181  {
182    "path" : "DSTROOT/System/Library/Frameworks/Simple.framework/PrivateHeaders/SimplePrivateSPI.h",
183    "type" : "private"
184  }
185  ],
186  "version": "3"
187}
188