mirror of
https://github.com/hyprwm/Hyprland.git
synced 2026-08-24 10:04:19 -05:00
hyprpm: allow distro packagers to provide extra cflags for building plugins (#14755)
This commit is contained in:
@@ -313,8 +313,10 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
|
||||
|
||||
progress.printMessageAbove(infoString("Building {}", p.name));
|
||||
|
||||
const auto env = getPluginBuildEnv();
|
||||
|
||||
for (auto const& bs : p.buildSteps) {
|
||||
const auto CMD_RAW = nixDevelopIfNeeded(std::format("cd {} && PKG_CONFIG_PATH=\"{}\" {}", m_szWorkingPluginDirectory, getPkgConfigPath(), bs), HLVER);
|
||||
const auto CMD_RAW = nixDevelopIfNeeded(std::format("cd {} && {} {}", m_szWorkingPluginDirectory, env, bs), HLVER);
|
||||
|
||||
if (!CMD_RAW) {
|
||||
progress.printMessageAbove(failureString("Failed to build {}: {}", p.name, CMD_RAW.error()));
|
||||
@@ -766,8 +768,10 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
|
||||
|
||||
progress.printMessageAbove(infoString("Building {}", p.name));
|
||||
|
||||
const auto env = getPluginBuildEnv();
|
||||
|
||||
for (auto const& bs : p.buildSteps) {
|
||||
const auto CMD_RAW = nixDevelopIfNeeded(std::format("cd {} && PKG_CONFIG_PATH=\"{}\" {}", m_szWorkingPluginDirectory, getPkgConfigPath(), bs), HLVER);
|
||||
const auto CMD_RAW = nixDevelopIfNeeded(std::format("cd {} && {} {}", m_szWorkingPluginDirectory, env, bs), HLVER);
|
||||
|
||||
if (!CMD_RAW) {
|
||||
progress.printMessageAbove(failureString("Failed to build {}: {}", p.name, CMD_RAW.error()));
|
||||
@@ -1035,6 +1039,22 @@ bool CPluginManager::hasDeps() {
|
||||
return hasAllDeps;
|
||||
}
|
||||
|
||||
std::string CPluginManager::getPluginBuildEnv() {
|
||||
std::string env = std::format("PKG_CONFIG_PATH=\"{}\"", getPkgConfigPath());
|
||||
|
||||
#if defined(HYPRPM_EXTRA_CFLAGS)
|
||||
if (std::string_view{HYPRPM_EXTRA_CFLAGS}.size() > 0)
|
||||
env += std::format(" CFLAGS=\"{} $CFLAGS\"", HYPRPM_EXTRA_CFLAGS);
|
||||
#endif
|
||||
|
||||
#if defined(HYPRPM_EXTRA_CXXFLAGS)
|
||||
if (std::string_view{HYPRPM_EXTRA_CXXFLAGS}.size() > 0)
|
||||
env += std::format(" CXXFLAGS=\"{} $CXXFLAGS\"", HYPRPM_EXTRA_CXXFLAGS);
|
||||
#endif
|
||||
|
||||
return env;
|
||||
}
|
||||
|
||||
const std::string& CPluginManager::getPkgConfigPath() {
|
||||
static const auto str = std::format("{}/share/pkgconfig:$PKG_CONFIG_PATH", DataState::getHeadersPath());
|
||||
return str;
|
||||
|
||||
@@ -66,6 +66,7 @@ class CPluginManager {
|
||||
|
||||
void notify(const eNotifyIcons icon, uint32_t color, int durationMs, const std::string& message);
|
||||
|
||||
std::string getPluginBuildEnv();
|
||||
const std::string& getPkgConfigPath();
|
||||
|
||||
bool hasDeps();
|
||||
|
||||
Reference in New Issue
Block a user