Uploaded image for project: 'Swift'
  1. Swift
  2. SR-327

Add --outdir argument to swiftc



    • Type: New Feature
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:


      Currently swiftc writes all its output to current working directory. Please consider adding a --outdir argument so you can instruct swiftc to write its output to a different directory.

      This makes it easier to integrate swiftc with other build systems. For example on Ninja you need to write all paths relative to the top level Ninja file directory. This leads to the weird situation that you need to manually cd into the output directory and invoke swiftc with paths that are different to what the Ninja file has.

      As an example suppose you have a swift project with sources in Sources and you want to build in a directory called build and place the temporary files in a directory called build/tmpdir then you Ninja dependency looks [roughly] like this

      executable [depends on] ../Sources/myexe.swift

      but the compilation command is this:

      cd tmpdir; swiftc -c ../../Sources/myexe.swift; cd ..

      Note the extra '..' in the source file. This makes integration work needlessly complicated. With --outdir the command would look like this:

      swiftc --outdir=tmpdir -c ../Sources/myexe.swift


          Issue Links



              • Assignee:
                modocache Brian Ivan Gesiak
                jpakkane Jussi Pakkanen
              • Votes:
                1 Vote for this issue
                4 Start watching this issue


                • Created: