hyprpm: allow distro packagers to provide extra cflags for building plugins (#14755)

This commit is contained in:
Yingjie Wang
2026-05-25 16:34:56 +01:00
committed by GitHub
parent d8008a8168
commit 457eb66dfb
2 changed files with 23 additions and 2 deletions
+22 -2
View File
@@ -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;
+1
View File
@@ -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();