Skip to content

Commit 6531264

Browse files
authored
Fix file embedding tests under windows that were broken by #16050 (#16102)
1 parent bc4ffdf commit 6531264

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ jobs:
444444
# note we do *not* build all libraries and freeze the cache; as we run
445445
# only limited tests here, it's more efficient to build on demand
446446
- run-tests:
447-
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"
447+
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"
448448
test-mac:
449449
executor: mac
450450
environment:

tools/file_packager.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ def err(*args):
134134
print(*args, file=sys.stderr)
135135

136136

137+
def to_unix_path(p):
138+
return p.replace(os.path.sep, '/')
139+
140+
137141
def base64_encode(b):
138142
b64 = base64.b64encode(b)
139143
return b64.decode('ascii')
@@ -265,18 +269,19 @@ def generate_object_file(data_files):
265269
err('embedding %s at %s' % (f.srcpath, f.dstpath))
266270

267271
size = os.path.getsize(f.srcpath)
268-
name = to_asm_string(f.dstpath)
272+
dstpath = to_asm_string(f.dstpath)
273+
srcpath = to_unix_path(f.srcpath)
269274
out.write(dedent(f'''
270275
.section .rodata.{f.c_symbol_name},"",@
271276
272277
# The name of file
273278
{f.c_symbol_name}_name:
274-
.asciz "{name}"
275-
.size {f.c_symbol_name}_name, {len(name)+1}
279+
.asciz "{dstpath}"
280+
.size {f.c_symbol_name}_name, {len(dstpath)+1}
276281
277282
# The size of the file followed by the content itself
278283
{f.c_symbol_name}:
279-
.incbin "{f.srcpath}"
284+
.incbin "{srcpath}"
280285
.size {f.c_symbol_name}, {size}
281286
'''))
282287

@@ -462,7 +467,7 @@ def main():
462467

463468
for file_ in data_files:
464469
# name in the filesystem, native and emulated
465-
file_.dstpath = file_.dstpath.replace(os.path.sep, '/')
470+
file_.dstpath = to_unix_path(file_.dstpath)
466471
# If user has submitted a directory name as the destination but omitted
467472
# the destination filename, use the filename from source file
468473
if file_.dstpath.endswith('/'):

0 commit comments

Comments
 (0)