Support for Posix shell emulation (MSYS, Cygwin) pathname conven…#110
Open
andrewstevens-infineon wants to merge 4 commits into
Open
Support for Posix shell emulation (MSYS, Cygwin) pathname conven…#110andrewstevens-infineon wants to merge 4 commits into
andrewstevens-infineon wants to merge 4 commits into
Conversation
|
Hey, I've tested this PR against MSYS2 on my Windows 10 machine. I liked the overall approach you took. However, there are some edge cases that needs to be handled and improvements to be made.
The first issue NEEDS to be handled otherwise the program crashes :/ Thanks again for the PR ☀️ |
|
Uhm…isn't it cleaner just to unconditionally strip away msys/cygwin stuff at the very end? At least that is what I had before I saw this PR. diff --git a/compiledb/parser.py b/compiledb/parser.py
index 9f4c550..2f9f31b 100755
--- a/compiledb/parser.py
+++ b/compiledb/parser.py
@@ -18,6 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+import sys
import bashlex
import re
import logging
@@ -152,6 +153,9 @@ def parse_build_log(build_log, proj_dir, exclude_files, command_style=False, add
logger.debug("Adding command {}: {}".format(len(result.compdb), command_str))
+ if sys.platform == 'win32':
+ working_dir = re.sub(r'^(?:/mnt|/cygdrive)?/([a-zA-Z])/', r'\1:/', working_dir)
+
if command_style:
result.compdb.append({
'directory': working_dir, |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The final pasting of working dir and captured filenames from make output uses python native pathname joining. This cannot allow for the special pathname conventions Posix shell environments (MSYS, cygwin) use to handle Windows drive-letters.
This PR allows the shell environment being used to be specified and adjusts pathname pasting to create a legal Windows pathname.