Commit 5b297bf8 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Fix PathManager to work on Windows

posixpath.abspath("d:\\a\\b") doesn't work because posixpath
doesn't recognize a drive letter.  This patch fixes the issue.

Bug: 839389
Change-Id: Ifef644dd1e9b26e6a4e572f485e7cbabf7148871
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2010751
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733376}
parent 53513b6a
......@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os.path
import posixpath
import web_idl
......@@ -14,8 +15,14 @@ class PathManager(object):
"""
Provides a variety of paths such as Blink headers and output files. Unless
explicitly specified, returned paths are relative to the project's root
directory or the root directory of generated files.
e.g. "third_party/blink/renderer/..."
directory or the root directory of generated files, e.g.
"third_party/blink/renderer/..."
Relative paths are represented in POSIX style so that it fits nicely in
generated code, e.g. #include "third_party/blink/renderer/...", while
absolute paths are represented in a platform-specific style so that it works
well with a platform-specific notion, e.g. a drive letter in Windows path
such as "C:\\chromium\\src\\...".
About output files, there are two cases.
- cross-components case:
......@@ -47,8 +54,8 @@ class PathManager(object):
cls._blink_path_prefix = posixpath.sep + posixpath.join(
"third_party", "blink", "renderer", "")
cls._root_src_dir = posixpath.abspath(root_src_dir)
cls._root_gen_dir = posixpath.abspath(root_gen_dir)
cls._root_src_dir = os.path.abspath(root_src_dir)
cls._root_gen_dir = os.path.abspath(root_gen_dir)
cls._component_reldirs = {
component: posixpath.normpath(rel_dir)
for component, rel_dir in component_reldirs.iteritems()
......@@ -62,8 +69,7 @@ class PathManager(object):
directory of generated files.
"""
assert PathManager._is_initialized, PathManager._REQUIRE_INIT_MESSAGE
return posixpath.abspath(
posixpath.join(PathManager._root_gen_dir, path))
return os.path.abspath(os.path.join(PathManager._root_gen_dir, path))
@classmethod
def relpath_to_project_root(cls, path):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment