Changeset View
Changeset View
Standalone View
Standalone View
bin/CraftSetupHelper.py
Show First 20 Lines • Show All 206 Lines • ▼ Show 20 Line(s) | 206 | self.addEnvVar("XDG_CONFIG_HOME", | |||
---|---|---|---|---|---|
207 | os.path.join(CraftStandardDirs.craftRoot(), "home", os.getenv("USER"), ".config")) | 207 | os.path.join(CraftStandardDirs.craftRoot(), "home", os.getenv("USER"), ".config")) | ||
208 | self.addEnvVar("XDG_CACHE_HOME", | 208 | self.addEnvVar("XDG_CACHE_HOME", | ||
209 | os.path.join(CraftStandardDirs.craftRoot(), "home", os.getenv("USER"), ".cache")) | 209 | os.path.join(CraftStandardDirs.craftRoot(), "home", os.getenv("USER"), ".cache")) | ||
210 | 210 | | |||
211 | def _setupUnix(self): | 211 | def _setupUnix(self): | ||
212 | self.prependEnvVar("LD_LIBRARY_PATH", [os.path.join(CraftStandardDirs.craftRoot(), "lib"), | 212 | self.prependEnvVar("LD_LIBRARY_PATH", [os.path.join(CraftStandardDirs.craftRoot(), "lib"), | ||
213 | os.path.join(CraftStandardDirs.craftRoot(), "lib", "x86_64-linux-gnu")]) | 213 | os.path.join(CraftStandardDirs.craftRoot(), "lib", "x86_64-linux-gnu")]) | ||
214 | if OsUtils.isMac(): | 214 | if OsUtils.isMac(): | ||
215 | self.prependEnvVar("DYLD_LIBRARY_PATH", [os.path.join(CraftStandardDirs.craftRoot(), "lib")]) | 215 | self._setupMac() | ||
216 | | ||||
217 | def _setupMac(self): | ||||
218 | self.prependEnvVar("DYLD_LIBRARY_PATH", [os.path.join(CraftStandardDirs.craftRoot(), "lib")]) | ||||
219 | brewPath = shutil.which("brew") | ||||
220 | if brewPath: | ||||
221 | log("Found brew: " + shutil.which("brew")) | ||||
222 | if CraftCore.settings.getboolean("Homebrew", "Enabled", brewPath is not None): | ||||
223 | log("Using homebrew packages. To disable set `Enabled = false` in the [Homebrew] group") | ||||
224 | _, prefix = self._getOutput(["brew", "--prefix"]) | ||||
225 | if not prefix: | ||||
226 | prefix = "/usr/local" | ||||
227 | for lib in ("gettext", "libarchive", "openssl@1.1"): | ||||
228 | if not CraftCore.settings.getboolean("Homebrew", "use-" + lib, True): | ||||
229 | continue | ||||
230 | installDir = os.path.join(prefix, "opt", lib) | ||||
231 | self.prependEnvVar("CMAKE_LIBRARY_PATH", os.path.join(installDir, "lib")) | ||||
232 | self.prependEnvVar("CMAKE_INCLUDE_PATH", os.path.join(installDir, "include")) | ||||
233 | self.prependEnvVar("PKG_CONFIG_PATH", os.path.join(installDir, "lib/pkgconfig")) | ||||
234 | log("Using homebrew library " + lib + ": " + installDir) | ||||
235 | | ||||
236 | if CraftCore.settings.getboolean("Homebrew", "use-bison", True): | ||||
237 | bisonPath = os.path.join(prefix, "opt/bison/bin") | ||||
238 | self.prependEnvVar("PATH", bisonPath) | ||||
239 | log("Using bison from homebrew: " + bisonPath) | ||||
240 | | ||||
241 | qtOption = CraftCore.settings.get("Homebrew", "qt", "disabled") | ||||
242 | if qtOption != "disabled": | ||||
243 | log("Using qt (" + qtOption + ") from homebrew packages. " | ||||
244 | " To disable set `qt = disabled` in the [Homebrew] group") | ||||
245 | self.prependEnvVar("PATH", os.path.join(prefix, "opt/bison/bin")) | ||||
246 | if qtOption == "latest": | ||||
247 | qtPath = os.path.join(prefix, "opt/qt5/") | ||||
248 | else: | ||||
249 | _, cellar = self._getOutput(["brew", "--cellar", "qt5"]) | ||||
250 | qtPath = os.path.join(cellar, qtOption) | ||||
251 | if not os.path.isdir(qtPath): | ||||
252 | log("Error: Homebrew/qt = '" + qtOption + "' but " + qtPath + " does not exist") | ||||
253 | exit(1) | ||||
254 | log("Found homebrew Qt5 in " + qtPath) | ||||
255 | self.prependEnvVar("PATH", os.path.join(qtPath, "bin")) | ||||
256 | | ||||
257 | else: | ||||
258 | log("Not using qt from homebrew packages. " | ||||
259 | "To enable set `use-qt = <version>/latest` in the [Homebrew] group") | ||||
260 | log("\n") | ||||
216 | 261 | | |||
217 | def _setupWin(self): | 262 | def _setupWin(self): | ||
218 | if not "HOME" in os.environ: | 263 | if not "HOME" in os.environ: | ||
219 | self.addEnvVar("HOME", os.getenv("USERPROFILE")) | 264 | self.addEnvVar("HOME", os.getenv("USERPROFILE")) | ||
220 | 265 | | |||
221 | | ||||
222 | if CraftCore.settings.getboolean("QtSDK", "Enabled", "false"): | 266 | if CraftCore.settings.getboolean("QtSDK", "Enabled", "false"): | ||
223 | self.prependEnvVar("PATH", | 267 | self.prependEnvVar("PATH", | ||
224 | os.path.join(CraftCore.settings.get("QtSDK", "Path"), CraftCore.settings.get("QtSDK", "Version"), | 268 | os.path.join(CraftCore.settings.get("QtSDK", "Path"), CraftCore.settings.get("QtSDK", "Version"), | ||
225 | CraftCore.settings.get("QtSDK", "Compiler"), "bin")) | 269 | CraftCore.settings.get("QtSDK", "Compiler"), "bin")) | ||
226 | 270 | | |||
227 | if CraftCore.compiler.isMinGW(): | 271 | if CraftCore.compiler.isMinGW(): | ||
228 | if not CraftCore.settings.getboolean("QtSDK", "Enabled", "false"): | 272 | if not CraftCore.settings.getboolean("QtSDK", "Enabled", "false"): | ||
229 | if CraftCore.compiler.isX86(): | 273 | if CraftCore.compiler.isX86(): | ||
Show All 34 Lines | 299 | def setupEnvironment(self): | |||
264 | 308 | | |||
265 | if CraftCore.settings.getboolean("Compile", "UseCCache", False): | 309 | if CraftCore.settings.getboolean("Compile", "UseCCache", False): | ||
266 | self.addEnvVar("CCACHE_DIR", | 310 | self.addEnvVar("CCACHE_DIR", | ||
267 | CraftCore.settings.get("Paths", "CCACHE_DIR", os.path.join(CraftStandardDirs.craftRoot(), | 311 | CraftCore.settings.get("Paths", "CCACHE_DIR", os.path.join(CraftStandardDirs.craftRoot(), | ||
268 | "build", "CCACHE"))) | 312 | "build", "CCACHE"))) | ||
269 | 313 | | |||
270 | if OsUtils.isWin(): | 314 | if OsUtils.isWin(): | ||
271 | self._setupWin() | 315 | self._setupWin() | ||
272 | else: | 316 | elif OsUtils.isUnix(): | ||
273 | self.setXDG() | 317 | self._setupUnix() | ||
274 | 318 | | |||
275 | self.prependEnvVar("PKG_CONFIG_PATH", os.path.join(CraftStandardDirs.craftRoot(), "lib", "pkgconfig")) | 319 | self.prependEnvVar("PKG_CONFIG_PATH", os.path.join(CraftStandardDirs.craftRoot(), "lib", "pkgconfig")) | ||
276 | 320 | | |||
277 | self.prependEnvVar("QT_PLUGIN_PATH", [os.path.join(CraftStandardDirs.craftRoot(), "plugins"), | 321 | self.prependEnvVar("QT_PLUGIN_PATH", [os.path.join(CraftStandardDirs.craftRoot(), "plugins"), | ||
278 | os.path.join(CraftStandardDirs.craftRoot(), "lib", "plugins"), | 322 | os.path.join(CraftStandardDirs.craftRoot(), "lib", "plugins"), | ||
279 | os.path.join(CraftStandardDirs.craftRoot(), "lib64", "plugins"), | 323 | os.path.join(CraftStandardDirs.craftRoot(), "lib64", "plugins"), | ||
280 | os.path.join(CraftStandardDirs.craftRoot(), "lib", "x86_64-linux-gnu", | 324 | os.path.join(CraftStandardDirs.craftRoot(), "lib", "x86_64-linux-gnu", | ||
281 | "plugins"), | 325 | "plugins"), | ||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |