[Swift-devel] cd into and run Swift statements in a dir

Ketan Maheshwari ketan at mcs.anl.gov
Thu May 21 10:36:43 CDT 2015


Hi All,

Max Hutchinson and I are working on an application whose first stage
involves building the inputs using an application provided makefile.

(Max, feel free to chime in if I captured things inaccurately from our
discussion)

The makefile must work from a directory where it expects an input
config and will output the executable and a couple of additional
configuration files which will be used in the further stages.

Max (Max, correct me if this is not the case) would normally do this
from within a python script by starting with a "mkdir" and "cd"
command followed by running the makefile and ending with a "cd ..".

After discussing a bit about how to do this in Swift, I was unsure how
we can tell Swift to change the working directory into a user specific
one and run the subsequent statements in there at Swift level.
Interestingly, at runtime, Swift will indeed create its own unique
directory and _Swiftwrap will run things from within this directory.

We discussed a couple of alternatives: a) invoke the makefile by
specifying a target dirname which is created as part of Swift mappers
operations. b) create a tiny wrapper around the makefile and put the
mkdir; cd, cd .. in this wrapper. Max however thinks that while these
are plausible solutions, he would prefer to keep things simpler by not
having to do this if Swift can do it for him.

So, a couple of ideas to achieve this: 1) A way to tell Swift to haul
the swift.work run directories to user area and 2) Have ability to
write script commands in Swift app definition eg. (..) app (..) {
mkdir tmp.$$; cd tmp.$$; appname args}

Thoughts?

Thanks,
Ketan



More information about the Swift-devel mailing list