@@ -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+
137141def 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