541
541
LINUX_SHARED_LIBRARY_EXTENSION = ".so"
542
542
# Path relative to the "Assets" dir of native Linux plugin libraries.
543
543
LINUX_SHARED_LIBRARY_PATH = re .compile (
544
- r"^Plugins{sep}(x86|x86_64){sep}(.*{ext})" .format (
545
- sep = os .path .sep ,
544
+ r"^Plugins/(x86|x86_64)/(.*{ext})" .format (
546
545
ext = LINUX_SHARED_LIBRARY_EXTENSION .replace ("." , r"\." )))
547
546
# Path components required for native desktop libraries.
548
547
SHARED_LIBRARY_PATH = re .compile (
549
- (r"(^|{sep})Plugins{sep}(x86|x86_64){sep}(.*{sep}|)[^{sep}]+"
550
- r"\.(so|dll|bundle)$" ).format (sep = os .path .sep ))
548
+ r"(^|/)Plugins/(x86|x86_64)/(.*/|)[^/]+\.(so|dll|bundle)$" )
551
549
# Prefix of the keywords to be added to UPM manifest to link to legacy manifest.
552
550
UPM_KEYWORDS_MANIFEST_PREFIX = "vh-name:"
553
551
# Everything in a Unity plugin - at the moment - lives under the Assets
570
568
STR_OR_UNICODE = [str ]
571
569
unicode = str # pylint: disable=redefined-builtin,invalid-name
572
570
571
+ def posix_path (path ):
572
+ """Convert path separators to POSIX style.
573
+
574
+ Args:
575
+ path: Path to convert.
576
+
577
+ Returns:
578
+ Path with POSIX separators, i.e / rather than \\ .
579
+ """
580
+ return path .replace ('\\ ' , '/' )
581
+
573
582
574
583
class MissingGuidsError (Exception ):
575
584
"""Raised when GUIDs are missing for input files in export_package().
@@ -638,7 +647,7 @@ def add_guid_and_path(self, guid, path):
638
647
guid: GUID to add to this instance.
639
648
path: Path associated with this GUID.
640
649
"""
641
- self ._paths_by_guid [guid ].add (path )
650
+ self ._paths_by_guid [guid ].add (posix_path ( path ) )
642
651
643
652
def check_for_duplicates (self ):
644
653
"""Check the set of GUIDs for duplicate paths.
@@ -960,7 +969,7 @@ def __init__(self, duplicate_guids_checker, guids_json,
960
969
guid_map = safe_dict_get_value (guids_json , plugin_version ,
961
970
default_value = {})
962
971
for filename , guid in guid_map .items ():
963
- self .add_guid (filename , guid )
972
+ self .add_guid (posix_path ( filename ) , guid )
964
973
965
974
if plugin_version :
966
975
# Aggregate guids for older versions of files.
@@ -983,6 +992,7 @@ def add_guid(self, path, guid):
983
992
path: Path associated with the GUID.
984
993
guid: GUID for the asset at the path.
985
994
"""
995
+ path = posix_path (path )
986
996
self ._guids_by_path [path ] = guid
987
997
self ._duplicate_guids_checker .add_guid_and_path (guid , path )
988
998
@@ -1026,6 +1036,7 @@ def get_guid(self, path):
1026
1036
Raises:
1027
1037
MissingGuidsError: If the GUID isn't found.
1028
1038
"""
1039
+ path = posix_path (path )
1029
1040
guid = self ._guids_by_path .get (path )
1030
1041
if not guid :
1031
1042
raise MissingGuidsError ([path ])
@@ -1108,7 +1119,7 @@ def version_handler_filename(filename, field_value_list):
1108
1119
components .extend ([VERSION_HANDLER_FIELD_SEPARATOR ,
1109
1120
VERSION_HANDLER_FIELD_SEPARATOR .join (fields )])
1110
1121
components .append (extension )
1111
- return "" .join (components )
1122
+ return posix_path ( "" .join (components ) )
1112
1123
1113
1124
1114
1125
class Asset (object ):
@@ -1167,7 +1178,7 @@ def filename(self):
1167
1178
Returns:
1168
1179
Filename string.
1169
1180
"""
1170
- return self ._filename
1181
+ return posix_path ( self ._filename )
1171
1182
1172
1183
@property
1173
1184
def filename_absolute (self ):
@@ -1176,7 +1187,7 @@ def filename_absolute(self):
1176
1187
Returns:
1177
1188
Filename string.
1178
1189
"""
1179
- return self ._filename_absolute
1190
+ return posix_path ( self ._filename_absolute )
1180
1191
1181
1192
@property
1182
1193
def filename_guid_lookup (self ):
@@ -1185,7 +1196,7 @@ def filename_guid_lookup(self):
1185
1196
Returns:
1186
1197
Filename string.
1187
1198
"""
1188
- return self ._filename_guid_lookup
1199
+ return posix_path ( self ._filename_guid_lookup )
1189
1200
1190
1201
@property
1191
1202
def is_folder (self ):
@@ -1239,7 +1250,7 @@ def disable_unsupported_platforms(importer_metadata, filename):
1239
1250
Returns:
1240
1251
Modified importer_metadata.
1241
1252
"""
1242
- filename = os .path .normpath (filename )
1253
+ filename = posix_path ( os .path .normpath (filename ) )
1243
1254
is_shared_library = SHARED_LIBRARY_PATH .search (filename )
1244
1255
if not is_shared_library :
1245
1256
return importer_metadata
@@ -1557,7 +1568,8 @@ def write(self, output_dir, guid, timestamp=-1):
1557
1568
# project.
1558
1569
with open (os .path .join (output_asset_dir , "pathname" ), "wt" ) as (
1559
1570
pathname_file ):
1560
- pathname_file .write (os .path .join (ASSETS_DIRECTORY , self .filename ))
1571
+ pathname_file .write (posix_path (os .path .join (ASSETS_DIRECTORY ,
1572
+ self .filename )))
1561
1573
return output_asset_dir
1562
1574
1563
1575
def write_upm (self , output_dir , guid , timestamp = - 1 ):
@@ -2331,7 +2343,8 @@ def write_manifest(self, output_dir, assets):
2331
2343
os .makedirs (manifest_directory )
2332
2344
with open (manifest_absolute_path , "wt" ) as manifest_file :
2333
2345
manifest_file .write (
2334
- "%s\n " % "\n " .join ([os .path .join (ASSETS_DIRECTORY , asset .filename )
2346
+ "%s\n " % "\n " .join ([posix_path (os .path .join (ASSETS_DIRECTORY ,
2347
+ asset .filename ))
2335
2348
for asset in Asset .sorted_by_filename (assets )]))
2336
2349
# Retrieve a template manifest asset if it exists.
2337
2350
manifest_asset = [asset for asset in assets
@@ -3295,7 +3308,7 @@ def copy_files_to_dir(colon_separated_input_output_filenames,
3295
3308
copied_files = []
3296
3309
for additional_file in colon_separated_input_output_filenames :
3297
3310
additional_file_args = additional_file .split (":" )
3298
- input_filename = additional_file_args [0 ]
3311
+ input_filename = posix_path ( additional_file_args [0 ])
3299
3312
3300
3313
# Get the output filename.
3301
3314
output_filename = input_filename
@@ -3306,11 +3319,11 @@ def copy_files_to_dir(colon_separated_input_output_filenames,
3306
3319
# Remove the drive or root directory from the output filename.
3307
3320
if os .path .normpath (output_filename ).startswith (os .path .sep ):
3308
3321
output_filename = output_filename [len (os .path .sep ):]
3309
- output_filename = os .path .join (output_dir , output_filename )
3322
+ output_filename = posix_path ( os .path .join (output_dir , output_filename ) )
3310
3323
3311
3324
# Copy the file to the output directory.
3312
3325
copy_and_set_rwx (input_filename , output_filename )
3313
- copied_files .append (output_filename )
3326
+ copied_files .append (posix_path ( output_filename ) )
3314
3327
return copied_files
3315
3328
3316
3329
0 commit comments