diff --git a/.vscode/chalet.code-snippets b/.vscode/chalet.code-snippets index c9eb59b43..2a31b3927 100644 --- a/.vscode/chalet.code-snippets +++ b/.vscode/chalet.code-snippets @@ -1,5 +1,5 @@ { - "Cruise Header File": { + "Chalet Header File": { "prefix": "chaleth", "description": "Chalet Class hpp file", "scope": "cpp", @@ -26,7 +26,7 @@ "" ], }, - "Cruise Implementation File": { + "Chalet Implementation File": { "prefix": "chaletc", "description": "Chalet Class cpp file", "scope": "cpp", diff --git a/CMakeLists.txt b/CMakeLists.txt index b0d62b099..1d9f37c22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/chalet.json b/chalet.json index eaf3176fb..38bfdd0ee 100644 --- a/chalet.json +++ b/chalet.json @@ -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.", diff --git a/src/Builder/CmakeBuilder.cpp b/src/Builder/CmakeBuilder.cpp index 14174d5c9..645717bc2 100644 --- a/src/Builder/CmakeBuilder.cpp +++ b/src/Builder/CmakeBuilder.cpp @@ -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()) { diff --git a/src/Compile/Generator/MakefileGeneratorGNU.cpp b/src/Compile/Generator/MakefileGeneratorGNU.cpp index 79255193f..f2b1aa0e1 100644 --- a/src/Compile/Generator/MakefileGeneratorGNU.cpp +++ b/src/Compile/Generator/MakefileGeneratorGNU.cpp @@ -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), diff --git a/src/Compile/Generator/MakefileGeneratorNMake.cpp b/src/Compile/Generator/MakefileGeneratorNMake.cpp index d30bb78fb..8a75be4df 100644 --- a/src/Compile/Generator/MakefileGeneratorNMake.cpp +++ b/src/Compile/Generator/MakefileGeneratorNMake.cpp @@ -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)); diff --git a/src/Compile/Generator/NinjaGenerator.cpp b/src/Compile/Generator/NinjaGenerator.cpp index eece0a1d8..62942636c 100644 --- a/src/Compile/Generator/NinjaGenerator.cpp +++ b/src/Compile/Generator/NinjaGenerator.cpp @@ -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} @@ -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) { @@ -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(); @@ -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; diff --git a/src/Compile/Strategy/CompileStrategyNative.cpp b/src/Compile/Strategy/CompileStrategyNative.cpp index c03c2bdee..0732dbcc5 100644 --- a/src/Compile/Strategy/CompileStrategyNative.cpp +++ b/src/Compile/Strategy/CompileStrategyNative.cpp @@ -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) @@ -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)); diff --git a/src/Libraries/WindowsApi.hpp b/src/Libraries/WindowsApi.hpp index b673b994b..9b93edb44 100644 --- a/src/Libraries/WindowsApi.hpp +++ b/src/Libraries/WindowsApi.hpp @@ -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 diff --git a/src/State/BuildPaths.cpp b/src/State/BuildPaths.cpp index a7b88a9d6..3d85783cc 100644 --- a/src/State/BuildPaths.cpp +++ b/src/State/BuildPaths.cpp @@ -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; +} + /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ @@ -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)) diff --git a/src/State/BuildPaths.hpp b/src/State/BuildPaths.hpp index a09676a02..35356011e 100644 --- a/src/State/BuildPaths.hpp +++ b/src/State/BuildPaths.hpp @@ -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(); diff --git a/src/Terminal/Spinner.cpp b/src/Terminal/Spinner.cpp index 47245925a..fc4c667b9 100644 --- a/src/Terminal/Spinner.cpp +++ b/src/Terminal/Spinner.cpp @@ -8,18 +8,34 @@ #include #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 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); } } @@ -39,6 +55,7 @@ void Spinner::start() destroy(); m_thread = std::make_unique(&Spinner::doRegularEllipsis, this); + state.spinner = this; } /*****************************************************************************/ @@ -58,6 +75,7 @@ bool Spinner::destroy() m_thread->join(); m_thread.reset(); } + state.spinner = nullptr; return result; } @@ -86,7 +104,7 @@ bool Spinner::sleepWithContext(const std::chrono::milliseconds& inLength) void Spinner::doRegularEllipsis() { { - std::lock_guard lock(m_mutex); + std::lock_guard lock(state.mutex); std::string output{ " ... " }; std::cout.write(output.data(), output.size()); std::cout.flush(); @@ -117,7 +135,7 @@ void Spinner::doRegularEllipsis() } { - std::lock_guard lock(m_mutex); + std::lock_guard lock(state.mutex); std::cout.write(output.data(), output.size()); std::cout.flush(); }