-
Notifications
You must be signed in to change notification settings - Fork 17
support for the -stdlib flag
#27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Danil42Russia
wants to merge
3
commits into
master
Choose a base branch
from
danil42russia/k2_build_fix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,12 +27,13 @@ type Invocation struct { | |
| sessionID uint32 // incremental while a daemon is alive | ||
|
|
||
| // cmdLine is parsed to the following fields: | ||
| cppInFile string // input file as specified in cmd line (.cpp for compilation, .h for pch generation) | ||
| objOutFile string // output file as specified in cmd line (.o for compilation, .gch/.pch for pch generation) | ||
| cxxName string // g++ / clang / etc. | ||
| cxxArgs []string // args like -Wall, -fpch-preprocess and many more, except: | ||
| cxxIDirs IncludeDirs // -I / -iquote / -isystem go here | ||
| depsFlags DepCmdFlags // -MD -MF file and others, used for .d files generation (not passed to server) | ||
| cppInFile string // input file as specified in cmd line (.cpp for compilation, .h for pch generation) | ||
| objOutFile string // output file as specified in cmd line (.o for compilation, .gch/.pch for pch generation) | ||
| cxxName string // g++ / clang / etc. | ||
| cxxArgs []string // args like -Wall, -fpch-preprocess and many more, except: | ||
| cxxArgsIncludes []string // TODO | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO mark is present but not explained |
||
| cxxIDirs IncludeDirs // -I / -iquote / -isystem go here | ||
| depsFlags DepCmdFlags // -MD -MF file and others, used for .d files generation (not passed to server) | ||
|
|
||
| waitUploads int32 // files still waiting for upload to finish; 0 releases wgUpload; see Invocation.DoneUploadFile | ||
| doneRecv int32 // 1 if o file received or failed receiving; 1 releases wgRecv; see Invocation.DoneRecvObj | ||
|
|
@@ -73,13 +74,14 @@ func pathAbs(cwd string, relPath string) string { | |
|
|
||
| func ParseCmdLineInvocation(daemon *Daemon, cwd string, cmdLine []string) (invocation *Invocation) { | ||
| invocation = &Invocation{ | ||
| createTime: time.Now(), | ||
| sessionID: atomic.AddUint32(&daemon.totalInvocations, 1), | ||
| cxxName: cmdLine[0], | ||
| cxxArgs: make([]string, 0, 10), | ||
| cxxIDirs: MakeIncludeDirs(), | ||
| summary: MakeInvocationSummary(), | ||
| includesCache: daemon.GetOrCreateIncludesCache(cmdLine[0]), | ||
| createTime: time.Now(), | ||
| sessionID: atomic.AddUint32(&daemon.totalInvocations, 1), | ||
| cxxName: cmdLine[0], | ||
| cxxArgs: make([]string, 0, 10), | ||
| cxxArgsIncludes: make([]string, 0, 1), | ||
| cxxIDirs: MakeIncludeDirs(), | ||
| summary: MakeInvocationSummary(), | ||
| includesCache: nil, // TODO | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? |
||
| } | ||
|
|
||
| parseArgFile := func(key string, arg string, argIndex *int) (string, bool) { | ||
|
|
@@ -113,6 +115,21 @@ func ParseCmdLineInvocation(daemon *Daemon, cwd string, cmdLine []string) (invoc | |
| return "" | ||
| } | ||
|
|
||
| parsePartsArgString := func(arg string, argIndex *int) string { | ||
| parts := strings.SplitN(arg, "=", 2) | ||
| if len(parts) == 2 { | ||
| return parts[1] | ||
| } | ||
|
|
||
| if *argIndex+1 < len(cmdLine) { | ||
| *argIndex++ | ||
| return cmdLine[*argIndex] | ||
| } else { | ||
| invocation.err = fmt.Errorf("unsupported command-line: no argument after %s", arg) | ||
| return "" | ||
| } | ||
| } | ||
|
|
||
| for i := 1; i < len(cmdLine); i++ { | ||
| arg := cmdLine[i] | ||
| if len(arg) == 0 { | ||
|
|
@@ -183,6 +200,9 @@ func ParseCmdLineInvocation(daemon *Daemon, cwd string, cmdLine []string) (invoc | |
| invocation.cxxArgs = append(invocation.cxxArgs, "-Xclang", xArg) | ||
| i++ | ||
| continue | ||
| } else if HasPrefixOrEqualOption(arg, "-stdlib") || HasPrefixOrEqualOption(arg, "--stdlib") { | ||
| invocation.cxxArgsIncludes = append(invocation.cxxArgsIncludes, parsePartsArgString(arg, &i)) | ||
| continue | ||
| } | ||
| } else if isSourceFileName(arg) || isHeaderFileName(arg) { | ||
| if invocation.cppInFile != "" { | ||
|
|
@@ -198,6 +218,8 @@ func ParseCmdLineInvocation(daemon *Daemon, cwd string, cmdLine []string) (invoc | |
| invocation.cxxArgs = append(invocation.cxxArgs, arg) | ||
| } | ||
|
|
||
| invocation.includesCache = daemon.GetOrCreateIncludesCache(invocation.cxxName, invocation.cxxArgsIncludes) | ||
|
|
||
| if invocation.err != nil { | ||
| return | ||
| } | ||
|
|
||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package client | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
| ) | ||
|
|
||
| func HasPrefixOrEqualOption(optionName string, flagValue string) bool { | ||
| if flagValue == optionName || strings.HasPrefix(flagValue, fmt.Sprintf("%s=", optionName)) { | ||
| return true | ||
| } | ||
|
|
||
| return false | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| package client | ||
|
|
||
| import "testing" | ||
|
|
||
| func TestOther(t *testing.T) { | ||
| tests := []struct { | ||
| optionName string | ||
| flag string | ||
| isPrefix bool | ||
| }{ | ||
| { | ||
| optionName: "-option", | ||
| flag: "-option=args", | ||
| isPrefix: true, | ||
| }, | ||
| { | ||
| optionName: "--option", | ||
| flag: "--option=args", | ||
| isPrefix: true, | ||
| }, | ||
| { | ||
| optionName: "-option", | ||
| flag: "-option", | ||
| isPrefix: true, | ||
| }, | ||
| { | ||
| optionName: "--option", | ||
| flag: "--option", | ||
| isPrefix: true, | ||
| }, | ||
|
|
||
| // Negative | ||
| { | ||
| optionName: "options", | ||
| flag: "-options", | ||
| isPrefix: false, | ||
| }, | ||
| { | ||
| optionName: "-options", | ||
| flag: "--options", | ||
| isPrefix: false, | ||
| }, | ||
| { | ||
| optionName: "--options", | ||
| flag: "-options", | ||
| isPrefix: false, | ||
| }, | ||
| { | ||
| optionName: "-option", | ||
| flag: "-options=args", | ||
| isPrefix: false, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| isPrefix := HasPrefixOrEqualOption(tt.optionName, tt.flag) | ||
| if isPrefix != tt.isPrefix { | ||
| t.Errorf("want: '%t', got: '%t' (optionName: '%s', flag: '%s')", tt.isPrefix, isPrefix, tt.optionName, tt.flag) | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be replaced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And for what and why?