def main()

in core/swift54Action/swiftbuild.py [0:0]


def main(argv):
    if len(argv) < 4:
        print("usage: <main-function> <source-dir> <target-dir>")
        sys.exit(1)

    main = argv[1]
    source_dir = os.path.abspath(argv[2])
    target = os.path.abspath("%s/exec" % argv[3])
    launch = os.path.abspath(argv[0]+".launcher.swift")

    src = "%s/exec" % source_dir

    #check if single source
    if os.path.isfile(src):
        actiondir = os.path.abspath("Sources")
        if not os.path.isdir(actiondir):
            os.makedirs(actiondir, mode=0o755)
        dst = "%s/main.swift" % actiondir
        os.rename(src, dst)
        sources(launch, os.path.abspath("."), main)
        build(os.path.abspath("."), target, ["./swiftbuildandlink.sh"])
    else:
        actiondir = "%s/Sources" % source_dir
        if not os.path.isdir(actiondir):
            os.makedirs(actiondir, mode=0o755)
        os.rename(os.path.abspath("Sources/_Whisk.swift"),"%s/Sources/_Whisk.swift" % source_dir)
        sources(launch, source_dir, main)
        build(source_dir, target, ["swift", "build", "-c", "release"])