MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / resolve

Method resolve

tools/wasm-sourcemap.py:69–97  ·  view source on GitHub ↗
(self, name)

Source from the content-addressed store, hash-verified

67 self.cache = {}
68
69 def resolve(self, name):
70 if name in self.cache:
71 return self.cache[name]
72
73 source = name
74 if not self.preserve_deterministic_prefix and name.startswith(DETERMINISTIC_PREFIX):
75 source = EMSCRIPTEN_PREFIX + name.removeprefix(DETERMINISTIC_PREFIX)
76
77 provided = False
78 for p in self.prefixes:
79 if source.startswith(p['prefix']):
80 source = p['replacement'] + source.removeprefix(p['prefix'])
81 provided = True
82 break
83
84 # If prefixes were provided, we use that; otherwise if base_path is set, we
85 # emit a relative path. For files with deterministic prefix, we never use
86 # a relative path, precisely to preserve determinism, and because it would
87 # still point to the wrong location, so we leave the filepath untouched to
88 # let users map it to the proper location using prefix options.
89 if not (source.startswith(DETERMINISTIC_PREFIX) or provided or self.base_path is None):
90 try:
91 source = os.path.relpath(source, self.base_path)
92 except ValueError:
93 source = os.path.abspath(source)
94 source = utils.normalize_path(source)
95
96 self.cache[name] = source
97 return source
98
99
100# SourceMapPrefixes contains resolver for file names that are:

Callers 15

build_sourcemapFunction · 0.80
removeRunDependencyFunction · 0.80
FS_preloadFileFunction · 0.80
symlinkFunction · 0.80
naFunction · 0.80
libbrowser.jsFile · 0.80
libdylink.jsFile · 0.80
loadLibDataFunction · 0.80
getExportsFunction · 0.80
libnodepath.jsFile · 0.80

Calls

no outgoing calls

Tested by 1