diff --git a/emcc.py b/emcc.py index f770f4a539b06..dddbdb197cb4f 100644 --- a/emcc.py +++ b/emcc.py @@ -265,7 +265,11 @@ def main(args): print_file_name = [a for a in args if a.startswith(('-print-file-name=', '--print-file-name='))] if print_file_name: libname = print_file_name[-1].split('=')[1] - system_libpath = cache.get_lib_dir(absolute=True) + resource_dir = [a for a in args if a.startswith(('-resource-dir=', '--resource-dir='))] + if resource_dir: + system_libpath = resource_dir[-1].split('=')[1] + else: + system_libpath = cache.get_lib_dir(absolute=True) fullpath = os.path.join(system_libpath, libname) if os.path.isfile(fullpath): print(fullpath) diff --git a/test/test_other.py b/test/test_other.py index b833da904979b..8b4bb8fe182be 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -776,6 +776,14 @@ def test_print_file_name(self, args): settings.MEMORY64 = int('-m64' in args) self.assertContained(cache.get_lib_name('libc.a'), str(filename)) + @crossplatform + def test_print_file_name_with_resource_dir(self): + file = Path(EMCC).name + output = self.run_process([EMCC, f'-print-file-name={file}'], stdout=PIPE).stdout + output_relative = self.run_process([EMCC, '-resource-dir=' + path_from_root(), f'-print-file-name={file}'], stdout=PIPE).stdout + self.assertNotExists(output.rstrip()) + self.assertExists(output_relative.rstrip()) + def test_emar_em_config_flag(self): # Test that the --em-config flag is accepted but not passed down do llvm-ar. # We expand this in case the EM_CONFIG is ~/.emscripten (default)