Skip to content

Commit

Permalink
force rebuild rc targets if configure file changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rewrking committed Jun 9, 2022
1 parent 4bba486 commit aaa846d
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 26 deletions.
10 changes: 9 additions & 1 deletion src/Compile/Generator/MakefileGeneratorGNU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,22 @@ std::string MakefileGeneratorGNU::getRcRecipe(const std::string& ext, const std:
makeDependency = fmt::format("\n\t@{}", getFallbackMakeDependsCommand(dependency, "$<", "$@"));
}

std::string configureFilesDeps;
if (!m_project->configureFiles().empty())
{
auto deps = String::join(m_state.paths.getConfigureFiles(*m_project));
configureFilesDeps = fmt::format(" {}", deps);
}

ret += fmt::format(R"makefile(
{objDir}/%.{ext}.res: %.{ext} {pchTarget} | {depDir}/%.{ext}.d
{objDir}/%.{ext}.res: %.{ext} {pchTarget} | {depDir}/%.{ext}.d{configureFilesDeps}
{compileEcho}
{quietFlag}{rcCompile}{makeDependency}
)makefile",
FMT_ARG(objDir),
FMT_ARG(depDir),
FMT_ARG(ext),
FMT_ARG(configureFilesDeps),
FMT_ARG(pchTarget),
FMT_ARG(dependency),
FMT_ARG(compileEcho),
Expand Down
10 changes: 9 additions & 1 deletion src/Compile/Generator/MakefileGeneratorNMake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,21 @@ std::string MakefileGeneratorNMake::getRcRecipe(const std::string& source, const
{
const auto compilerEcho = getCompileEchoSources(source);

std::string configureFilesDeps;
if (!m_project->configureFiles().empty())
{
auto deps = String::join(m_state.paths.getConfigureFiles(*m_project));
configureFilesDeps = fmt::format(" {}", deps);
}

ret = fmt::format(R"makefile(
{object}: {source}
{object}: {source}{configureFilesDeps}
{compilerEcho}
{quietFlag}{rcCompile} 1>nul
)makefile",
FMT_ARG(object),
FMT_ARG(source),
FMT_ARG(configureFilesDeps),
FMT_ARG(compilerEcho),
FMT_ARG(quietFlag),
FMT_ARG(rcCompile));
Expand Down
43 changes: 20 additions & 23 deletions src/Compile/Generator/NinjaGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,11 @@ std::string NinjaGenerator::getObjBuildRules(const SourceFileGroupList& inGroups
{
std::string ret;

StringList pches;
std::string pchImplicitDep;
if (m_project->usesPrecompiledHeader())
{
const auto pchTarget = m_state.paths.getPrecompiledHeaderTarget(*m_project);
StringList pches;
auto pchTarget = m_state.paths.getPrecompiledHeaderTarget(*m_project);
#if defined(CHALET_MACOS)
if (m_state.info.targetArchitecture() == Arch::Cpu::UniversalMacOS)
{
Expand All @@ -458,14 +459,20 @@ std::string NinjaGenerator::getObjBuildRules(const SourceFileGroupList& inGroups
else
#endif
{
pches.push_back(pchTarget);
pches.push_back(std::move(pchTarget));
}
if (!pches.empty())
{
auto deps = String::join(std::move(pches));
pchImplicitDep = fmt::format(" | {}", deps);
}
}

std::string pchImplicitDep;
if (!pches.empty())
std::string configureFilesDeps;
if (!m_project->configureFiles().empty())
{
pchImplicitDep = fmt::format(" | {}", String::join(std::move(pches)));
auto deps = String::join(m_state.paths.getConfigureFiles(*m_project));
configureFilesDeps = fmt::format(" | {}", deps);
}

const bool objectiveCxx = m_project->objectiveCxx();
Expand Down Expand Up @@ -512,23 +519,13 @@ std::string NinjaGenerator::getObjBuildRules(const SourceFileGroupList& inGroups
if (rule.empty())
continue;

if (group->type != SourceType::WindowsResource)
{
ret += fmt::format("build {object}: {rule}_{hash} {source}{pchImplicitDep}\n",
fmt::arg("hash", m_hash),
FMT_ARG(object),
FMT_ARG(rule),
FMT_ARG(source),
FMT_ARG(pchImplicitDep));
}
else
{
ret += fmt::format("build {object}: {rule}_{hash} {source}\n",
fmt::arg("hash", m_hash),
FMT_ARG(object),
FMT_ARG(rule),
FMT_ARG(source));
}
const auto& implicitDeps = group->type != SourceType::WindowsResource ? pchImplicitDep : configureFilesDeps;
ret += fmt::format("build {object}: {rule}_{hash} {source}{implicitDeps}\n",
fmt::arg("hash", m_hash),
FMT_ARG(object),
FMT_ARG(rule),
FMT_ARG(source),
FMT_ARG(implicitDeps));
}

return ret;
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/WindowsApi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define CHALET_WINDOWS_API_HPP

// Windows
#if defined(CHALET_WIN32)
#if defined(_WIN32) && !defined(RC_INVOKED)
#ifndef UNICODE
#define UNICODE
#endif
Expand Down
19 changes: 19 additions & 0 deletions src/State/BuildPaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,25 @@ std::string BuildPaths::getWindowsIconResourceFilename(const SourceTarget& inPro
return std::string();
}

/*****************************************************************************/
StringList BuildPaths::getConfigureFiles(const SourceTarget& inProject) const
{
StringList ret;

if (!inProject.configureFiles().empty())
{
auto outFolder = intermediateDir(inProject);
for (const auto& configureFile : inProject.configureFiles())
{
auto outFile = String::getPathFilename(configureFile);
outFile = outFile.substr(0, outFile.size() - 3);

ret.emplace_back(fmt::format("{}/{}", outFolder, outFile));
}
}
return ret;
}

/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
Expand Down
1 change: 1 addition & 0 deletions src/State/BuildPaths.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct BuildPaths
std::string getWindowsManifestFilename(const SourceTarget& inProject) const;
std::string getWindowsManifestResourceFilename(const SourceTarget& inProject) const;
std::string getWindowsIconResourceFilename(const SourceTarget& inProject) const;
StringList getConfigureFiles(const SourceTarget& inProject) const;

void setBuildDirectoriesBasedOnProjectKind(const SourceTarget& inProject);
void clearOutputCaches();
Expand Down

0 comments on commit aaa846d

Please sign in to comment.