Override the path to the Swift compiler?


(Jimmy Yue) #1

Hey Swift Devs,

Does there happen to be an environment variable, similar to 'CC' for C,
that I could use to override the path to the Swift compiler? If so, is
there also one for ibtool, metal, etc.?

I want to redirect swift calls to a bash script that does some processing
before running the original compile call. Preferably, I would have all the
information available to the swift call (input files, output files, etc.),
which makes using a build rule a little difficult.


(Greg Parker) #2

You might be able to do this using the "Build Rules" settings in Xcode. (project settings > target settings > Build Rules > click Copy to Target for the file type you are interested in)

Xcode honors SWIFT_LIBRARY_PATH and SWIFT_EXEC in project settings, but that is designed to substitute the entire Swift toolchain, not just the Swift compiler itself. SWIFT_EXEC might work if your wrapper script lives next to swiftc in the filesystem.

ยทยทยท

On May 30, 2017, at 4:48 PM, Jimmy Yue via swift-dev <swift-dev@swift.org> wrote:

Hey Swift Devs,

Does there happen to be an environment variable, similar to 'CC' for C, that I could use to override the path to the Swift compiler? If so, is there also one for ibtool, metal, etc.?

I want to redirect swift calls to a bash script that does some processing before running the original compile call. Preferably, I would have all the information available to the swift call (input files, output files, etc.), which makes using a build rule a little difficult.

--
Greg Parker gparker@apple.com <mailto:gparker@apple.com> Runtime Wrangler