From e94a883804ecd6aebd2da110723d84059fe9740f Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Sun, 23 Jan 2022 08:40:46 -0800 Subject: [PATCH] Fix file embedding tests under windows that were broken by #16050 --- .circleci/config.yml | 2 +- tools/file_packager.py | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dfa1363942cb6..e58a9545c15a8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -444,7 +444,7 @@ jobs: # note we do *not* build all libraries and freeze the cache; as we run # only limited tests here, it's more efficient to build on demand - run-tests: - test_targets: "other.test_emcc_cflags other.test_stdin other.test_bad_triple core2.test_sse1 core2.test_ccall other.test_closure_externs other.test_binaryen_debug other.test_js_optimizer_parse_error other.test_output_to_nowhere other.test_emcc_dev_null other.test_cmake* other.test_system_include_paths other.test_emar_response_file core2.test_utf16 other.test_special_chars_in_arguments other.test_toolchain_profiler other.test_realpath_nodefs other.test_response_file_encoding other.test_libc_progname" + test_targets: "other.test_emcc_cflags other.test_stdin other.test_bad_triple core2.test_sse1 core2.test_ccall other.test_closure_externs other.test_binaryen_debug other.test_js_optimizer_parse_error other.test_output_to_nowhere other.test_emcc_dev_null other.test_cmake* other.test_system_include_paths other.test_emar_response_file core2.test_utf16 other.test_special_chars_in_arguments other.test_toolchain_profiler other.test_realpath_nodefs other.test_response_file_encoding other.test_libc_progname other.test_realpath other.test_embed_file_dup" test-mac: executor: mac environment: diff --git a/tools/file_packager.py b/tools/file_packager.py index 3eaaf2b1259b8..a05c9513fdb66 100755 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -134,6 +134,10 @@ def err(*args): print(*args, file=sys.stderr) +def to_unix_path(p): + return p.replace(os.path.sep, '/') + + def base64_encode(b): b64 = base64.b64encode(b) return b64.decode('ascii') @@ -265,18 +269,19 @@ def generate_object_file(data_files): err('embedding %s at %s' % (f.srcpath, f.dstpath)) size = os.path.getsize(f.srcpath) - name = to_asm_string(f.dstpath) + dstpath = to_asm_string(f.dstpath) + srcpath = to_unix_path(f.srcpath) out.write(dedent(f''' .section .rodata.{f.c_symbol_name},"",@ # The name of file {f.c_symbol_name}_name: - .asciz "{name}" - .size {f.c_symbol_name}_name, {len(name)+1} + .asciz "{dstpath}" + .size {f.c_symbol_name}_name, {len(dstpath)+1} # The size of the file followed by the content itself {f.c_symbol_name}: - .incbin "{f.srcpath}" + .incbin "{srcpath}" .size {f.c_symbol_name}, {size} ''')) @@ -462,7 +467,7 @@ def main(): for file_ in data_files: # name in the filesystem, native and emulated - file_.dstpath = file_.dstpath.replace(os.path.sep, '/') + file_.dstpath = to_unix_path(file_.dstpath) # If user has submitted a directory name as the destination but omitted # the destination filename, use the filename from source file if file_.dstpath.endswith('/'):