Commit Graph

19 Commits

Author SHA1 Message Date
Connor Wakamo
70b47ef783 [driver] Forward-declare DiagnosticEngine in Driver.h instead of including swift/ADT/DiagnosticEngine.h.
Also removed an unnecessary newline in the declaration of Driver’s constructor.

Swift SVN r13177
2014-01-30 22:42:19 +00:00
Jordan Rose
b77dccef4e [driver] Add the -emit-library option.
This emits a dynamic library as the final build product (rather than an
executable), as well as implicitly passing -parse-as-library to the frontend.

Swift SVN r12930
2014-01-24 19:46:39 +00:00
Jordan Rose
d24b212597 [driver] Use the input file name as the output executable name.
...when no -module-name or -o is provided.

This makes the single-file compile /very/ easy: compiling "foo.swift"
produces an output named "foo", rather than "a.out". For multi-file
modes, the module name is used if -o is missing; if no module name is
provided, it defaults to "main".

In a nutshell:
  explicit -o > explicit -module-name > single file's stem name > "main"

<rdar://problem/12593849>

Swift SVN r12841
2014-01-23 02:11:48 +00:00
Jordan Rose
9cb81b0006 [driver] Add support for invoking ld.
swift_driver can now end-to-end compile a Swift file. Try it yourself!

echo 'println("hello")' | swift_driver -

Swift SVN r12840
2014-01-23 02:11:47 +00:00
Connor Wakamo
6384482902 [driver] Added support to honor the SDKROOT environment variable.
Centralized the driver-level handling of the SDK path in OutputInfo and
Driver::buildOutputInfo(), and added support for falling back to getenv(SDKROOT)
if -sdk wasn't passed (and SDKROOT is set in the environment).

Updated Swift::constructJob() to get the SDK path from the OutputInfo instead of
just passing -sdk from the original driver invocation.

Also added a driver-level check to ensure that the specified SDK is present;
if not, print out a warning. This fixes <rdar://problem/14409974>.

Added test/Driver/sdk.swift to test the -sdk and SDKROOT behavior, as well as
the nonexistent SDK warning.

Swift SVN r12815
2014-01-22 23:41:29 +00:00
Connor Wakamo
77890aa5cc [driver] Added initial support for loading an OutputFileMap.
Added an -output-file-map option which will specify the path to an
OutputFileMap.

Added Driver::buildOutputFileMap(), which constructs an OutputFileMap
from the arguments.

Added OutputFileMap* parameters to Driver::buildJobs() and
Driver::buildJobsForAction(). (These parameters are not yet honored, except to
pass to calls of these functions.)

Swift SVN r12772
2014-01-22 21:07:05 +00:00
Connor Wakamo
a982000175 [driver] Added a hidden -force-single-frontend-invocation option.
This sets OutputInfo::CompilerMode to a new SingleCompile mode, which in turn
causes the driver to create a single CompileJobAction for all inputs. This mode
also prevents the creation of a MergeModuleJobAction, since we can rely on the
frontend to generate a full swiftmodule.

This mode will allow the driver to properly compile the stdlib; if this mode is
necessary for other inputs, we can rename and publicize this option.

Swift SVN r12612
2014-01-20 21:47:17 +00:00
Connor Wakamo
bb439764b4 [driver] Implemented driver-level support for immediate mode and the REPL.
Introduced OutputInfo::Mode and OutputInfo::CompilerMode, which dictate how the
driver should invoke the integrated frontend. Currently, there are three
options:

- StandardCompile: invoke the frontend once-per-input, using -primary-file
- REPL: invoke the frontend as the REPL
- Immediate: invoke the frontend in immediate mode

Updated buildOutputInfo() to properly set the CompilerMode, and updated
buildActions() and Swift::constructJob() to honor the CompilerMode.

With these changes, "swift_driver" (with no inputs) and "swift_driver -repl"
should invoke the REPL, and "swift_driver -i" should invoke the frontend in
immediate mode.

Swift SVN r12547
2014-01-18 20:55:21 +00:00
Connor Wakamo
62d1fec41e [driver] Added support for suppressing the "no input files" error.
While SuppressNoInputFiles is not yet set, this is necessary for driver-level
support for the REPL, which requires no input files.

Swift SVN r12545
2014-01-18 20:55:19 +00:00
Connor Wakamo
622b83b98d [driver] Updated OutputInfo with a ShouldTreatModuleAsTopLevelOutput field.
This will indicate that the generated module was user-requested, so it should be
placed alongside other outputs.

Updated buildOutputInfo() in a few ways:
  - Updated it to set ShouldTreatModuleAsTopLevelOutput correctly.
  - Updated it such that -g implies that a module should be generated, but treated as an intermediate.
  - Moved the fallback ModuleName handling into buildOutputInfo(), which requires passing an InputList.

Swift SVN r12502
2014-01-17 19:39:25 +00:00
Connor Wakamo
6a33e53258 [driver] Renamed OutputMode to OutputInfo.
OutputInfo no longer just describes a "mode", so use a more applicable name for
the class.

Swift SVN r12501
2014-01-17 19:39:25 +00:00
Connor Wakamo
db3888ba0f [driver] Replaced Tool::constructJob()’s LinkingOutput parameter with an OutputMode parameter.
Moved OutputMode out of Driver and directly into swift::driver.
Adjusted callers of Tool::constructJob() to pass an OutputMode.

Swift SVN r12497
2014-01-17 19:39:23 +00:00
Connor Wakamo
11a6121caa [driver] Updated OutputMode to include the module name.
This is centralized, as many Commands need to reference the module name.

Swift SVN r12496
2014-01-17 19:39:23 +00:00
Connor Wakamo
f892b1a544 [driver] Implemented support for adding an additional output for a swiftmodule to the CommandOutput of frontend Commands.
Adjusted Driver::buildJobs() and Driver::buildJobsForAction() to include a const OutputMode& parameter.
Updated Driver::buildJobsForAction() to set an additional swiftmodule output on Jobs generated from a CompileJobAction if the OutputMode says the driver should generate a module.
This change now causes frontend invocations to pass “-emit-module -module-output-path <path>” when a module is requested, though the partial modules are not yet properly merged.

Swift SVN r12495
2014-01-17 19:39:22 +00:00
Connor Wakamo
b94e9e3f76 [driver] Slightly refactored Driver’s handling of OutputMode.
Instead of having buildActions() call the private Driver::getOutputMode() function, establish an OutputMode using a new Driver::buildOutputMode() function.
This change will allow the OutputMode to be more easily shared across functions without needing to generate it each time (though, at the moment, only buildActions() uses the OutputMode).

Swift SVN r12494
2014-01-17 19:39:22 +00:00
Connor Wakamo
e9599f249d [driver] Added support for adding a MergeModuleJobAction to the Action graph.
Updated Driver::OutputMode to also contain a ShouldGenerateModule field.
Updated Driver::getOutputMode() to set OutputMode::ShouldGenerateModule appropriately.
Updated Driver::buildActions() to insert a MergeModuleJobAction into the Action graph if the Driver’s OutputMode indicates that a module should be generated.

Swift SVN r12492
2014-01-17 19:39:21 +00:00
Connor Wakamo
40b38c40b2 [driver] Reworked Driver::buildJobsForAction() so that it doesn’t create the same Job multiple times.
Since a Job may be reached through multiple paths in the dependency graph, we
need to include support for caching Jobs. (Currently, the cache maps
Action/ToolChain pairs to Jobs.)

As a result of these changes, Tool::constructJob() and
Driver::buildJobsForAction() return a plain Job *, instead of a
std::unique_ptr<Job>, since the Jobs returned by buildJobsForAction() no longer
need to be unique.

Swift SVN r12443
2014-01-17 00:47:21 +00:00
Connor Wakamo
3d9f94e715 Properly implemented "swift_driver -driver-print-bindings".
This produces output similar to "clang -ccc-print-bindings".
Also added several tests to ensure that "swift_driver -driver-print-bindings"
behaves as expected.

Swift SVN r10935
2013-12-06 21:23:03 +00:00
Connor Wakamo
ed2038585f Initial set of changes to add a new 'swift_driver' executable.
- Added a couple of new targets:
  - libswiftDriver, which contains most of the driver implementation
  - swift_driver, which produces the actual executable

- Added centralized version information into libswiftBasic.

- Added a new "Driver Design & Internals" document, which currently describes
  the high-level design of the Swift driver.

- Implemented an early version of the functionality of the driver, including
  versions of the Parse, Pipeline, Bind, Translate, and Execute driver stages.
  Parse, Pipeline, and Bind are largely implemented; Translate and Execute are
  early placeholders. (Translate produces "swift_driver --version" and "ld -v"
  commands, while Execute performs all subtasks sequentially, rather than in
  parallel.)

This is just the starting point for the Swift driver. Tests for the existing
behavior are forthcoming.

Swift SVN r10933
2013-12-06 21:23:01 +00:00