Changeset View
Changeset View
Standalone View
Standalone View
bin/BuildSystem/BuildSystemBase.py
1 | # | 1 | # | ||
---|---|---|---|---|---|
2 | # copyright (c) 2009 Ralf Habacker <ralf.habacker@freenet.de> | 2 | # copyright (c) 2009 Ralf Habacker <ralf.habacker@freenet.de> | ||
3 | # | 3 | # | ||
4 | 4 | | |||
5 | """ \package BuildSystemBase""" | 5 | """ \package BuildSystemBase""" | ||
6 | import multiprocessing | 6 | import multiprocessing | ||
7 | import os | 7 | import os | ||
8 | import re | 8 | import re | ||
9 | import subprocess | ||||
9 | 10 | | |||
10 | from CraftBase import * | 11 | from CraftBase import * | ||
11 | from CraftOS.osutils import OsUtils | 12 | from CraftOS.osutils import OsUtils | ||
12 | 13 | | |||
13 | 14 | | |||
14 | class BuildSystemBase(CraftBase): | 15 | class BuildSystemBase(CraftBase): | ||
15 | """provides a generic interface for build systems and implements all stuff for all build systems""" | 16 | """provides a generic interface for build systems and implements all stuff for all build systems""" | ||
16 | debug = True | 17 | debug = True | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 105 | def unittest(self): | |||
106 | return True | 107 | return True | ||
107 | 108 | | |||
108 | def ccacheOptions(self): | 109 | def ccacheOptions(self): | ||
109 | return "" | 110 | return "" | ||
110 | 111 | | |||
111 | def clangOptions(self): | 112 | def clangOptions(self): | ||
112 | return "" | 113 | return "" | ||
113 | 114 | | |||
115 | | ||||
116 | def _fixRpath(self, prefix : str, path : str) -> bool: | ||||
117 | with os.scandir(path) as scan: | ||||
118 | for f in scan: | ||||
119 | if f.is_symlink(): | ||||
120 | continue | ||||
121 | elif f.is_dir(): | ||||
122 | if not self._fixRpath(prefix, f.path): | ||||
123 | return False | ||||
124 | elif utils.isBinary(f.path): | ||||
125 | for dep in utils.getLibraryDeps(f.path): | ||||
126 | if dep.startswith(prefix): | ||||
127 | newPrefix = f"@loader_path/{os.path.relpath(self.imageDir(), os.path.dirname(f.path))}/{os.path.relpath(dep, prefix)}" | ||||
128 | if not utils.system(["install_name_tool", "-change", dep, newPrefix, f.path]): | ||||
129 | return False | ||||
130 | return True | ||||
131 | | ||||
114 | def _fixInstallPrefix(self, prefix=CraftStandardDirs.craftRoot()): | 132 | def _fixInstallPrefix(self, prefix=CraftStandardDirs.craftRoot()): | ||
115 | CraftCore.log.debug(f"Begin: fixInstallPrefix {self}: {prefix}") | 133 | CraftCore.log.debug(f"Begin: fixInstallPrefix {self}: {prefix}") | ||
116 | def stripPath(path): | 134 | def stripPath(path): | ||
117 | rootPath = os.path.splitdrive(path)[1] | 135 | rootPath = os.path.splitdrive(path)[1] | ||
118 | if rootPath.startswith(os.path.sep) or rootPath.startswith("/"): | 136 | if rootPath.startswith(os.path.sep) or rootPath.startswith("/"): | ||
119 | rootPath = rootPath[1:] | 137 | rootPath = rootPath[1:] | ||
120 | return rootPath | 138 | return rootPath | ||
121 | badPrefix = os.path.join(self.installDir(), stripPath(prefix)) | 139 | badPrefix = os.path.join(self.installDir(), stripPath(prefix)) | ||
Show All 10 Lines | 145 | if CraftCore.settings.getboolean("QtSDK", "Enabled", False): | |||
132 | if os.path.exists(path) and not os.path.samefile(self.installDir(), path): | 150 | if os.path.exists(path) and not os.path.samefile(self.installDir(), path): | ||
133 | if not utils.mergeTree(path, self.installDir()): | 151 | if not utils.mergeTree(path, self.installDir()): | ||
134 | return False | 152 | return False | ||
135 | 153 | | |||
136 | if stripPath(prefix): | 154 | if stripPath(prefix): | ||
137 | oldPrefix = OsUtils.toUnixPath(stripPath(prefix)).split("/", 1)[0] | 155 | oldPrefix = OsUtils.toUnixPath(stripPath(prefix)).split("/", 1)[0] | ||
138 | utils.rmtree(os.path.join(self.installDir(), oldPrefix)) | 156 | utils.rmtree(os.path.join(self.installDir(), oldPrefix)) | ||
139 | 157 | | |||
158 | if CraftCore.compiler.isMacOS: | ||||
159 | if not self._fixRpath(prefix, self.installDir()): | ||||
160 | return False | ||||
161 | | ||||
140 | CraftCore.log.debug(f"End: fixInstallPrefix {self}") | 162 | CraftCore.log.debug(f"End: fixInstallPrefix {self}") | ||
141 | return True | 163 | return True | ||
142 | 164 | | |||
143 | 165 | | |||
144 | 166 | | |||
145 | def patchInstallPrefix(self, files : [str], oldPaths : [str]=None, newPath : str=CraftCore.standardDirs.craftRoot()) -> bool: | 167 | def patchInstallPrefix(self, files : [str], oldPaths : [str]=None, newPath : str=CraftCore.standardDirs.craftRoot()) -> bool: | ||
146 | if isinstance(oldPaths, str): | 168 | if isinstance(oldPaths, str): | ||
147 | oldPaths = [oldPaths] | 169 | oldPaths = [oldPaths] | ||
Show All 34 Lines |