MCPcopy Create free account
hub / github.com/nodejs/node / MakePathRelative

Function MakePathRelative

tools/gyp/pylib/gyp/input.py:2164–2198  ·  view source on GitHub ↗
(to_file, fro_file, item)

Source from the content-addressed store, hash-verified

2162
2163
2164def MakePathRelative(to_file, fro_file, item):
2165 # If item is a relative path, it's relative to the build file dict that it's
2166 # coming from. Fix it up to make it relative to the build file dict that
2167 # it's going into.
2168 # Exception: any |item| that begins with these special characters is
2169 # returned without modification.
2170 # / Used when a path is already absolute (shortcut optimization;
2171 # such paths would be returned as absolute anyway)
2172 # $ Used for build environment variables
2173 # - Used for some build environment flags (such as -lapr-1 in a
2174 # "libraries" section)
2175 # < Used for our own variable and command expansions (see ExpandVariables)
2176 # > Used for our own variable and command expansions (see ExpandVariables)
2177 # ^ Used for our own variable and command expansions (see ExpandVariables)
2178 #
2179 # "/' Used when a value is quoted. If these are present, then we
2180 # check the second character instead.
2181 #
2182 if to_file == fro_file or exception_re.match(item):
2183 return item
2184 else:
2185 # TODO(dglazkov) The backslash/forward-slash replacement at the end is a
2186 # temporary measure. This should really be addressed by keeping all paths
2187 # in POSIX until actual project generation.
2188 ret = os.path.normpath(
2189 os.path.join(
2190 gyp.common.RelativePath(
2191 os.path.dirname(fro_file), os.path.dirname(to_file)
2192 ),
2193 item,
2194 )
2195 ).replace("\\", "/")
2196 if item.endswith("/"):
2197 ret += "/"
2198 return ret
2199
2200
2201def MergeLists(to, fro, to_file, fro_file, is_paths=False, append=True):

Callers 2

MergeListsFunction · 0.85
MergeDictsFunction · 0.85

Calls 2

matchMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected