@@ -302,20 +302,28 @@ build nodes for the its `SwiftTargetBuildDescription` and
302
302
303
303
304
304
305
- ##### module.modulemap
305
+ ##### Module Maps
306
306
307
307
The product module map’s purpose is to define the public API of the mixed
308
308
language module. It has two parts, a primary module declaration and a secondary
309
309
submodule declaration. The former of which exposes the public C language
310
310
headers and the latter of which exposes the generated interop header.
311
311
312
312
There are two cases when creating the product module map:
313
- - If a custom module map exists in the target, its contents are copied to the
314
- product module map and a submodule is added to expose the generated interop
315
- header.
313
+ - If a custom module map exists in the target, its contents are copied and
314
+ extended to modularize the generated interop header. These contents are
315
+ written to the build directory as ` extended-custom-module.modulemap ` .
316
+ Since the public header directory and build directory are passed as import
317
+ paths to the build invocations, a different name is needed for this module
318
+ map as the ` -import-underlying-module ` should only be able to find one
319
+ ` module.modulemap ` file from the given import paths.
316
320
- Else, the product module map’s contents will be generated via the same
317
321
generation rules established in [ SE-0038] with an added step to generate the
318
- ` .Swift ` submodule.
322
+ ` .Swift ` submodule. This file is called ` module.modulemap ` and lives in the
323
+ build directory.
324
+
325
+ Clients will use an _ extended_ module map that includes the modularized interop
326
+ header. Building the target will use _ unextended_ module map.
319
327
320
328
> Note: It’s possible that the Clang part of the module exports no public API.
321
329
> This could be the case for a target whose public API surface is written in
@@ -326,7 +334,7 @@ Below is an example of a module map for a target that has an umbrella
326
334
header in its public headers directory (` include ` ).
327
335
328
336
```
329
- // module.modulemap
337
+ // extended-custom- module.modulemap
330
338
331
339
// This declaration is either copied from the custom module map or generated
332
340
// via the rules from SE-0038.
@@ -343,54 +351,18 @@ module MixedTarget.Swift {
343
351
344
352
##### all-product-headers.yaml
345
353
346
- The product ` all-product-headers.yaml ` overlay file is only created when there
347
- exists a custom module map that needs to be swapped out for the product module
348
- map.
354
+ An ` all-product-headers.yaml ` VFS overlay file will adjust the public headers
355
+ directory to expose the interop header as a relative path, and, if a custom
356
+ module map exists, swap it out for the extended one that modualrizes the interop
357
+ header.
349
358
350
- In the case that this overlay file exists , it will be passed alongside the
351
- product module map as a compilation argument to clients:
359
+ In either case, it will be passed alongside the module map as a compilation
360
+ argument to clients:
352
361
```
353
362
-fmodule-map-file=/Users/crusty/Developer/MixedTarget/Sources/MixedTarget/include/module.modulemap
354
363
-ivfsoverlay /Users/crusty/Developer/MixedTarget/.build/.../MixedTarget.build/Product/all-product-headers.yaml
355
364
```
356
365
357
- The ` -fmodule-map-file ` argument tells the client to find the mixed target’s
358
- module map in its public ` include ` directory. However, the product module map
359
- should be used instead of the custom module map, so passing the overlay via
360
- ` -vfsoverlay ` will ensure that resolving the module map path redirects to the
361
- product module map in the build directory. The reason this is necessary is
362
- because a custom module map will likely have relative paths within it (e.g.
363
- ` umbrella header “MyHeader.h” ` ) that are preserved when its contents are copied
364
- to the product module map. In order for these relative paths to be resolved,
365
- the product module map needs to appear as if it is in the original directory
366
- that the custom module map resides in.
367
-
368
- The below sample shows what this overlay file may look like:
369
- ``` yaml
370
- // all-product-headers.yaml
371
-
372
- {
373
- " version " : 0,
374
- " case-sensitive " : false,
375
- " roots " :
376
- [
377
- {
378
- " name " : " /Users/crusty/Developer/MixedTarget/Sources/MixedTarget/include" ,
379
- " type " : " directory" ,
380
- " contents " :
381
- [
382
- {
383
- " name " : " module.modulemap" ,
384
- " type " : " file" ,
385
- " external-contents " : " /Users/crusty/Developer/MixedTarget/.build/.../MixedTarget.build/Product/module.modulemap" ,
386
- },
387
- ],
388
- },
389
- ],
390
- " use-external-names " : false,
391
- }
392
- ```
393
-
394
366
### Additional changes to the package manager
395
367
396
368
It is the goal for mixed language targets to work on all platforms supported
0 commit comments