Skip to content
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

Add support for parsing non-unix paths in compilation database #716

Merged

Conversation

papadokolos
Copy link
Contributor

@papadokolos papadokolos commented Aug 7, 2020

The parsing mode (posix vs non-posix) is selected automatically by checking if the OS in which ECC is currently running supports posix. Otherwise, shlex would not treat windows paths correctly (treating them as posix paths).

Here is an example for such a generated compilation database:
[
{
  "directory": "C:/Users/Secret/AppData/Local/Temp/EasyClangComplete/cmake_builds/afeee6ac216a4e3cad7a41f5cf6958c1",
  "command": "C:\\PROGRA~1\\LLVM\\bin\\CLANG_~1.EXE    -target i686-pc-windows-gnu -g   -Wall -Wextra -Wpedantic -Werror -std=c++14 -o CMakeFiles\\space-age.dir\\space_age_test.cpp.obj -c C:\\Users\\Secret\\Exercism\\cpp\\space-age\\space_age_test.cpp",
  "file": "C:/Users/Secret/Exercism/cpp/space-age/space_age_test.cpp"
},
{
  "directory": "C:/Users/Secret/AppData/Local/Temp/EasyClangComplete/cmake_builds/afeee6ac216a4e3cad7a41f5cf6958c1",
  "command": "C:\\PROGRA~1\\LLVM\\bin\\CLANG_~1.EXE    -target i686-pc-windows-gnu -g   -Wall -Wextra -Wpedantic -Werror -std=c++14 -o CMakeFiles\\space-age.dir\\space_age.cpp.obj -c C:\\Users\\Secret\\Exercism\\cpp\\space-age\\space_age.cpp",
  "file": "C:/Users/Secret/Exercism/cpp/space-age/space_age.cpp"
},
{
  "directory": "C:/Users/Secret/AppData/Local/Temp/EasyClangComplete/cmake_builds/afeee6ac216a4e3cad7a41f5cf6958c1",
  "command": "C:\\PROGRA~1\\LLVM\\bin\\CLANG_~1.EXE    -target i686-pc-windows-gnu -g   -Wall -Wextra -Wpedantic -Werror -std=c++14 -o CMakeFiles\\space-age.dir\\test\\tests-main.cpp.obj -c C:\\Users\\Secret\\Exercism\\cpp\\space-age\\test\\tests-main.cpp",
  "file": "C:/Users/Secret/Exercism/cpp/space-age/test/tests-main.cpp"
}
]

By doing this, I assume that non-posix operating systems will generate compilation database that has non-posix paths (this was my case when running ECC on Windows).

Implementation note: I chose os.name over platform.system() based on this and this.

Related to #712

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
This is selected automatically by checking the OS in which ECC is
running. Without this, `shlex` would not treat windows paths correctly.
@niosus
Copy link
Owner

niosus commented Dec 8, 2020

Sounds reasonable. Thanks!

@niosus niosus merged commit 13b2c5b into niosus:master Dec 8, 2020
@papadokolos papadokolos deleted the support_compilation_db_with_windows_path branch January 8, 2021 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants