Skip to content

Generate swiftinterface files next to the stdlib swiftmodules #18973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions cmake/modules/SwiftSource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ function(_compile_swift_files
set(sibopt_file "${module_base}.O.sib")
set(sibgen_file "${module_base}.sibgen")
set(module_doc_file "${module_base}.swiftdoc")
set(interface_file "${module_base}.swiftinterface")

list(APPEND command_create_dirs
COMMAND "${CMAKE_COMMAND}" -E make_directory "${module_dir}")
Expand Down Expand Up @@ -395,7 +396,7 @@ function(_compile_swift_files

set(standard_outputs ${SWIFTFILE_OUTPUT})
set(apinotes_outputs ${apinote_files})
set(module_outputs "${module_file}" "${module_doc_file}")
set(module_outputs "${module_file}" "${module_doc_file}" "${interface_file}")
set(sib_outputs "${sib_file}")
set(sibopt_outputs "${sibopt_file}")
set(sibgen_outputs "${sibgen_file}")
Expand Down Expand Up @@ -483,13 +484,14 @@ function(_compile_swift_files
#
# 1. *.swiftmodule
# 2. *.swiftdoc
# 3. *.Onone.sib
# 4. *.O.sib
# 5. *.sibgen
# 3. *.swiftinterface
# 4. *.Onone.sib
# 5. *.O.sib
# 6. *.sibgen
#
# Only 1,2 are built by default. 3,4,5 are utility targets for use by engineers
# and thus even though the targets are generated, the targets are not built by
# default.
# Only 1,2,3 are built by default. 4,5,6 are utility targets for use by
# engineers and thus even though the targets are generated, the targets are
# not built by default.
#
# We only build these when we are not producing a main file. We could do this
# with sib/sibgen, but it is useful for looking at the stdlib.
Expand All @@ -500,10 +502,12 @@ function(_compile_swift_files
"${CMAKE_COMMAND}" "-E" "remove" "-f" "${module_file}"
COMMAND
"${CMAKE_COMMAND}" "-E" "remove" "-f" "${module_doc_file}"
COMMAND
"${CMAKE_COMMAND}" "-E" "remove" "-f" "${interface_file}"
COMMAND
"${PYTHON_EXECUTABLE}" "${line_directive_tool}" "@${file_path}" --
"${swift_compiler_tool}" "-emit-module" "-o" "${module_file}" ${swift_flags}
"@${file_path}"
"${swift_compiler_tool}" "-emit-module" "-o" "${module_file}"
"-experimental-emit-interface" ${swift_flags} "@${file_path}"
${command_touch_module_outputs}
OUTPUT ${module_outputs}
DEPENDS
Expand Down
32 changes: 17 additions & 15 deletions include/swift/Driver/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,22 +308,19 @@ class Driver {
///
/// \param C The Compilation which this Job will eventually be part of
/// \param JA The Action for which a Job should be created
/// \param OI The OutputInfo for which a Job should be created
/// \param OFM The OutputFileMap for which a Job should be created
/// \param TC The tool chain which should be used to create the Job
/// \param AtTopLevel indicates whether or not this is a top-level Job
/// \param JobCache maps existing Action/ToolChain pairs to Jobs
///
/// \returns a Job for the given Action/ToolChain pair
Job *buildJobsForAction(Compilation &C, const JobAction *JA,
const OutputInfo &OI, const OutputFileMap *OFM,
StringRef workingDirectory, const ToolChain &TC,
const OutputFileMap *OFM,
StringRef workingDirectory,
bool AtTopLevel, JobCacheMap &JobCache) const;

private:
void computeMainOutput(Compilation &C, const JobAction *JA,
const OutputInfo &OI, const OutputFileMap *OFM,
const ToolChain &TC, bool AtTopLevel,
const OutputFileMap *OFM, bool AtTopLevel,
SmallVectorImpl<const Action *> &InputActions,
SmallVectorImpl<const Job *> &InputJobs,
const TypeToPathMap *OutputMap,
Expand All @@ -333,7 +330,7 @@ class Driver {
llvm::SmallString<128> &Buf,
CommandOutput *Output) const;

void chooseSwiftModuleOutputPath(Compilation &C, const OutputInfo &OI,
void chooseSwiftModuleOutputPath(Compilation &C,
const OutputFileMap *OFM,
const TypeToPathMap *OutputMap,
StringRef workingDirectory,
Expand All @@ -343,39 +340,44 @@ class Driver {
const TypeToPathMap *OutputMap,
StringRef workingDirectory,
CommandOutput *Output) const;

void chooseTextualInterfacePath(Compilation &C, const JobAction *JA,
StringRef workingDirectory,
llvm::SmallString<128> &buffer,
CommandOutput *output) const;

void chooseRemappingOutputPath(Compilation &C, const TypeToPathMap *OutputMap,
CommandOutput *Output) const;

void chooseSerializedDiagnosticsPath(Compilation &C, const JobAction *JA,
const OutputInfo &OI,
const TypeToPathMap *OutputMap,
StringRef workingDirectory,
CommandOutput *Output) const;

void chooseDependenciesOutputPaths(Compilation &C, const OutputInfo &OI,
void chooseDependenciesOutputPaths(Compilation &C,
const TypeToPathMap *OutputMap,
StringRef workingDirectory,
llvm::SmallString<128> &Buf,
CommandOutput *Output) const;

void chooseOptimizationRecordPath(Compilation &C, const OutputInfo &OI,
void chooseOptimizationRecordPath(Compilation &C,
StringRef workingDirectory,
llvm::SmallString<128> &Buf,
CommandOutput *Output) const;

void chooseObjectiveCHeaderOutputPath(Compilation &C, const OutputInfo &OI,
void chooseObjectiveCHeaderOutputPath(Compilation &C,
const TypeToPathMap *OutputMap,
StringRef workingDirectory,
CommandOutput *Output) const;

void chooseLoadedModuleTracePath(Compilation &C, const OutputInfo &OI,
void chooseLoadedModuleTracePath(Compilation &C,
StringRef workingDirectory,
llvm::SmallString<128> &Buf,
CommandOutput *Output) const;

void chooseTBDPath(Compilation &C, const OutputInfo &OI,
const TypeToPathMap *OutputMap, StringRef workingDirectory,
llvm::SmallString<128> &Buf, CommandOutput *Output) const;
void chooseTBDPath(Compilation &C, const TypeToPathMap *OutputMap,
StringRef workingDirectory, llvm::SmallString<128> &Buf,
CommandOutput *Output) const;

public:
/// Handle any arguments which should be treated before building actions or
Expand Down
4 changes: 4 additions & 0 deletions include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ def emit_module_path_EQ : Joined<["-"], "emit-module-path=">,
ArgumentIsPath]>,
Alias<emit_module_path>;

def experimental_emit_interface : Flag<["-"], "experimental-emit-interface">,
Flags<[NoInteractiveOption, HelpHidden]>,
HelpText<"Test out the textual interfaces feature">;

def emit_objc_header : Flag<["-"], "emit-objc-header">,
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>,
HelpText<"Emit an Objective-C header file">;
Expand Down
Loading