Skip to content

Commit 6ffe644

Browse files
authored
Merge pull request #18973 from jrose-apple/interfacepalm
Generate swiftinterface files next to the stdlib swiftmodules, for testing purposes.
2 parents 04d5d9b + b6b3a1b commit 6ffe644

File tree

8 files changed

+185
-105
lines changed

8 files changed

+185
-105
lines changed

cmake/modules/SwiftSource.cmake

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ function(_compile_swift_files
317317
set(sibopt_file "${module_base}.O.sib")
318318
set(sibgen_file "${module_base}.sibgen")
319319
set(module_doc_file "${module_base}.swiftdoc")
320+
set(interface_file "${module_base}.swiftinterface")
320321

321322
list(APPEND command_create_dirs
322323
COMMAND "${CMAKE_COMMAND}" -E make_directory "${module_dir}")
@@ -395,7 +396,7 @@ function(_compile_swift_files
395396

396397
set(standard_outputs ${SWIFTFILE_OUTPUT})
397398
set(apinotes_outputs ${apinote_files})
398-
set(module_outputs "${module_file}" "${module_doc_file}")
399+
set(module_outputs "${module_file}" "${module_doc_file}" "${interface_file}")
399400
set(sib_outputs "${sib_file}")
400401
set(sibopt_outputs "${sibopt_file}")
401402
set(sibgen_outputs "${sibgen_file}")
@@ -483,13 +484,14 @@ function(_compile_swift_files
483484
#
484485
# 1. *.swiftmodule
485486
# 2. *.swiftdoc
486-
# 3. *.Onone.sib
487-
# 4. *.O.sib
488-
# 5. *.sibgen
487+
# 3. *.swiftinterface
488+
# 4. *.Onone.sib
489+
# 5. *.O.sib
490+
# 6. *.sibgen
489491
#
490-
# Only 1,2 are built by default. 3,4,5 are utility targets for use by engineers
491-
# and thus even though the targets are generated, the targets are not built by
492-
# default.
492+
# Only 1,2,3 are built by default. 4,5,6 are utility targets for use by
493+
# engineers and thus even though the targets are generated, the targets are
494+
# not built by default.
493495
#
494496
# We only build these when we are not producing a main file. We could do this
495497
# with sib/sibgen, but it is useful for looking at the stdlib.
@@ -500,10 +502,12 @@ function(_compile_swift_files
500502
"${CMAKE_COMMAND}" "-E" "remove" "-f" "${module_file}"
501503
COMMAND
502504
"${CMAKE_COMMAND}" "-E" "remove" "-f" "${module_doc_file}"
505+
COMMAND
506+
"${CMAKE_COMMAND}" "-E" "remove" "-f" "${interface_file}"
503507
COMMAND
504508
"${PYTHON_EXECUTABLE}" "${line_directive_tool}" "@${file_path}" --
505-
"${swift_compiler_tool}" "-emit-module" "-o" "${module_file}" ${swift_flags}
506-
"@${file_path}"
509+
"${swift_compiler_tool}" "-emit-module" "-o" "${module_file}"
510+
"-experimental-emit-interface" ${swift_flags} "@${file_path}"
507511
${command_touch_module_outputs}
508512
OUTPUT ${module_outputs}
509513
DEPENDS

include/swift/Driver/Driver.h

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -308,22 +308,19 @@ class Driver {
308308
///
309309
/// \param C The Compilation which this Job will eventually be part of
310310
/// \param JA The Action for which a Job should be created
311-
/// \param OI The OutputInfo for which a Job should be created
312311
/// \param OFM The OutputFileMap for which a Job should be created
313-
/// \param TC The tool chain which should be used to create the Job
314312
/// \param AtTopLevel indicates whether or not this is a top-level Job
315313
/// \param JobCache maps existing Action/ToolChain pairs to Jobs
316314
///
317315
/// \returns a Job for the given Action/ToolChain pair
318316
Job *buildJobsForAction(Compilation &C, const JobAction *JA,
319-
const OutputInfo &OI, const OutputFileMap *OFM,
320-
StringRef workingDirectory, const ToolChain &TC,
317+
const OutputFileMap *OFM,
318+
StringRef workingDirectory,
321319
bool AtTopLevel, JobCacheMap &JobCache) const;
322320

323321
private:
324322
void computeMainOutput(Compilation &C, const JobAction *JA,
325-
const OutputInfo &OI, const OutputFileMap *OFM,
326-
const ToolChain &TC, bool AtTopLevel,
323+
const OutputFileMap *OFM, bool AtTopLevel,
327324
SmallVectorImpl<const Action *> &InputActions,
328325
SmallVectorImpl<const Job *> &InputJobs,
329326
const TypeToPathMap *OutputMap,
@@ -333,7 +330,7 @@ class Driver {
333330
llvm::SmallString<128> &Buf,
334331
CommandOutput *Output) const;
335332

336-
void chooseSwiftModuleOutputPath(Compilation &C, const OutputInfo &OI,
333+
void chooseSwiftModuleOutputPath(Compilation &C,
337334
const OutputFileMap *OFM,
338335
const TypeToPathMap *OutputMap,
339336
StringRef workingDirectory,
@@ -343,39 +340,44 @@ class Driver {
343340
const TypeToPathMap *OutputMap,
344341
StringRef workingDirectory,
345342
CommandOutput *Output) const;
343+
344+
void chooseTextualInterfacePath(Compilation &C, const JobAction *JA,
345+
StringRef workingDirectory,
346+
llvm::SmallString<128> &buffer,
347+
CommandOutput *output) const;
348+
346349
void chooseRemappingOutputPath(Compilation &C, const TypeToPathMap *OutputMap,
347350
CommandOutput *Output) const;
348351

349352
void chooseSerializedDiagnosticsPath(Compilation &C, const JobAction *JA,
350-
const OutputInfo &OI,
351353
const TypeToPathMap *OutputMap,
352354
StringRef workingDirectory,
353355
CommandOutput *Output) const;
354356

355-
void chooseDependenciesOutputPaths(Compilation &C, const OutputInfo &OI,
357+
void chooseDependenciesOutputPaths(Compilation &C,
356358
const TypeToPathMap *OutputMap,
357359
StringRef workingDirectory,
358360
llvm::SmallString<128> &Buf,
359361
CommandOutput *Output) const;
360362

361-
void chooseOptimizationRecordPath(Compilation &C, const OutputInfo &OI,
363+
void chooseOptimizationRecordPath(Compilation &C,
362364
StringRef workingDirectory,
363365
llvm::SmallString<128> &Buf,
364366
CommandOutput *Output) const;
365367

366-
void chooseObjectiveCHeaderOutputPath(Compilation &C, const OutputInfo &OI,
368+
void chooseObjectiveCHeaderOutputPath(Compilation &C,
367369
const TypeToPathMap *OutputMap,
368370
StringRef workingDirectory,
369371
CommandOutput *Output) const;
370372

371-
void chooseLoadedModuleTracePath(Compilation &C, const OutputInfo &OI,
373+
void chooseLoadedModuleTracePath(Compilation &C,
372374
StringRef workingDirectory,
373375
llvm::SmallString<128> &Buf,
374376
CommandOutput *Output) const;
375377

376-
void chooseTBDPath(Compilation &C, const OutputInfo &OI,
377-
const TypeToPathMap *OutputMap, StringRef workingDirectory,
378-
llvm::SmallString<128> &Buf, CommandOutput *Output) const;
378+
void chooseTBDPath(Compilation &C, const TypeToPathMap *OutputMap,
379+
StringRef workingDirectory, llvm::SmallString<128> &Buf,
380+
CommandOutput *Output) const;
379381

380382
public:
381383
/// Handle any arguments which should be treated before building actions or

include/swift/Option/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ def emit_module_path_EQ : Joined<["-"], "emit-module-path=">,
296296
ArgumentIsPath]>,
297297
Alias<emit_module_path>;
298298

299+
def experimental_emit_interface : Flag<["-"], "experimental-emit-interface">,
300+
Flags<[NoInteractiveOption, HelpHidden]>,
301+
HelpText<"Test out the textual interfaces feature">;
302+
299303
def emit_objc_header : Flag<["-"], "emit-objc-header">,
300304
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>,
301305
HelpText<"Emit an Objective-C header file">;

0 commit comments

Comments
 (0)