Created
August 21, 2018 15:24
-
-
Save yeswolf/1f70a65258b595176509d81f104a2ab4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function request(requestType, srcText, srcPath, offset) { | |
function targetArgumentsForImport(lib, platform, target) { | |
return loadedArgs.indexOf("-target") === -1 && srcText.includes(`import ${lib}`) | |
? [ | |
"-target", | |
target, | |
"-sdk", | |
`/Applications/Xcode.app/Contents/Developer/Platforms/${platform}.platform/Developer/SDKs/${platform}.sdk` | |
] | |
: null; | |
} | |
function defaultTargetArguments() { | |
if (loadedArgs.indexOf("-target") !== -1) { | |
return []; | |
} | |
return process.platform === 'linux' | |
? ["-target", "x86_64-unknown-linux"] | |
: ["-target", "x86_64-apple-macosx10.10", "-sdk", `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk`]; | |
} | |
const sourcePaths = server.getAllSourcePaths(srcPath); | |
const loadedArgs = server.loadArgsImportPaths(); | |
/*const inferredOSArgs = process.platform === 'darwin' | |
? ["-target", "x86_64-apple-macosx10.10"]*/ | |
const inferredTargetArgs = targetArgumentsForImport('UIKit', 'iPhoneOS', 'arm64-apple-ios11.0') | |
|| targetArgumentsForImport('WatchKit', 'WatchOS', 'armv7k-apple-watchos4.0') | |
|| targetArgumentsForImport('AppKit', 'MacOSX', 'x86_64-apple-macosx10.10') | |
|| defaultTargetArguments(); | |
var compilerargs = JSON.stringify([ | |
...(sourcePaths || [srcPath]), | |
...server.loadArgsImportPaths(), | |
...inferredTargetArgs | |
]); | |
compilerargs = JSON.stringify( | |
[ srcPath, | |
"-swift-version","4","-target","x86_64-apple-macosx10.10","-sdk","/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk","-F","/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks","-Onone","-g","-enable-testing","-j8","-DSWIFT_PACKAGE","-Xcc","-fmodule-map-file=/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap","-I","/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOZlib/include","-Xcc","-fmodule-map-file=/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap","-I","/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOHTTPParser/include","-Xcc","-fmodule-map-file=/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap","-I","/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/CNIOOpenSSL/include","-Xcc","-fmodule-map-file=/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/checkouts/swift-nio-ssl-support.git--2359138821295600615/module.modulemap","-I/usr/local/Cellar/libressl/2.7.4/include","-I/usr/local/Cellar/libressl/2.7.4/include","-Xcc","-fmodule-map-file=/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/checkouts/crypto.git-7980259129511365902/Sources/libbcrypt/include/module.modulemap","-I","/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/checkouts/crypto.git-7980259129511365902/Sources/libbcrypt/include","-Xcc","-fmodule-map-file=/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap","-I","/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOSHA1/include","-Xcc","-fmodule-map-file=/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap","-I","/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include","-Xcc","-fmodule-map-file=/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap","-I","/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include","-Xcc","-fmodule-map-file=/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap","-I","/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include","-Xcc","-fmodule-map-file=/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap","-module-cache-path","/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/x86_64-apple-macosx10.10/debug/ModuleCache", | |
"-Xcc", | |
"-I", | |
"-Xcc", | |
"/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/debug", | |
"-I", | |
"/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/debug", | |
"-Xcc", | |
"-F", | |
"-Xcc", | |
"/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/debug", | |
"-F", | |
"/Users/jetbrains/Desktop/ServerSide Swift/dev/appcode-clion-vapor/.build/debug" | |
] | |
); | |
srcText = JSON.stringify(srcText); | |
let request = `{ | |
key.request: source.request.${requestType}, | |
key.sourcefile: "${srcPath}", | |
key.offset: ${offset}, | |
key.compilerargs: ${compilerargs}, | |
key.sourcetext: ${srcText} | |
} | |
`; | |
return typedResponse(request, requestType); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment