MCPcopy Create free account
hub / github.com/defold/defold / remove_platform_files_from_archive

Function remove_platform_files_from_archive

editor/scripts/bundle.py:403–497  ·  view source on GitHub ↗
(platform, jar, jdk=None)

Source from the content-addressed store, hash-verified

401 return ".exe" if 'win32' in platform else ""
402
403def remove_platform_files_from_archive(platform, jar, jdk=None):
404 start_time = time.perf_counter()
405 zin = zipfile.ZipFile(jar, 'r')
406 files = zin.namelist()
407 files_to_remove = set()
408
409 # find files to remove from libexec/*
410 libexec_platform = "libexec/" + platform
411 _unpack_platform = "_unpack/" + platform
412 for file in files:
413 if file.startswith("libexec"):
414 # don't remove any folders
415 if file.endswith("/"):
416 continue
417 # don't touch anything for the current platform
418 if file.startswith(libexec_platform):
419 continue
420 # don't touch any of the dmengine files
421 if "dmengine" in file:
422 continue
423 # don't remove the cross-platform bundletool-all.jar
424 if "bundletool-all.jar" in file:
425 continue
426 # keep Android VkQuality native libraries; Bob needs these when bundling
427 # Vulkan-enabled Android apps from any desktop editor.
428 if file in REQUIRED_ANDROID_VKQUALITY_FILES:
429 continue
430 # anything else should be removed
431 files_to_remove.add(file)
432 # keep files needed only for this particular platform (+ shared files in '_defold' and 'shared')
433 if file.startswith("_unpack"):
434 # don't touch '_unpack/'
435 if file == "_unpack/":
436 continue
437 # don't touch anything for the current platform
438 if file.startswith(_unpack_platform):
439 continue
440 # keep shared files
441 if file.startswith("_unpack/shared"):
442 continue
443 # keep _defold folder
444 if file.startswith("_unpack/_defold"):
445 continue
446 # anything else should be removed
447 files_to_remove.add(file)
448
449
450 # find libs to remove in the root folder
451 for file in files:
452 if "/" not in file:
453 if platform in ["x86_64-macos", "arm64-macos"] and (file.endswith(".so") or file.endswith(".dll")):
454 files_to_remove.add(file)
455 elif platform in ["x86_64-win32"] and (file.endswith(".so") or file.endswith(".dylib")):
456 files_to_remove.add(file)
457 elif platform in ["x86_64-linux", "arm64-linux"] and (file.endswith(".dll") or file.endswith(".dylib")):
458 files_to_remove.add(file)
459
460 # Always rewrite the jar here, even when Leiningen already excluded all

Callers 1

create_bundleFunction · 0.85

Calls 9

setFunction · 0.85
invoke_zip_parallelFunction · 0.85
logFunction · 0.70
addMethod · 0.65
closeMethod · 0.65
existsMethod · 0.65
removeMethod · 0.65
namelistMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected