Skip to content

Commit b2f60bf

Browse files
authored
Merge pull request #20312 from akyrtzi/sourcekit-resource-dir-fix
[sourcekitd] Make sure to put '-resource-dir' argument in front to allow overriding it by the passed in arguments
2 parents eea96a3 + 4d7ee80 commit b2f60bf

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public struct CoolInt {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// REQUIRES: OS=macosx
2+
3+
var p: CoolInt
4+
5+
// RUN: mkdir -p %t/custom-resource-dir/macosx/x86_64
6+
// RUN: %target-swift-frontend -emit-module -module-name Swift -parse-stdlib -target x86_64-apple-macosx10.12 %S/Inputs/custom-resource-stdlib.swift -o %t/custom-resource-dir/macosx/x86_64
7+
// RUN: %sourcekitd-test -req=cursor -pos=3:8 %s -- -resource-dir %t/custom-resource-dir -target x86_64-apple-macosx10.12 %s | %FileCheck %s
8+
9+
// CHECK: source.lang.swift.ref.struct
10+
// CHECK-NEXT: CoolInt

tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,12 @@ bool SwiftASTManager::initCompilerInvocation(CompilerInvocation &Invocation,
431431
DiagnosticEngine &Diags,
432432
StringRef UnresolvedPrimaryFile,
433433
std::string &Error) {
434-
SmallVector<const char *, 16> Args(OrigArgs.begin(), OrigArgs.end());
434+
SmallVector<const char *, 16> Args;
435+
// Make sure to put '-resource-dir' at the top to allow overriding it by
436+
// the passed in arguments.
435437
Args.push_back("-resource-dir");
436438
Args.push_back(Impl.RuntimeResourcePath.c_str());
439+
Args.append(OrigArgs.begin(), OrigArgs.end());
437440

438441
bool HadError = driver::getSingleFrontendInvocationFromDriverArguments(
439442
Args, Diags, [&](ArrayRef<const char *> FrontendArgs) {

0 commit comments

Comments
 (0)