mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
StdIo: Replace uses of KWSys ConsoleBuf with StdIo::Console
Issue: #26924
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
#include "cmCPackGeneratorFactory.h"
|
||||
#include "cmCPackLog.h"
|
||||
#include "cmCommandLineArgument.h"
|
||||
#include "cmConsoleBuf.h"
|
||||
#include "cmDocumentation.h"
|
||||
#include "cmDocumentationEntry.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
@@ -33,6 +32,7 @@
|
||||
#include "cmMakefile.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStdIoConsole.h"
|
||||
#include "cmStdIoInit.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
@@ -92,9 +92,7 @@ int main(int argc, char const* const* argv)
|
||||
{
|
||||
cm::StdIo::Init();
|
||||
|
||||
// Replace streambuf so we can output Unicode to console
|
||||
cmConsoleBuf consoleBuf;
|
||||
consoleBuf.SetUTF8Pipes();
|
||||
cm::StdIo::Console console;
|
||||
|
||||
cmsys::Encoding::CommandLineArguments args =
|
||||
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
|
||||
|
@@ -16,7 +16,6 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <cm/memory>
|
||||
#include <cm/optional>
|
||||
#include <cmext/algorithm>
|
||||
|
||||
@@ -24,7 +23,6 @@
|
||||
|
||||
#include "cmBuildOptions.h"
|
||||
#include "cmCommandLineArgument.h"
|
||||
#include "cmConsoleBuf.h"
|
||||
#include "cmDocumentationEntry.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmInstallScriptHandler.h"
|
||||
@@ -35,6 +33,7 @@
|
||||
#include "cmMessageMetadata.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStdIoConsole.h"
|
||||
#include "cmStdIoInit.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
@@ -139,13 +138,13 @@ cmDocumentationEntry const cmDocumentationOptions[35] = {
|
||||
#endif
|
||||
|
||||
int do_command(int ac, char const* const* av,
|
||||
std::unique_ptr<cmConsoleBuf> consoleBuf)
|
||||
cm::optional<cm::StdIo::Console> console)
|
||||
{
|
||||
std::vector<std::string> args;
|
||||
args.reserve(ac - 1);
|
||||
args.emplace_back(av[0]);
|
||||
cm::append(args, av + 2, av + ac);
|
||||
return cmcmd::ExecuteCMakeCommand(args, std::move(consoleBuf));
|
||||
return cmcmd::ExecuteCMakeCommand(args, std::move(console));
|
||||
}
|
||||
|
||||
cmMakefile* cmakemainGetMakefile(cmake* cm)
|
||||
@@ -1145,9 +1144,7 @@ int main(int ac, char const* const* av)
|
||||
{
|
||||
cm::StdIo::Init();
|
||||
|
||||
// Replace streambuf so we can output Unicode to console
|
||||
auto consoleBuf = cm::make_unique<cmConsoleBuf>();
|
||||
consoleBuf->SetUTF8Pipes();
|
||||
cm::optional<cm::StdIo::Console> console = cm::StdIo::Console();
|
||||
|
||||
cmsys::Encoding::CommandLineArguments args =
|
||||
cmsys::Encoding::CommandLineArguments::Main(ac, av);
|
||||
@@ -1170,7 +1167,7 @@ int main(int ac, char const* const* av)
|
||||
return do_workflow(ac, av);
|
||||
}
|
||||
if (strcmp(av[1], "-E") == 0) {
|
||||
return do_command(ac, av, std::move(consoleBuf));
|
||||
return do_command(ac, av, std::move(console));
|
||||
}
|
||||
if (strcmp(av[1], "--print-config-dir") == 0) {
|
||||
std::cout << cmSystemTools::ConvertToOutputPath(
|
||||
|
@@ -12,7 +12,6 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "cmCommandLineArgument.h"
|
||||
#include "cmConsoleBuf.h"
|
||||
#include "cmCryptoHash.h"
|
||||
#include "cmDuration.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
@@ -26,6 +25,7 @@
|
||||
#include "cmState.h"
|
||||
#include "cmStateDirectory.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStdIoConsole.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTransformDepfile.h"
|
||||
@@ -689,7 +689,7 @@ int cmcmd::HandleCoCompileCommands(std::vector<std::string> const& args)
|
||||
}
|
||||
|
||||
int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
|
||||
std::unique_ptr<cmConsoleBuf> consoleBuf)
|
||||
cm::optional<cm::StdIo::Console> console)
|
||||
{
|
||||
// IF YOU ADD A NEW COMMAND, DOCUMENT IT ABOVE and in cmakemain.cxx
|
||||
if (args.size() > 1) {
|
||||
@@ -1191,7 +1191,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
|
||||
if (arg == "-") {
|
||||
doing_options = false;
|
||||
// Destroy console buffers to drop cout/cerr encoding transform.
|
||||
consoleBuf.reset();
|
||||
console.reset();
|
||||
cmCatFile(arg);
|
||||
} else if (doing_options && cmHasLiteralPrefix(arg, "-")) {
|
||||
if (arg == "--") {
|
||||
@@ -1215,7 +1215,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
|
||||
// Ignore empty files, this is not an error
|
||||
} else {
|
||||
// Destroy console buffers to drop cout/cerr encoding transform.
|
||||
consoleBuf.reset();
|
||||
console.reset();
|
||||
cmCatFile(arg);
|
||||
}
|
||||
}
|
||||
@@ -1464,11 +1464,11 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
|
||||
}
|
||||
|
||||
if (args[1] == "vs_link_exe") {
|
||||
return cmcmd::VisualStudioLink(args, 1, std::move(consoleBuf));
|
||||
return cmcmd::VisualStudioLink(args, 1, std::move(console));
|
||||
}
|
||||
|
||||
if (args[1] == "vs_link_dll") {
|
||||
return cmcmd::VisualStudioLink(args, 2, std::move(consoleBuf));
|
||||
return cmcmd::VisualStudioLink(args, 2, std::move(console));
|
||||
}
|
||||
|
||||
if (args[1] == "cmake_llvm_rc") {
|
||||
@@ -2221,7 +2221,7 @@ private:
|
||||
// exe and dll's. This code does that in such a way that incremental linking
|
||||
// still works.
|
||||
int cmcmd::VisualStudioLink(std::vector<std::string> const& args, int type,
|
||||
std::unique_ptr<cmConsoleBuf> consoleBuf)
|
||||
cm::optional<cm::StdIo::Console> console)
|
||||
{
|
||||
// MSVC tools print output in the language specified by the VSLANG
|
||||
// environment variable, and encoded in the console output code page.
|
||||
@@ -2229,7 +2229,7 @@ int cmcmd::VisualStudioLink(std::vector<std::string> const& args, int type,
|
||||
// RunCommand tells RunSingleCommand to *not* convert encoding, so
|
||||
// we buffer the output in its original encoding instead of UTF-8.
|
||||
// Drop our output encoding conversion so we print with original encoding.
|
||||
consoleBuf.reset();
|
||||
console.reset();
|
||||
|
||||
if (args.size() < 2) {
|
||||
return -1;
|
||||
|
@@ -4,15 +4,20 @@
|
||||
|
||||
#include "cmConfigure.h" // IWYU pragma: keep
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <cm/optional>
|
||||
|
||||
#include "cmsys/Status.hxx"
|
||||
|
||||
#include "cmCryptoHash.h"
|
||||
|
||||
class cmConsoleBuf;
|
||||
namespace cm {
|
||||
namespace StdIo {
|
||||
class Console;
|
||||
}
|
||||
}
|
||||
|
||||
class cmcmd
|
||||
{
|
||||
@@ -22,7 +27,7 @@ public:
|
||||
* as echo, remove file etc.
|
||||
*/
|
||||
static int ExecuteCMakeCommand(std::vector<std::string> const&,
|
||||
std::unique_ptr<cmConsoleBuf> consoleBuf);
|
||||
cm::optional<cm::StdIo::Console> console);
|
||||
|
||||
protected:
|
||||
static int HandleCoCompileCommands(std::vector<std::string> const& args);
|
||||
@@ -40,5 +45,5 @@ protected:
|
||||
std::string const& intermediate_file);
|
||||
static int RunLLVMRC(std::vector<std::string> const& args);
|
||||
static int VisualStudioLink(std::vector<std::string> const& args, int type,
|
||||
std::unique_ptr<cmConsoleBuf> consoleBuf);
|
||||
cm::optional<cm::StdIo::Console> console);
|
||||
};
|
||||
|
@@ -9,11 +9,11 @@
|
||||
#include "cmsys/Encoding.hxx"
|
||||
|
||||
#include "cmCTest.h"
|
||||
#include "cmConsoleBuf.h"
|
||||
#include "cmDocumentation.h"
|
||||
#include "cmDocumentationEntry.h"
|
||||
#include "cmInstrumentation.h"
|
||||
#include "cmInstrumentationQuery.h"
|
||||
#include "cmStdIoConsole.h"
|
||||
#include "cmStdIoInit.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
@@ -169,9 +169,7 @@ int main(int argc, char const* const* argv)
|
||||
{
|
||||
cm::StdIo::Init();
|
||||
|
||||
// Replace streambuf so we can output Unicode to console
|
||||
cmConsoleBuf consoleBuf;
|
||||
consoleBuf.SetUTF8Pipes();
|
||||
cm::StdIo::Console console;
|
||||
|
||||
cmsys::Encoding::CommandLineArguments encoding_args =
|
||||
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
|
||||
|
Reference in New Issue
Block a user