Changeset View
Changeset View
Standalone View
Standalone View
bin/utils.py
Show First 20 Lines • Show All 852 Lines • ▼ Show 20 Line(s) | 852 | for args in limitCommandLineLength(command, fileNames): | |||
---|---|---|---|---|---|
853 | if not system(args): | 853 | if not system(args): | ||
854 | return False | 854 | return False | ||
855 | return True | 855 | return True | ||
856 | 856 | | |||
857 | def isBinary(fileName : str) -> bool: | 857 | def isBinary(fileName : str) -> bool: | ||
858 | # https://en.wikipedia.org/wiki/List_of_file_signatures | 858 | # https://en.wikipedia.org/wiki/List_of_file_signatures | ||
859 | fileName = Path(fileName) | 859 | fileName = Path(fileName) | ||
860 | MACH_O_64 = b"\xCF\xFA\xED\xFE" | 860 | MACH_O_64 = b"\xCF\xFA\xED\xFE" | ||
861 | ELF = b"\x7F\x45\x4C\x46" | ||||
861 | if fileName.is_symlink() or fileName.is_dir(): | 862 | if fileName.is_symlink() or fileName.is_dir(): | ||
862 | return False | 863 | return False | ||
863 | if CraftCore.compiler.isWindows: | 864 | if CraftCore.compiler.isWindows: | ||
864 | if fileName.suffix in {".dll", ".exe"}: | 865 | if fileName.suffix in {".dll", ".exe"}: | ||
865 | return True | 866 | return True | ||
866 | else: | 867 | else: | ||
867 | if CraftCore.compiler.isMacOS and ".dSYM/" in str(fileName): | 868 | if CraftCore.compiler.isMacOS and ".dSYM/" in str(fileName): | ||
868 | return False | 869 | return False | ||
869 | if fileName.suffix in {".so", ".dylib"}: | 870 | if fileName.suffix in {".so", ".dylib"}: | ||
870 | return True | 871 | return True | ||
871 | elif os.access(fileName, os.X_OK): | 872 | elif os.access(fileName, os.X_OK): | ||
872 | signature = None | | |||
873 | if CraftCore.compiler.isMacOS: | 873 | if CraftCore.compiler.isMacOS: | ||
874 | signature = MACH_O_64 | 874 | signature = MACH_O_64 | ||
875 | if signature: | 875 | elif CraftCore.compiler.isLinux: | ||
876 | with open(fileName, "rb") as f: | 876 | signature = ELF | ||
877 | return f.read(len(signature)) == signature | 877 | else: | ||
878 | raise Exception("Unsupported platform") | ||||
879 | with open(fileName, "rb") as f: | ||||
880 | return f.read(len(signature)) == signature | ||||
878 | return False | 881 | return False | ||
879 | 882 | | |||
880 | 883 | | |||
881 | def getLibraryDeps(path): | 884 | def getLibraryDeps(path): | ||
882 | deps = [] | 885 | deps = [] | ||
883 | if CraftCore.compiler.isMacOS: | 886 | if CraftCore.compiler.isMacOS: | ||
884 | # based on https://github.com/qt/qttools/blob/5.11/src/macdeployqt/shared/shared.cpp | 887 | # based on https://github.com/qt/qttools/blob/5.11/src/macdeployqt/shared/shared.cpp | ||
885 | infoRe = re.compile("^\\t(.+) \\(compatibility version (\\d+\\.\\d+\\.\\d+), "+ | 888 | infoRe = re.compile("^\\t(.+) \\(compatibility version (\\d+\\.\\d+\\.\\d+), "+ | ||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |