You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can c_cpp_properties.json support wildcard paths? #723
The scripts I am using to build my projects are generating the dependencies in a folder. It could be very useful in this situation to be able to give a path like this /my/path/*/include to simplify /my/path/dep1/include/my/path/dep2/include/my/path/dep3/include
As far as I can see the middle wildcard doesn't work. Our include files are all "include" & "interface" directories in many places. So this only leaves using everything via "${workspaceFolder}/", or adding each one in turn when required (which may be better where there are duplicated names). I suspect using "${workspaceFolder}/" isn't great for performance.
A middle wildcard is not currently supported. I started a branch that would support this a while ago, but I forget what state it was in and now the branch is out of date. If anyone wants to get it back in sync with master and finish it, we can consider taking it. I'll reopen this issue since the original request was not actually addressed.
@haolly Not yet -- it's been pushed back repeatedly. It's currently "On Deck" which means we don't have a definite target Milestone yet. The best case might be September, but it certainly could be delayed further.
Here is a standalone working example of a glob walker
show
importfsfrom'fs';importpathfrom'path';importprocessfrom'process'classDemo{globMatch(pattern,str){// use picomatch ?leti=0;letj=0;while(i<pattern.length&&j<str.length){if(pattern.charAt(i)=='*'){if(i+1==pattern.length)returntrue;for(letk=j;k<str.length;k++)if(this.globMatch(pattern.substring(i+1),str.substring(k)))returntrue;returnfalse;}else{if(pattern.charAt(i)!=str.charAt(j))returnfalse;i++;j++;}}return(i==pattern.length&&j==str.length);}tryReadDir=(dir)=>{try{constres=fs.readdirSync(dir);returnres;}catch(e){return[];}};globWalkDir(components,i=0){if(i>=components.length||components[i]=='**'){returnpath.sep+components.join(path.sep);// end of expression}constcwd=path.sep+components.slice(0,i).join(path.sep);returnthis.tryReadDir(cwd).filter(name=>this.globMatch(components[i],name)).filter(match=>fs.lstatSync(path.join(cwd,match)).isDirectory()).map(match=>this.globWalkDir([...components.slice(0,i),match, ...components.slice(i+1)],i+1));//console.log({components,i, cwd, ls, res})}}if(!process.argv[2]||!path.isAbsolute(process.argv[2])){throw'USAGE: glob.mjs ABS_GLOB_EXP';}constcompo=process.argv[2].split(path.sep).slice(1);console.log(newDemo().globWalkDir(compo).flat(compo.length));
and can be used as drop-in replacement of resolveAndSplit() in ~/.vscode/extensions/ms-vscode.cpptools-*/dist/main.js :
globMatch(pattern,str){// TODO: use picomatch ?leti=0;letj=0;while(i<pattern.length&&j<str.length){if(pattern.charAt(i)=='*'){if(i+1==pattern.length)returntrue;for(letk=j;k<str.length;k++)if(this.globMatch(pattern.substring(i+1),str.substring(k)))returntrue;returnfalse;}else{if(pattern.charAt(i)!=str.charAt(j))returnfalse;i++;j++;}}return(i==pattern.length&&j==str.length);}tryReadDir(...args){try{returnfs.readdirSync(...args);}catch(e){return[];}}globWalkDir(components,i=0){if(i>=components.length||components[i]=='**'){returnpath.sep+components.join(path.sep);// end of expression}constcwd=path.sep+components.slice(0,i).join(path.sep);returnthis.tryReadDir(cwd).filter(name=>this.globMatch(components[i],name)).filter(match=>fs.lstatSync(path.join(cwd,match)).isDirectory()).map(match=>this.globWalkDir([...components.slice(0,i),match, ...components.slice(i+1)],i+1));}resolveAndSplit(paths,defaultValue,env){//// <<<<<returnpaths ? this.resolveDefaults(paths,defaultValue).map(entry=>util.resolveVariables(entry,env).split(util.envDelimiter).filter(e=>e).map(e=>e.replace("${workspaceFolder}",this.rootUri.fsPath).split(path.sep).slice(1)).map(e=>this.globWalkDir(e).flat(e.length)).flat()).flat() : [];}
Tell me if you have any use-case that doesn't work
Sean McManus (@sean-mcmanus) Slightly confused about the status of this issue and the related issue #10388. What is the status with the latest VS Code 1.79.2 and C/C++ extension v1.16.3? What is the syntax?
Thanks.
Activity
sean-mcmanus commentedon Jan 10, 2018
This should be implementable in our open source typescript if anyone wants to contribute :)
bobbrow commentedon Jun 26, 2018
With 0.17.5 you should be able to use
/my/path/**and it will add all of the relevant paths. Let us know if that works for you.aaronlelevier commentedon Feb 22, 2019
Hi, is a middle wildcard not supported though? For example:
It's not finding the path, and I'm trying to avoid adding each
opencv/modules/<some-module>/include/**to theincludePathThanks
BillDenton commentedon Feb 28, 2019
As far as I can see the middle wildcard doesn't work. Our include files are all "include" & "interface" directories in many places. So this only leaves using everything via "${workspaceFolder}/", or adding each one in turn when required (which may be better where there are duplicated names). I suspect using "${workspaceFolder}/" isn't great for performance.
bobbrow commentedon Feb 28, 2019
A middle wildcard is not currently supported. I started a branch that would support this a while ago, but I forget what state it was in and now the branch is out of date. If anyone wants to get it back in sync with master and finish it, we can consider taking it. I'll reopen this issue since the original request was not actually addressed.
This is the branch: https://github.com/Microsoft/vscode-cpptools/tree/bobbrow/expand-wildcards
21 remaining items
momadacoding commentedon Jun 15, 2022
any progress?
sean-mcmanus commentedon Jun 15, 2022
@haolly Not yet -- it's been pushed back repeatedly. It's currently "On Deck" which means we don't have a definite target Milestone yet. The best case might be September, but it certainly could be delayed further.
gchen88 commentedon Sep 14, 2022
ran across this Issue. also interested. any good news yet?
sean-mcmanus commentedon Sep 15, 2022
@lifo888 No news. I don't have an ETA.
yne commentedon Jan 2, 2023
Here is a standalone working example of a glob walker
show
It allow partial matching, for example :
and can be used as drop-in replacement of
resolveAndSplit()in~/.vscode/extensions/ms-vscode.cpptools-*/dist/main.js:Tell me if you have any use-case that doesn't work
Bob Brown (@bobbrow) I'm currently following the CONTRIBUTING.md in order to send you a PR. Is that okay for you ?
sean-mcmanus commentedon Jan 3, 2023
Rémy F. (@yne) Sure, can you submit a PR?
yne commentedon Jan 17, 2023
Sean McManus (@sean-mcmanus): I've PR'd a working exemple with
*path support.BillDenton commentedon Jun 29, 2023
Sean McManus (@sean-mcmanus) Slightly confused about the status of this issue and the related issue #10388. What is the status with the latest VS Code 1.79.2 and C/C++ extension v1.16.3? What is the syntax?
Thanks.
sean-mcmanus commentedon Jun 29, 2023
BillDenton It'll be in 1.17.0. Syntax is currently
*for wildcards in the middle of a path.