def sources()

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


def sources(launcher, source_dir, main):
    actiondir = "%s/Sources" % source_dir
    # copy the launcher fixing the main
    dst = "%s/main.swift" % actiondir
    with codecs.open(dst, 'a', 'utf-8') as d:
        with codecs.open(launcher, 'r', 'utf-8') as e:
            code = e.read()
            code += "while let inputStr: String = readLine() {\n"
            code += "  let json = inputStr.data(using: .utf8, allowLossyConversion: true)!\n"
            code += "  let parsed = try JSONSerialization.jsonObject(with: json, options: []) as! [String: Any]\n"
            code += "  for (key, value) in parsed {\n"
            code += "    if key != \"value\" {\n"
            code += "      setenv(\"__OW_\\(key.uppercased())\",value as! String,1)\n"
            code += "    }\n"
            code += "  }\n"
            code += "  let jsonData = try JSONSerialization.data(withJSONObject: parsed[\"value\"] as Any, options: [])\n"
            code += "  _run_main(mainFunction: %s, json: jsonData)\n" % main
            code += "} \n"
            d.write(code)