question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: Environment variable for using source file's current folder in `common_flags`

See original GitHub issue

We have these options to define include dirs in the plugin settings:

  // Every path variable in settings can contain wildcards (without the ""):
  //  - "$project_base_path"  <-- replaced by the full path to the project to
  //                              which the currently opened view belongs.
  //  - "$project_name"       <-- replaced by the name of the current project.
  //  - "$clang_version"      <-- replaced by the numeric version of used clang.
  //  - "~"                   <-- replaced by the path to user home directory.
  //
  //  In addition to these, you can use your environment variables:
  //  - OSX and Linux:  $variable_name or ${variable_name}
  //  - Windows:        $variable_name or ${variable_name} or %variable_name%

  // Specify common flags that will be passed to clang for EVERY build.
  "common_flags" : [
    // some example includes
    "-I/usr/include",
    "-I$project_base_path/src",
    // this is needed to include the correct headers for clang
    "-I/usr/lib/clang/$clang_version/include"
  ],

If you use Sublime that your Opened Project folder (D:\www) is where all of your dev projects stored (i.e. lots of subfolders where your real projects reside, for example: D:\www\cpp\asio, D:\www\node\koa, D:\www\html\personal-portfolio, etc.), so these environment variables:

    "-I$project_base_path/src",
    "-I$project_base_path/include",
    "-I%cd%/include",

Simply not giving you the desired paths. Also, the windows environment variable like %cd% simply didn’t included in the verbose output that I included below (probably this also can be MSYS2 issue, because clang insalled in that, not native MSVC version). $project_base_path is just a confusing name, because you expect to get your current folder where your source .cpp files resides for linting, but instead you got:

DEBUG:EasyClangComplete.plugin.settings.settings_storage: populated '-I$project_base_path/src' to '-ID:\www/src'
DEBUG:EasyClangComplete.plugin.settings.settings_storage: populated '-I$project_base_path/include' to '-ID:\www/include'
DEBUG:EasyClangComplete.plugin.settings.settings_storage: populated '-I/usr/lib/clang/$clang_version/include' to '-I/usr/lib/clang/3.9.1/include'

But what should I want to have, if you open a .cpp file at D:\www\cpp\asio\src\main.cpp location, these lines should be:

DEBUG:EasyClangComplete.plugin.settings.settings_storage: populated '-I$current_path/include' to '-ID:\www\cpp\asio\src\include'

Something like $current_path would be nice to have, if the Windows environment variables doesn’t work thanks to MSYS2, Cygwin, compatibility issues. I think it’s not impossible because these lines already giving the desired paths:

DEBUG:EasyClangComplete.plugin.tools: searching 'CMakeLists.txt' from 'D:\www\cpp\asio\src' to 'D:\\www'
DEBUG:EasyClangComplete.plugin.tools: searching 'compile_commands.json' from 'D:\www\cpp\asio\src' to 'D:\\www'
DEBUG:EasyClangComplete.plugin.tools: searching '.clang_complete' from 'D:\www\cpp\asio\src' to 'D:\\www'

For many starters like me who learning C++, dealing with Cmake is just utterly confusing, that’s why would be much simpler to have an option like $current_path in EasyClangComplete.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
simiacommented, Jan 31, 2017

Have you tried using .clang_complete file? I am not sure what your problem exactly is but you could do something like this: D:\www\P1\ .clang_complete D:\www\P2\ .clang_complete D:\www\P3\ .clang_complete

Then when working on file in P1 you would use includes from P1\ .clang_complete etc.

0reactions
sus007commented, Mar 5, 2018

Wow, I did the opposite. 😁 I left VSCode in favor of Sublime Text since VSCode consumed way too much memory for me. I hope @simia still uses Sublime.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Allow environment variables to configure SAM cli flags #637
Regarding the --template[-file] , all commands but package and deploy default to [default: template.[yaml|yml]] in the current working directory ...
Read more >
Set environment variables from file of key/value pairs
Enable exporting of all declared variables in the sources script to the environment. Read .env file. All variables will be exported into current...
Read more >
Environment variables - IBM
A mandatory environment variable that points to the Target Deployment Port directory when you are using the product in the command line interface....
Read more >
How To View and Update the Linux PATH Environment Variable
The PATH variable contains a list of directories the system checks ... To apply the changes to the current session, use the source...
Read more >
Frequently Asked Questions - 1.36.0 - Boost C++ Libraries
Accessing environment variables. Many users would like to use environment variables in Jamfiles, for example, to control location of external libraries. In many ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found