Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development'
Browse files Browse the repository at this point in the history
  • Loading branch information
rewrking committed Jun 9, 2022
2 parents 829b2ea + aaa846d commit b993b1e
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 47 deletions.
4 changes: 2 additions & 2 deletions .vscode/chalet.code-snippets
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Cruise Header File": {
"Chalet Header File": {
"prefix": "chaleth",
"description": "Chalet Class hpp file",
"scope": "cpp",
Expand All @@ -26,7 +26,7 @@
""
],
},
"Cruise Implementation File": {
"Chalet Implementation File": {
"prefix": "chaletc",
"description": "Chalet Class cpp file",
"scope": "cpp",
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.16)

project(chalet-debug
VERSION 0.3.9
VERSION 0.4.0
DESCRIPTION "A JSON-based project & build tool"
HOMEPAGE_URL "https://www.chalet-work.space"
LANGUAGES CXX
Expand Down
2 changes: 1 addition & 1 deletion chalet.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Chalet",
"version": "0.3.9",
"version": "0.4.0",
"description": "A JSON-based project & build tool",
"homepage": "https://www.chalet-work.space",
"author": "Cosmic Road Interactive, LLC.",
Expand Down
9 changes: 6 additions & 3 deletions src/Builder/CmakeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,12 @@ StringList CmakeBuilder::getBuildCommand(const std::string& inLocation) const
if (m_state.info.keepGoing())
ret.emplace_back("--keep-going");

ret.emplace_back("--no-builtin-rules");
ret.emplace_back("--no-builtin-variables");
ret.emplace_back("--no-print-directory");
if (!m_state.toolchain.makeIsNMake())
{
ret.emplace_back("--no-builtin-rules");
ret.emplace_back("--no-builtin-variables");
ret.emplace_back("--no-print-directory");
}
}
else if (isNinja && Output::showCommands())
{
Expand Down
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
51 changes: 24 additions & 27 deletions src/Compile/Generator/NinjaGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ std::string NinjaGenerator::getContents(const std::string& inPath) const
auto recipes = String::join(m_targetRecipes);

std::string msvcDepsPrefix;
#if defined(CHALET_WIN32)
if (m_needsMsvcDepsPrefix)
// #if defined(CHALET_WIN32)
/*if (m_needsMsvcDepsPrefix)
{
msvcDepsPrefix = "msvc_deps_prefix = Note: including file:";
}
#endif
}*/
// #endif

std::string ninjaTemplate = fmt::format(R"ninja(
builddir = {buildCache}
Expand Down 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
8 changes: 1 addition & 7 deletions src/Compile/Strategy/CompileStrategyNative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,6 @@ CommandPool::CmdList CompileStrategyNative::getCompileCommands(const SourceFileG
case SourceType::CPlusPlus:
case SourceType::ObjectiveC:
case SourceType::ObjectiveCPlusPlus: {
CxxSpecialization specialization = CxxSpecialization::CPlusPlus;
if (group->type == SourceType::ObjectiveC)
specialization = CxxSpecialization::ObjectiveC;
else if (group->type == SourceType::ObjectiveCPlusPlus)
specialization = CxxSpecialization::ObjectiveCPlusPlus;

bool sourceChanged = sourceCache.fileChangedOrDoesNotExist(source, target);
m_sourcesChanged |= sourceChanged;
if (sourceChanged || m_pchChanged)
Expand All @@ -311,7 +305,7 @@ CommandPool::CmdList CompileStrategyNative::getCompileCommands(const SourceFileG

CommandPool::Cmd out;
out.output = std::move(source);
out.command = getCxxCompile(source, target, specialization);
out.command = getCxxCompile(source, target, m_project->cxxSpecialization());
out.reference = out.output;

ret.emplace_back(std::move(out));
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
22 changes: 22 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 Expand Up @@ -491,6 +510,9 @@ SourceType BuildPaths::getSourceType(const std::string& inSource) const
{
if (String::equals(m_cExts, ext))
{
if (m_cxxExtension.empty())
m_cxxExtension = ext;

return SourceType::C;
}
else if (String::equals(m_resourceExts, ext))
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
24 changes: 21 additions & 3 deletions src/Terminal/Spinner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,34 @@
#include <signal.h>

#include "Terminal/Environment.hpp"
#include "Terminal/Output.hpp"

namespace chalet
{
namespace
{
static struct
{
std::mutex mutex;
Spinner* spinner = nullptr;
} state;

/*****************************************************************************/
void signalHandler(int inSignal)
{
if (state.spinner)
{
state.spinner->stop();
}

std::lock_guard<std::mutex> lock(state.mutex);

UNUSED(inSignal);
std::string output{ "\b\b \b\b" };
output += Output::getAnsiStyle(Color::Reset);
std::cout.write(output.data(), output.size());
std::cout.flush();

std::exit(1);
}
}

Expand All @@ -39,6 +55,7 @@ void Spinner::start()
destroy();

m_thread = std::make_unique<std::thread>(&Spinner::doRegularEllipsis, this);
state.spinner = this;
}

/*****************************************************************************/
Expand All @@ -58,6 +75,7 @@ bool Spinner::destroy()
m_thread->join();
m_thread.reset();
}
state.spinner = nullptr;

return result;
}
Expand Down Expand Up @@ -86,7 +104,7 @@ bool Spinner::sleepWithContext(const std::chrono::milliseconds& inLength)
void Spinner::doRegularEllipsis()
{
{
std::lock_guard<std::mutex> lock(m_mutex);
std::lock_guard<std::mutex> lock(state.mutex);
std::string output{ " ... " };
std::cout.write(output.data(), output.size());
std::cout.flush();
Expand Down Expand Up @@ -117,7 +135,7 @@ void Spinner::doRegularEllipsis()
}

{
std::lock_guard<std::mutex> lock(m_mutex);
std::lock_guard<std::mutex> lock(state.mutex);
std::cout.write(output.data(), output.size());
std::cout.flush();
}
Expand Down

0 comments on commit b993b1e

Please sign in to comment.